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.XLayer;
27 import lib.MultiMethodTest;
28 import util.XLayerHandlerImpl;
29 
30 public class _XLayer extends MultiMethodTest {
31 
32     public XLayer oObj;
33 
_readData()34     public void _readData() {
35         boolean res = false;
36 
37         log.println("Checking for Exception in case of nul argument");
38 
39         try {
40             oObj.readData(null);
41         } catch (com.sun.star.lang.NullPointerException e) {
42             log.println("Expected Exception -- OK");
43             res = true;
44         } catch (com.sun.star.lang.WrappedTargetException e) {
45             log.println("Unexpected Exception ("+e+") -- FAILED");
46         } catch (com.sun.star.configuration.backend.MalformedDataException e) {
47             log.println("Unexpected Exception ("+e+") -- FAILED");
48         }
49 
50         log.println("checking read data with own XLayerHandler implementation");
51         try {
52             XLayerHandlerImpl xLayerHandler = new XLayerHandlerImpl();
53             oObj.readData(xLayerHandler);
54             String implCalled = xLayerHandler.getCalls();
55             log.println(implCalled);
56             int sl = implCalled.indexOf("startLayer");
57             if (sl < 0) {
58                 log.println("startLayer wasn't called -- FAILED");
59                 res &= false;
60             } else {
61                 log.println("startLayer was called -- OK");
62                 res &= true;
63             }
64             int el = implCalled.indexOf("endLayer");
65             if (el < 0) {
66                 log.println("endLayer wasn't called -- FAILED");
67                 res &= false;
68             } else {
69                 log.println("endLayer was called -- OK");
70                 res &= true;
71             }
72         } catch (com.sun.star.lang.NullPointerException e) {
73             log.println("Unexpected Exception ("+e+") -- FAILED");
74             res &= false;
75         } catch (com.sun.star.lang.WrappedTargetException e) {
76             log.println("Unexpected Exception ("+e+") -- FAILED");
77             res &= false;
78         } catch (com.sun.star.configuration.backend.MalformedDataException e) {
79             log.println("Unexpected Exception ("+e+") -- FAILED");
80             res &= false;
81         }
82 
83         tRes.tested("readData()",res);
84     }
85 
86 }
87