merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / configuration / backend / _XSchemaSupplier.java
blob6b03868fbfa906e115dac555aefc429e90d18158
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XSchemaSupplier.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package ifc.configuration.backend;
32 import com.sun.star.configuration.backend.XSchema;
33 import com.sun.star.configuration.backend.XSchemaSupplier;
35 import lib.MultiMethodTest;
36 import util.XSchemaHandlerImpl;
38 public class _XSchemaSupplier extends MultiMethodTest {
39 public XSchemaSupplier oObj;
41 public void _getComponentSchema() {
42 boolean res = true;
43 XSchema aSchema = null;
45 try {
46 aSchema = oObj.getComponentSchema("org.openoffice.Office.Linguistic");
47 res &= (aSchema != null);
49 if (aSchema == null) {
50 log.println("\treturned Layer is NULL -- FAILED");
53 res &= checkSchema(aSchema);
54 } catch (com.sun.star.configuration.backend.BackendAccessException e) {
55 log.println("Unexpected Exception (" + e + ") -- FAILED");
56 res &= false;
57 } catch (com.sun.star.lang.IllegalArgumentException e) {
58 log.println("Unexpected Exception (" + e + ") -- FAILED");
59 res &= false;
61 tRes.tested("getComponentSchema()",res);
64 protected boolean checkSchema(XSchema aSchema) {
65 boolean res = false;
66 XSchemaHandlerImpl xSchemaHandlerImpl = new XSchemaHandlerImpl();
67 log.println("Checking for Exception in case of null argument");
69 try {
70 aSchema.readTemplates(null);
71 log.println("NoException thrown for null argument -- FAILED");
72 } catch (com.sun.star.lang.NullPointerException e) {
73 log.println("Expected Exception -- OK");
74 res = true;
75 } catch (com.sun.star.lang.WrappedTargetException e) {
76 log.println("Unexpected Exception (" + e + ") -- FAILED");
77 } catch (com.sun.star.configuration.backend.MalformedDataException e) {
78 log.println("Unexpected Exception (" + e + ") -- FAILED");
81 log.println(
82 "checking readComponent with own XSchemaHandler implementation");
84 try {
85 aSchema.readComponent(xSchemaHandlerImpl);
87 String implCalled = xSchemaHandlerImpl.getCalls();
88 int sc = implCalled.indexOf("startComponent");
90 if (sc < 0) {
91 log.println("startComponent wasn't called -- FAILED");
92 res &= false;
93 } else {
94 log.println("startComponent was called -- OK");
95 res &= true;
98 int ec = implCalled.indexOf("endComponent");
100 if (ec < 0) {
101 log.println("endComponent wasn't called -- FAILED");
102 res &= false;
103 } else {
104 log.println("endComponent was called -- OK");
105 res &= true;
107 } catch (com.sun.star.lang.NullPointerException e) {
108 log.println("Unexpected Exception (" + e + ") -- FAILED");
109 res &= false;
110 } catch (com.sun.star.lang.WrappedTargetException e) {
111 log.println("Unexpected Exception (" + e + ") -- FAILED");
112 res &= false;
113 } catch (com.sun.star.configuration.backend.MalformedDataException e) {
114 log.println("Unexpected Exception (" + e + ") -- FAILED");
115 res &= false;
118 return res;