1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XSchemaSupplier.java,v $
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() {
43 XSchema aSchema
= null;
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");
57 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
58 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
61 tRes
.tested("getComponentSchema()",res
);
64 protected boolean checkSchema(XSchema aSchema
) {
66 XSchemaHandlerImpl xSchemaHandlerImpl
= new XSchemaHandlerImpl();
67 log
.println("Checking for Exception in case of null argument");
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");
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");
82 "checking readComponent with own XSchemaHandler implementation");
85 aSchema
.readComponent(xSchemaHandlerImpl
);
87 String implCalled
= xSchemaHandlerImpl
.getCalls();
88 int sc
= implCalled
.indexOf("startComponent");
91 log
.println("startComponent wasn't called -- FAILED");
94 log
.println("startComponent was called -- OK");
98 int ec
= implCalled
.indexOf("endComponent");
101 log
.println("endComponent wasn't called -- FAILED");
104 log
.println("endComponent was called -- OK");
107 } catch (com
.sun
.star
.lang
.NullPointerException e
) {
108 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
110 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
111 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
113 } catch (com
.sun
.star
.configuration
.backend
.MalformedDataException e
) {
114 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");