bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / configuration / backend / _XSingleLayerStratum.java
blob4297c6c9f1dcdaaf75441a23d766a1790fdbef8c
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 * _XSingleLayerStratum.java
22 * Created on 23. March 2004, 16:37
24 package ifc.configuration.backend;
25 import com.sun.star.configuration.backend.XLayer;
26 import com.sun.star.configuration.backend.XSingleLayerStratum;
27 import com.sun.star.configuration.backend.XUpdatableLayer;
29 import lib.MultiMethodTest;
31 import util.XLayerHandlerImpl;
34 public class _XSingleLayerStratum extends MultiMethodTest {
35 public XSingleLayerStratum oObj;
37 public void _getLayer() {
38 String aLayerID = "org.openoffice.Office.Common";
39 boolean res = true;
41 try {
42 oObj.getLayer("", "");
43 log.println("Exception expected -- FAILED");
44 res = false;
45 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
46 log.println("unexpected Exception " + e + " -- FAILED");
47 res = false;
48 } catch (com.sun.star.lang.IllegalArgumentException e) {
49 log.println("expected Exception -- OK");
52 try {
53 XLayer aLayer = oObj.getLayer(aLayerID, "");
54 res &= (aLayer != null);
56 if (aLayer == null) {
57 log.println("\treturned Layer is NULL -- FAILED");
60 res &= checkLayer(aLayer);
61 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
62 log.println("unexpected Exception -- FAILED");
63 res = false;
64 } catch (com.sun.star.lang.IllegalArgumentException e) {
65 log.println("unexpected Exception -- FAILED");
66 res = false;
69 tRes.tested("getLayer()", res);
72 public void _getUpdatableLayer() {
73 String aLayerID = "org.openoffice.Office.Common";
74 boolean res = true;
76 try {
77 oObj.getUpdatableLayer("");
78 log.println("Exception expected -- FAILED");
79 res = false;
80 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
81 log.println("unexpected Exception " + e + " -- FAILED");
82 res = false;
83 } catch (com.sun.star.lang.IllegalArgumentException e) {
84 log.println("expected Exception -- OK");
85 } catch (com.sun.star.lang.NoSupportException e) {
86 log.println("unexpected Exception -- FAILED");
87 res = false;
90 try {
91 XUpdatableLayer aLayer = oObj.getUpdatableLayer(aLayerID);
92 res &= (aLayer != null);
94 if (aLayer == null) {
95 log.println("\treturned Layer is NULL -- FAILED");
98 res &= checkLayer(aLayer);
99 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
100 log.println("unexpected Exception -- FAILED");
101 res = false;
102 } catch (com.sun.star.lang.IllegalArgumentException e) {
103 log.println("unexpected Exception -- FAILED");
104 res = false;
105 } catch (com.sun.star.lang.NoSupportException e) {
106 log.println("unexpected Exception -- FAILED");
107 res = false;
110 tRes.tested("getUpdatableLayer()", res);
113 protected boolean checkLayer(XLayer aLayer) {
114 boolean res = false;
116 log.println("Checking for Exception in case of null argument");
118 try {
119 aLayer.readData(null);
120 } catch (com.sun.star.lang.NullPointerException e) {
121 log.println("Expected Exception -- OK");
122 res = true;
123 } catch (com.sun.star.lang.WrappedTargetException e) {
124 log.println("Unexpected Exception (" + e + ") -- FAILED");
125 } catch (com.sun.star.configuration.backend.MalformedDataException e) {
126 log.println("Unexpected Exception (" + e + ") -- FAILED");
129 log.println("checking read data with own XLayerHandler implementation");
131 try {
132 XLayerHandlerImpl xLayerHandler = new XLayerHandlerImpl();
133 aLayer.readData(xLayerHandler);
135 String implCalled = xLayerHandler.getCalls();
136 log.println(implCalled);
138 int sl = implCalled.indexOf("startLayer");
140 if (sl < 0) {
141 log.println("startLayer wasn't called -- FAILED");
142 res &= false;
143 } else {
144 log.println("startLayer was called -- OK");
145 res &= true;
148 int el = implCalled.indexOf("endLayer");
150 if (el < 0) {
151 log.println("endLayer wasn't called -- FAILED");
152 res &= false;
153 } else {
154 log.println("endLayer was called -- OK");
155 res &= true;
157 } catch (com.sun.star.lang.NullPointerException e) {
158 log.println("Unexpected Exception (" + e + ") -- FAILED");
159 res &= false;
160 } catch (com.sun.star.lang.WrappedTargetException e) {
161 log.println("Unexpected Exception (" + e + ") -- FAILED");
162 res &= false;
163 } catch (com.sun.star.configuration.backend.MalformedDataException e) {
164 log.println("Unexpected Exception (" + e + ") -- FAILED");
165 res &= false;
168 return res;