1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 package ifc.configuration.backend; 28 29 import com.sun.star.configuration.backend.XBackendEntities; 30 31 import lib.MultiMethodTest; 32 33 34 public class _XBackendEntities extends MultiMethodTest { 35 String AdminEntity = ""; 36 String OwnerEntity = ""; 37 String adm = ""; 38 public XBackendEntities oObj; 39 40 public void before() { 41 adm = (String) tEnv.getObjRelation("NoAdmin"); 42 } 43 44 public void _getAdminEntity() { 45 if (adm != null) { 46 AdminEntity = adm; 47 log.println( 48 "This component doesn't have an AdminEntity, setting it to default"); 49 tRes.tested("getAdminEntity()", true); 50 51 return; 52 } 53 54 AdminEntity = oObj.getAdminEntity(); 55 56 boolean res = AdminEntity.endsWith("/share/registry"); 57 58 if (!res) { 59 log.println("Expected the Entity to end with /share/registry"); 60 log.println("getting: " + AdminEntity + " -- FAILED"); 61 } 62 63 tRes.tested("getAdminEntity()", res); 64 } 65 66 public void _getOwnerEntity() { 67 OwnerEntity = oObj.getOwnerEntity(); 68 69 boolean res = OwnerEntity.endsWith("/user/registry"); 70 71 if (!res) { 72 log.println("Expected the Entity to end with /user/registry"); 73 log.println("getting: " + OwnerEntity + " -- FAILED"); 74 } 75 76 tRes.tested("getOwnerEntity()", res); 77 } 78 79 public void _isEqualEntity() { 80 boolean res = true; 81 boolean localRes = true; 82 83 try { 84 localRes = oObj.isEqualEntity("", ""); 85 log.println( 86 "No Exception thrown for isEqualEntity(\"\",\"\") -- FAILED"); 87 res &= false; 88 } catch (com.sun.star.configuration.backend.BackendAccessException e) { 89 log.println("Unexpected Exception (" + e + ") -- FAILED"); 90 res &= false; 91 } catch (com.sun.star.lang.IllegalArgumentException e) { 92 log.println("Expected Exception (" + e + ") -- OK"); 93 res &= true; 94 } 95 96 try { 97 localRes = oObj.isEqualEntity(AdminEntity, AdminEntity); 98 99 if (!localRes) { 100 log.println( 101 "isEqualEntity(AdminEntity,AdminEntity) returns false -- FAILED"); 102 } 103 104 res &= localRes; 105 106 localRes = oObj.isEqualEntity(OwnerEntity, OwnerEntity); 107 108 if (!localRes) { 109 log.println( 110 "isEqualEntity(OwnerEntity,OwnerEntity) returns false -- FAILED"); 111 } 112 113 res &= localRes; 114 115 localRes = !oObj.isEqualEntity(AdminEntity, OwnerEntity); 116 117 if (!localRes) { 118 log.println( 119 "isEqualEntity(AdminEntity,OwnerEntity) returns true -- FAILED"); 120 } 121 122 res &= localRes; 123 } catch (com.sun.star.configuration.backend.BackendAccessException e) { 124 log.println("Unexpected Exception (" + e + ") -- FAILED"); 125 res &= false; 126 } catch (com.sun.star.lang.IllegalArgumentException e) { 127 log.println("Unexpected Exception (" + e + ") -- FAILED"); 128 res &= false; 129 } 130 131 tRes.tested("isEqualEntity()", res); 132 } 133 134 public void _supportsEntity() { 135 boolean res = true; 136 boolean localRes = true; 137 138 try { 139 localRes = oObj.supportsEntity("illegal"); 140 log.println( 141 "No Exception thrown for supportsEntity(\"\") -- FAILED"); 142 res &= false; 143 } catch (com.sun.star.configuration.backend.BackendAccessException e) { 144 log.println("Expected Exception (" + e + ") -- OK"); 145 res &= true; 146 } 147 148 try { 149 localRes = oObj.supportsEntity(AdminEntity); 150 151 if (adm != null) { 152 Object msb = tEnv.getObjRelation("MSB") ; 153 if (msb == null){ 154 localRes = !localRes; 155 log.println("This Component doesn't support the AdminEntity"); 156 } 157 } 158 159 if (!localRes) { 160 log.println( 161 "supportsEntity(AdminEntity) returns false -- FAILED"); 162 } 163 164 res &= localRes; 165 166 localRes = oObj.supportsEntity(OwnerEntity); 167 168 if (!localRes) { 169 log.println( 170 "supportsEntity(OwnerEntity) returns false -- FAILED"); 171 } 172 173 res &= localRes; 174 } catch (com.sun.star.configuration.backend.BackendAccessException e) { 175 log.println("Unexpected Exception (" + e + ") -- FAILED"); 176 res &= false; 177 } 178 179 tRes.tested("supportsEntity()", res); 180 } 181 }