1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 package ifc.configuration.backend;
24 
25 import com.sun.star.configuration.backend.XBackendEntities;
26 
27 import lib.MultiMethodTest;
28 
29 
30 public class _XBackendEntities extends MultiMethodTest {
31     String AdminEntity = "";
32     String OwnerEntity = "";
33     String adm = "";
34     public XBackendEntities oObj;
35 
before()36     public void before() {
37         adm = (String) tEnv.getObjRelation("NoAdmin");
38     }
39 
_getAdminEntity()40     public void _getAdminEntity() {
41         if (adm != null) {
42             AdminEntity = adm;
43             log.println(
44                     "This component doesn't have an AdminEntity, setting it to default");
45             tRes.tested("getAdminEntity()", true);
46 
47             return;
48         }
49 
50         AdminEntity = oObj.getAdminEntity();
51 
52         boolean res = AdminEntity.endsWith("/share/registry");
53 
54         if (!res) {
55             log.println("Expected the Entity to end with /share/registry");
56             log.println("getting: " + AdminEntity + " -- FAILED");
57         }
58 
59         tRes.tested("getAdminEntity()", res);
60     }
61 
_getOwnerEntity()62     public void _getOwnerEntity() {
63         OwnerEntity = oObj.getOwnerEntity();
64 
65         boolean res = OwnerEntity.endsWith("/user/registry");
66 
67         if (!res) {
68             log.println("Expected the Entity to end with /user/registry");
69             log.println("getting: " + OwnerEntity + " -- FAILED");
70         }
71 
72         tRes.tested("getOwnerEntity()", res);
73     }
74 
_isEqualEntity()75     public void _isEqualEntity() {
76         boolean res = true;
77         boolean localRes = true;
78 
79         try {
80             localRes = oObj.isEqualEntity("", "");
81             log.println(
82                     "No Exception thrown for isEqualEntity(\"\",\"\") -- FAILED");
83             res &= false;
84         } catch (com.sun.star.configuration.backend.BackendAccessException e) {
85             log.println("Unexpected Exception (" + e + ") -- FAILED");
86             res &= false;
87         } catch (com.sun.star.lang.IllegalArgumentException e) {
88             log.println("Expected Exception (" + e + ") -- OK");
89             res &= true;
90         }
91 
92         try {
93             localRes = oObj.isEqualEntity(AdminEntity, AdminEntity);
94 
95             if (!localRes) {
96                 log.println(
97                         "isEqualEntity(AdminEntity,AdminEntity) returns false -- FAILED");
98             }
99 
100             res &= localRes;
101 
102             localRes = oObj.isEqualEntity(OwnerEntity, OwnerEntity);
103 
104             if (!localRes) {
105                 log.println(
106                         "isEqualEntity(OwnerEntity,OwnerEntity) returns false -- FAILED");
107             }
108 
109             res &= localRes;
110 
111             localRes = !oObj.isEqualEntity(AdminEntity, OwnerEntity);
112 
113             if (!localRes) {
114                 log.println(
115                         "isEqualEntity(AdminEntity,OwnerEntity) returns true -- FAILED");
116             }
117 
118             res &= localRes;
119         } catch (com.sun.star.configuration.backend.BackendAccessException e) {
120             log.println("Unexpected Exception (" + e + ") -- FAILED");
121             res &= false;
122         } catch (com.sun.star.lang.IllegalArgumentException e) {
123             log.println("Unexpected Exception (" + e + ") -- FAILED");
124             res &= false;
125         }
126 
127         tRes.tested("isEqualEntity()", res);
128     }
129 
_supportsEntity()130     public void _supportsEntity() {
131         boolean res = true;
132         boolean localRes = true;
133 
134         try {
135             localRes = oObj.supportsEntity("illegal");
136             log.println(
137                     "No Exception thrown for supportsEntity(\"\") -- FAILED");
138             res &= false;
139         } catch (com.sun.star.configuration.backend.BackendAccessException e) {
140             log.println("Expected Exception (" + e + ") -- OK");
141             res &= true;
142         }
143 
144         try {
145             localRes = oObj.supportsEntity(AdminEntity);
146 
147             if (adm != null) {
148                 Object msb = tEnv.getObjRelation("MSB") ;
149                 if (msb == null){
150                     localRes = !localRes;
151                     log.println("This Component doesn't support the AdminEntity");
152                 }
153             }
154 
155             if (!localRes) {
156                 log.println(
157                         "supportsEntity(AdminEntity) returns false -- FAILED");
158             }
159 
160             res &= localRes;
161 
162             localRes = oObj.supportsEntity(OwnerEntity);
163 
164             if (!localRes) {
165                 log.println(
166                         "supportsEntity(OwnerEntity) returns false -- FAILED");
167             }
168 
169             res &= localRes;
170         } catch (com.sun.star.configuration.backend.BackendAccessException e) {
171             log.println("Unexpected Exception (" + e + ") -- FAILED");
172             res &= false;
173         }
174 
175         tRes.tested("supportsEntity()", res);
176     }
177 }