merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / configuration / backend / _XSingleLayerStratum.java
blob4ff3e8518f71af740c5b68749da8ec5b721c8ede
1 /*
2 * _XSingleLayerStratum.java
4 * Created on 23. March 2004, 16:37
5 */
6 package ifc.configuration.backend;
7 import com.sun.star.configuration.backend.XLayer;
8 import com.sun.star.configuration.backend.XSingleLayerStratum;
9 import com.sun.star.configuration.backend.XUpdatableLayer;
11 import lib.MultiMethodTest;
13 import util.XLayerHandlerImpl;
16 public class _XSingleLayerStratum extends MultiMethodTest {
17 public XSingleLayerStratum oObj;
19 public void _getLayer() {
20 String aLayerID = "org.openoffice.Office.Common";
21 boolean res = true;
23 try {
24 XLayer aLayer = oObj.getLayer("", "");
25 log.println("Exception expected -- FAILED");
26 res = false;
27 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
28 log.println("unexpected Exception " + e + " -- FAILED");
29 res = false;
30 } catch (com.sun.star.lang.IllegalArgumentException e) {
31 log.println("expected Exception -- OK");
34 try {
35 XLayer aLayer = oObj.getLayer(aLayerID, "");
36 res &= (aLayer != null);
38 if (aLayer == null) {
39 log.println("\treturned Layer is NULL -- FAILED");
42 res &= checkLayer(aLayer);
43 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
44 log.println("unexpected Exception -- FAILED");
45 res = false;
46 } catch (com.sun.star.lang.IllegalArgumentException e) {
47 log.println("unexpected Exception -- FAILED");
48 res = false;
51 tRes.tested("getLayer()", res);
54 public void _getUpdatableLayer() {
55 String aLayerID = "org.openoffice.Office.Common";
56 boolean res = true;
58 try {
59 XUpdatableLayer aLayer = oObj.getUpdatableLayer("");
60 log.println("Exception expected -- FAILED");
61 res = false;
62 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
63 log.println("unexpected Exception " + e + " -- FAILED");
64 res = false;
65 } catch (com.sun.star.lang.IllegalArgumentException e) {
66 log.println("expected Exception -- OK");
67 } catch (com.sun.star.lang.NoSupportException e) {
68 log.println("unexpected Exception -- FAILED");
69 res = false;
72 try {
73 XUpdatableLayer aLayer = oObj.getUpdatableLayer(aLayerID);
74 res &= (aLayer != null);
76 if (aLayer == null) {
77 log.println("\treturned Layer is NULL -- FAILED");
80 res &= checkLayer(aLayer);
81 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
82 log.println("unexpected Exception -- FAILED");
83 res = false;
84 } catch (com.sun.star.lang.IllegalArgumentException e) {
85 log.println("unexpected Exception -- FAILED");
86 res = false;
87 } catch (com.sun.star.lang.NoSupportException e) {
88 log.println("unexpected Exception -- FAILED");
89 res = false;
92 tRes.tested("getUpdatableLayer()", res);
95 protected boolean checkLayer(XLayer aLayer) {
96 boolean res = false;
98 log.println("Checking for Exception in case of null argument");
100 try {
101 aLayer.readData(null);
102 } catch (com.sun.star.lang.NullPointerException e) {
103 log.println("Expected Exception -- OK");
104 res = true;
105 } catch (com.sun.star.lang.WrappedTargetException e) {
106 log.println("Unexpected Exception (" + e + ") -- FAILED");
107 } catch (com.sun.star.configuration.backend.MalformedDataException e) {
108 log.println("Unexpected Exception (" + e + ") -- FAILED");
111 log.println("checking read data with own XLayerHandler implementation");
113 try {
114 XLayerHandlerImpl xLayerHandler = new XLayerHandlerImpl();
115 aLayer.readData(xLayerHandler);
117 String implCalled = xLayerHandler.getCalls();
118 log.println(implCalled);
120 int sl = implCalled.indexOf("startLayer");
122 if (sl < 0) {
123 log.println("startLayer wasn't called -- FAILED");
124 res &= false;
125 } else {
126 log.println("startLayer was called -- OK");
127 res &= true;
130 int el = implCalled.indexOf("endLayer");
132 if (el < 0) {
133 log.println("endLayer wasn't called -- FAILED");
134 res &= false;
135 } else {
136 log.println("endLayer was called -- OK");
137 res &= true;
139 } catch (com.sun.star.lang.NullPointerException e) {
140 log.println("Unexpected Exception (" + e + ") -- FAILED");
141 res &= false;
142 } catch (com.sun.star.lang.WrappedTargetException e) {
143 log.println("Unexpected Exception (" + e + ") -- FAILED");
144 res &= false;
145 } catch (com.sun.star.configuration.backend.MalformedDataException e) {
146 log.println("Unexpected Exception (" + e + ") -- FAILED");
147 res &= false;
150 return res;