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