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";
37 oObj
.getLayer("", "");
38 log
.println("Exception expected -- FAILED");
40 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
41 log
.println("unexpected Exception " + e
+ " -- FAILED");
43 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
44 log
.println("expected Exception -- OK");
48 XLayer aLayer
= oObj
.getLayer(aLayerID
, "");
49 res
&= (aLayer
!= null);
52 log
.println("\treturned Layer is NULL -- FAILED");
54 res
&= checkLayer(aLayer
);
56 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
57 log
.println("unexpected Exception -- FAILED");
59 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
60 log
.println("unexpected Exception -- FAILED");
64 tRes
.tested("getLayer()", res
);
67 public void _getUpdatableLayer() {
68 String aLayerID
= "org.openoffice.Office.Common";
72 oObj
.getUpdatableLayer("");
73 log
.println("Exception expected -- FAILED");
75 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
76 log
.println("unexpected Exception " + e
+ " -- FAILED");
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");
86 XUpdatableLayer aLayer
= oObj
.getUpdatableLayer(aLayerID
);
87 res
&= (aLayer
!= null);
90 log
.println("\treturned Layer is NULL -- FAILED");
92 res
&= checkLayer(aLayer
);
94 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
95 log
.println("unexpected Exception -- FAILED");
97 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
98 log
.println("unexpected Exception -- FAILED");
100 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
101 log
.println("unexpected Exception -- FAILED");
105 tRes
.tested("getUpdatableLayer()", res
);
108 protected boolean checkLayer(XLayer aLayer
) {
111 log
.println("Checking for Exception in case of null argument");
114 aLayer
.readData(null);
115 } catch (com
.sun
.star
.lang
.NullPointerException e
) {
116 log
.println("Expected Exception -- OK");
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");
127 XLayerHandlerImpl xLayerHandler
= new XLayerHandlerImpl();
128 aLayer
.readData(xLayerHandler
);
130 String implCalled
= xLayerHandler
.getCalls();
131 log
.println(implCalled
);
133 int sl
= implCalled
.indexOf("startLayer");
136 log
.println("startLayer wasn't called -- FAILED");
139 log
.println("startLayer was called -- OK");
143 int el
= implCalled
.indexOf("endLayer");
146 log
.println("endLayer wasn't called -- FAILED");
149 log
.println("endLayer was called -- OK");
152 } catch (com
.sun
.star
.lang
.NullPointerException e
) {
153 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
155 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
156 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
158 } catch (com
.sun
.star
.configuration
.backend
.MalformedDataException e
) {
159 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");