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 
24 package ifc.configuration.backend;
25 
26 import com.sun.star.configuration.backend.XBackend;
27 import com.sun.star.configuration.backend.XLayerImporter;
28 import lib.MultiMethodTest;
29 
30 public class _XLayerImporter extends MultiMethodTest {
31 
32     public XLayerImporter oObj;
33     public XBackend xBackend = null;
34 
_getTargetBackend()35     public void _getTargetBackend() {
36         xBackend = oObj.getTargetBackend();
37         tRes.tested("getTargetBackend()", xBackend != null);
38     }
39 
_importLayer()40     public void _importLayer() {
41         boolean res = false;
42         log.println("checking for exception is argument null is given");
43         try {
44             oObj.importLayer(null);
45             log.println("\tException expected -- FAILED");
46         } catch (com.sun.star.lang.NullPointerException ne) {
47             res = true;
48             log.println("\tExpected exception was thrown -- OK");
49         } catch (com.sun.star.configuration.backend.MalformedDataException mde) {
50             res = false;
51             log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED");
52         } catch (com.sun.star.lang.IllegalArgumentException iae) {
53             res = false;
54             log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED");
55         } catch (com.sun.star.lang.WrappedTargetException wte) {
56             res = false;
57             log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED");
58         }
59 
60         log.println("checking own implementation of XLayer");
61         try {
62             util.XLayerImpl xLayer = new util.XLayerImpl();
63             oObj.importLayer(xLayer);
64             if (! xLayer.hasBeenCalled()) {
65                 log.println("\tXLayer hasn't been imported -- FAILED");
66                 res &= false;
67             } else {
68                 log.println("\tXLayer has been imported -- OK");
69                 res &= true;
70             }
71         } catch (com.sun.star.lang.NullPointerException ne) {
72             res &= false;
73             log.println("\tExpected exception "+ne+" was thrown -- FAILED");
74         } catch (com.sun.star.configuration.backend.MalformedDataException mde) {
75             res &= false;
76             log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED");
77         } catch (com.sun.star.lang.IllegalArgumentException iae) {
78             res &= false;
79             log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED");
80         } catch (com.sun.star.lang.WrappedTargetException wte) {
81             res &= false;
82             log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED");
83         }
84 
85         tRes.tested("importLayer()",res);
86     }
87 
_importLayerForEntity()88     public void _importLayerForEntity() {
89         boolean res = false;
90         log.println("checking for exception for argument (null,\"\")");
91         try {
92             oObj.importLayerForEntity(null,"");
93             log.println("\tException expected -- FAILED");
94         } catch (com.sun.star.lang.NullPointerException ne) {
95             res = true;
96             log.println("\tExpected exception was thrown -- OK");
97         } catch (com.sun.star.configuration.backend.MalformedDataException mde) {
98             res = false;
99             log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED");
100         } catch (com.sun.star.lang.IllegalArgumentException iae) {
101             res = false;
102             log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED");
103         } catch (com.sun.star.lang.WrappedTargetException wte) {
104             res = false;
105             log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED");
106         }
107 
108         log.println("checking own implementation of XLayer");
109         try {
110             util.XLayerImpl xLayer = new util.XLayerImpl();
111             oObj.importLayerForEntity(xLayer,"");
112             if (! xLayer.hasBeenCalled()) {
113                 log.println("\tXLayer hasn't been imported -- FAILED");
114                 res &= false;
115             } else {
116                 log.println("\tXLayer has been imported -- OK");
117                 res &= true;
118             }
119         } catch (com.sun.star.lang.NullPointerException ne) {
120             res &= false;
121             log.println("\tExpected exception "+ne+" was thrown -- FAILED");
122         } catch (com.sun.star.configuration.backend.MalformedDataException mde) {
123             res &= false;
124             log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED");
125         } catch (com.sun.star.lang.IllegalArgumentException iae) {
126             res &= false;
127             log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED");
128         } catch (com.sun.star.lang.WrappedTargetException wte) {
129             res &= false;
130             log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED");
131         }
132 
133         tRes.tested("importLayerForEntity()",res);
134     }
135 
_setTargetBackend()136     public void _setTargetBackend() {
137         requiredMethod("getTargetBackend()");
138         boolean res = false;
139         log.println("checking for exception if argument null is given");
140         try {
141             oObj.setTargetBackend(null);
142             log.println("\tException expected -- FAILED");
143         } catch (com.sun.star.lang.NullPointerException ne) {
144             res = true;
145             log.println("\tExpected exception was thrown -- OK");
146         }
147 
148         log.println("checking argument previously gained by getTargetBackend");
149         try {
150             oObj.setTargetBackend(xBackend);
151             log.println("\t No Exception thrown -- OK");
152             res &= true;
153         } catch (com.sun.star.lang.NullPointerException ne) {
154             res &= false;
155             log.println("\tException was thrown -- FAILED");
156         }
157 
158         tRes.tested("setTargetBackend()",res);
159 
160     }
161 
162 }
163