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