cid#1607171 Data race condition
[LibreOffice.git] / qadevOOo / tests / java / ifc / configuration / backend / _XSingleLayerStratum.java
blob33eb0cfa8962ede57c956e59f8ffdea58b9375fc
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 .
18 package ifc.configuration.backend;
20 import com.sun.star.configuration.backend.XLayer;
21 import com.sun.star.configuration.backend.XSingleLayerStratum;
22 import com.sun.star.configuration.backend.XUpdatableLayer;
24 import lib.MultiMethodTest;
26 import util.XLayerHandlerImpl;
29 public class _XSingleLayerStratum extends MultiMethodTest {
30 public XSingleLayerStratum oObj;
32 public void _getLayer() {
33 String aLayerID = "org.openoffice.Office.Common";
34 boolean res = true;
36 try {
37 oObj.getLayer("", "");
38 log.println("Exception expected -- FAILED");
39 res = false;
40 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
41 log.println("unexpected Exception " + e + " -- FAILED");
42 res = false;
43 } catch (com.sun.star.lang.IllegalArgumentException e) {
44 log.println("expected Exception -- OK");
47 try {
48 XLayer aLayer = oObj.getLayer(aLayerID, "");
49 res &= (aLayer != null);
51 if (aLayer == null) {
52 log.println("\treturned Layer is NULL -- FAILED");
53 } else {
54 res &= checkLayer(aLayer);
56 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
57 log.println("unexpected Exception -- FAILED");
58 res = false;
59 } catch (com.sun.star.lang.IllegalArgumentException e) {
60 log.println("unexpected Exception -- FAILED");
61 res = false;
64 tRes.tested("getLayer()", res);
67 public void _getUpdatableLayer() {
68 String aLayerID = "org.openoffice.Office.Common";
69 boolean res = true;
71 try {
72 oObj.getUpdatableLayer("");
73 log.println("Exception expected -- FAILED");
74 res = false;
75 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
76 log.println("unexpected Exception " + e + " -- FAILED");
77 res = false;
78 } catch (com.sun.star.lang.IllegalArgumentException e) {
79 log.println("expected Exception -- OK");
80 } catch (com.sun.star.lang.NoSupportException e) {
81 log.println("unexpected Exception -- FAILED");
82 res = false;
85 try {
86 XUpdatableLayer aLayer = oObj.getUpdatableLayer(aLayerID);
87 res &= (aLayer != null);
89 if (aLayer == null) {
90 log.println("\treturned Layer is NULL -- FAILED");
91 } else {
92 res &= checkLayer(aLayer);
94 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
95 log.println("unexpected Exception -- FAILED");
96 res = false;
97 } catch (com.sun.star.lang.IllegalArgumentException e) {
98 log.println("unexpected Exception -- FAILED");
99 res = false;
100 } catch (com.sun.star.lang.NoSupportException e) {
101 log.println("unexpected Exception -- FAILED");
102 res = false;
105 tRes.tested("getUpdatableLayer()", res);
108 protected boolean checkLayer(XLayer aLayer) {
109 boolean res = false;
111 log.println("Checking for Exception in case of null argument");
113 try {
114 aLayer.readData(null);
115 } catch (com.sun.star.lang.NullPointerException e) {
116 log.println("Expected Exception -- OK");
117 res = true;
118 } catch (com.sun.star.lang.WrappedTargetException e) {
119 log.println("Unexpected Exception (" + e + ") -- FAILED");
120 } catch (com.sun.star.configuration.backend.MalformedDataException e) {
121 log.println("Unexpected Exception (" + e + ") -- FAILED");
124 log.println("checking read data with own XLayerHandler implementation");
126 try {
127 XLayerHandlerImpl xLayerHandler = new XLayerHandlerImpl();
128 aLayer.readData(xLayerHandler);
130 String implCalled = xLayerHandler.getCalls();
131 log.println(implCalled);
133 int sl = implCalled.indexOf("startLayer");
135 if (sl < 0) {
136 log.println("startLayer wasn't called -- FAILED");
137 res &= false;
138 } else {
139 log.println("startLayer was called -- OK");
140 res &= true;
143 int el = implCalled.indexOf("endLayer");
145 if (el < 0) {
146 log.println("endLayer wasn't called -- FAILED");
147 res &= false;
148 } else {
149 log.println("endLayer was called -- OK");
150 res &= true;
152 } catch (com.sun.star.lang.NullPointerException e) {
153 log.println("Unexpected Exception (" + e + ") -- FAILED");
154 res &= false;
155 } catch (com.sun.star.lang.WrappedTargetException e) {
156 log.println("Unexpected Exception (" + e + ") -- FAILED");
157 res &= false;
158 } catch (com.sun.star.configuration.backend.MalformedDataException e) {
159 log.println("Unexpected Exception (" + e + ") -- FAILED");
160 res &= false;
163 return res;