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
.XMultiLayerStratum
;
22 import com
.sun
.star
.configuration
.backend
.XUpdatableLayer
;
23 import lib
.MultiMethodTest
;
25 import util
.XLayerHandlerImpl
;
28 public class _XMultiLayerStratum
extends MultiMethodTest
{
29 public XMultiLayerStratum oObj
;
30 protected String aLayerID
;
32 public void _getLayer() {
36 oObj
.getLayer("", "");
37 log
.println("Exception expected -- FAILED");
39 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
40 log
.println("unexpected Exception " + e
+ " -- FAILED");
42 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
43 log
.println("expected Exception -- OK");
47 XLayer aLayer
= oObj
.getLayer(aLayerID
, "");
48 res
&= (aLayer
!= null);
51 log
.println("\treturned Layer is NULL -- FAILED");
53 res
&= checkLayer(aLayer
);
55 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
56 log
.println("unexpected Exception -- FAILED");
58 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
59 log
.println("unexpected Exception -- FAILED");
63 tRes
.tested("getLayer()", res
);
66 public void _getLayers() {
70 String
[] LayerIds
= new String
[] {
71 "1 /org/openoffice/Office/Jobs.xcu",
72 "2 /org/openoffice/Office/Linguistic.xcu" };
74 XLayer
[] Layers
= oObj
.getLayers(LayerIds
, "");
75 res
= Layers
.length
== 2;
76 log
.println("Getting two XLayers -- OK");
77 log
.println("Checking first on "+LayerIds
[0]);
78 res
&= checkLayer(Layers
[0]);
79 log
.println("Checking second on "+LayerIds
[1]);
80 res
&= checkLayer(Layers
[1]);
81 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
82 log
.println("unexpected Exception -- FAILED");
84 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
85 log
.println("unexpected Exception -- FAILED");
89 tRes
.tested("getLayers()", res
);
92 public void _getMultipleLayers() {
96 String
[] LayerIds
= new String
[] {
97 "1 /org/openoffice/Office/Jobs.xcu",
98 "2 /org/openoffice/Office/Linguistic.xcu" };
99 String
[] Times
= new String
[] { "", "" };
101 XLayer
[] Layers
= oObj
.getMultipleLayers(LayerIds
, Times
);
102 res
= Layers
.length
== 2;
103 log
.println("Getting two XLayers -- OK");
104 log
.println("Checking first on "+LayerIds
[0]);
105 res
&= checkLayer(Layers
[0]);
106 log
.println("Checking second on "+LayerIds
[1]);
107 res
&= checkLayer(Layers
[1]);
108 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
109 log
.println("unexpected Exception -- FAILED");
111 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
112 log
.println("unexpected Exception -- FAILED");
116 tRes
.tested("getMultipleLayers()", res
);
119 public void _getUpdatableLayer() {
123 oObj
.getUpdatableLayer("");
124 log
.println("Exception expected -- FAILED");
126 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
127 log
.println("unexpected Exception " + e
+ " -- FAILED");
129 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
130 log
.println("expected Exception -- OK");
131 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
132 log
.println("unexpected Exception -- FAILED");
137 XUpdatableLayer aLayer
= oObj
.getUpdatableLayer(aLayerID
);
138 res
&= (aLayer
!= null);
140 if (aLayer
== null) {
141 log
.println("\treturned Layer is NULL -- FAILED");
143 res
&= checkLayer(aLayer
);
145 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
146 log
.println("unexpected Exception -- FAILED");
148 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
149 log
.println("unexpected Exception -- FAILED");
151 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
152 log
.println("unexpected Exception -- FAILED");
156 tRes
.tested("getUpdatableLayer()", res
);
159 public void _getUpdateLayerId() throws com
.sun
.star
.uno
.Exception
{
163 oObj
.getUpdateLayerId(
164 "org.openoffice.Office.TypeDetection",
166 log
.println("Exception expected -- FAILED");
168 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
169 log
.println("expected Exception -- OK");
170 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
171 log
.println("unexpected Exception -- FAILED");
173 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
174 log
.println("unexpected Exception -- FAILED");
179 String ent
= util
.utils
.getOfficeURL(
181 "/../share/registry";
182 String UpdateLayerID
= oObj
.getUpdateLayerId(
183 "org.openoffice.Office.Linguistic", ent
);
184 res
&= UpdateLayerID
.endsWith("Linguistic.xcu");
186 if (!UpdateLayerID
.endsWith("Linguistic.xcu")) {
187 log
.println("\tExpected the id to end with Linguistic.xcu");
188 log
.println("\tBut got " + UpdateLayerID
);
189 log
.println("\t=> FAILED");
191 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
192 log
.println("unexpected Exception -- FAILED");
194 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
195 log
.println("unexpected Exception "+e
+" -- FAILED");
197 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
198 log
.println("unexpected Exception -- FAILED");
202 tRes
.tested("getUpdateLayerId()", res
);
205 public void _listLayerIds() throws com
.sun
.star
.uno
.Exception
{
210 "org.openoffice.Office.TypeDetection",
212 log
.println("Exception expected -- FAILED");
214 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
215 log
.println("expected Exception -- OK");
216 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
217 log
.println("unexpected Exception -- FAILED");
222 String ent
= util
.utils
.getOfficeURL(
224 "/../share/registry";
225 String
[] LayerIDs
= oObj
.listLayerIds("org.openoffice.Office.Jobs",
227 res
&= LayerIDs
[0].endsWith("Jobs.xcu");
228 aLayerID
= LayerIDs
[0];
230 if (!LayerIDs
[0].endsWith("Jobs.xcu")) {
231 log
.println("\tExpected the id to end with Jobs.xcu");
232 log
.println("\tBut got " + LayerIDs
[0]);
233 log
.println("\t=> FAILED");
235 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
236 log
.println("unexpected Exception -- FAILED");
238 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
239 log
.println("unexpected Exception -- FAILED");
243 tRes
.tested("listLayerIds()", res
);
246 protected boolean checkLayer(XLayer aLayer
) {
249 log
.println("Checking for Exception in case of null argument");
252 aLayer
.readData(null);
253 } catch (com
.sun
.star
.lang
.NullPointerException e
) {
254 log
.println("Expected Exception -- OK");
256 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
257 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
258 } catch (com
.sun
.star
.configuration
.backend
.MalformedDataException e
) {
259 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
262 log
.println("checking read data with own XLayerHandler implementation");
265 XLayerHandlerImpl xLayerHandler
= new XLayerHandlerImpl();
266 aLayer
.readData(xLayerHandler
);
268 String implCalled
= xLayerHandler
.getCalls();
269 log
.println(implCalled
);
271 int sl
= implCalled
.indexOf("startLayer");
274 log
.println("startLayer wasn't called -- FAILED");
277 log
.println("startLayer was called -- OK");
281 int el
= implCalled
.indexOf("endLayer");
284 log
.println("endLayer wasn't called -- FAILED");
287 log
.println("endLayer was called -- OK");
290 } catch (com
.sun
.star
.lang
.NullPointerException e
) {
291 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
293 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
294 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
296 } catch (com
.sun
.star
.configuration
.backend
.MalformedDataException e
) {
297 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");