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
.XSchema
;
21 import com
.sun
.star
.configuration
.backend
.XSchemaSupplier
;
23 import lib
.MultiMethodTest
;
24 import util
.XSchemaHandlerImpl
;
26 public class _XSchemaSupplier
extends MultiMethodTest
{
27 public XSchemaSupplier oObj
;
29 public void _getComponentSchema() {
31 XSchema aSchema
= null;
34 aSchema
= oObj
.getComponentSchema("org.openoffice.Office.Linguistic");
35 res
&= (aSchema
!= null);
37 if (aSchema
== null) {
38 log
.println("\treturned Layer is NULL -- FAILED");
40 res
&= checkSchema(aSchema
);
42 } catch (com
.sun
.star
.configuration
.backend
.BackendAccessException e
) {
43 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
45 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
46 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
49 tRes
.tested("getComponentSchema()",res
);
52 protected boolean checkSchema(XSchema aSchema
) {
54 XSchemaHandlerImpl xSchemaHandlerImpl
= new XSchemaHandlerImpl();
55 log
.println("Checking for Exception in case of null argument");
58 aSchema
.readTemplates(null);
59 log
.println("NoException thrown for null argument -- FAILED");
60 } catch (com
.sun
.star
.lang
.NullPointerException e
) {
61 log
.println("Expected Exception -- OK");
63 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
64 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
65 } catch (com
.sun
.star
.configuration
.backend
.MalformedDataException e
) {
66 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
70 "checking readComponent with own XSchemaHandler implementation");
73 aSchema
.readComponent(xSchemaHandlerImpl
);
75 String implCalled
= xSchemaHandlerImpl
.getCalls();
76 int sc
= implCalled
.indexOf("startComponent");
79 log
.println("startComponent wasn't called -- FAILED");
82 log
.println("startComponent was called -- OK");
86 int ec
= implCalled
.indexOf("endComponent");
89 log
.println("endComponent wasn't called -- FAILED");
92 log
.println("endComponent was called -- OK");
95 } catch (com
.sun
.star
.lang
.NullPointerException e
) {
96 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
98 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
99 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");
101 } catch (com
.sun
.star
.configuration
.backend
.MalformedDataException e
) {
102 log
.println("Unexpected Exception (" + e
+ ") -- FAILED");