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 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.lang
.XInitialization
;
26 * Testing <code>com.sun.star.lang.XInitialization</code>
27 * interface methods. <p>
28 * This test needs the following object relations :
30 * <li> <code>'XInitialization.args'</code> (of type <code>Object[]</code>):
31 * (<b>Optional</b>) : argument for <code>initialize</code>
32 * method. If omitted zero length array is used. </li>
34 * Test is multithread compliant. <p>
35 * Till the present time there was no need to recreate environment
36 * after this test completion.
38 public class _XInitialization
extends MultiMethodTest
{
40 public static XInitialization oObj
= null;
43 * Test calls the method with 0 length array and checks that
44 * no exceptions were thrown. <p>
45 * Has <b> OK </b> status if no exceptions were thrown. <p>
47 public void _initialize() {
48 boolean result
= true ;
51 XInitialization xInit
= (XInitialization
) tEnv
.getObjRelation("XInitialization.xIni");
52 if (xInit
== null) xInit
= oObj
;
54 log
.println("calling method with valid arguments...");
55 Object
[] args
= (Object
[]) tEnv
.getObjRelation("XInitialization.args");
57 System
.out
.println("Using new Object[0] as Argument");
58 xInit
.initialize(new Object
[0]);
60 xInit
.initialize(args
);
63 // try to call the method with invalid parameters
64 Object
[] ExArgs
= (Object
[]) tEnv
.getObjRelation("XInitialization.ExceptionArgs");
66 log
.println("calling method with in-valid arguments...");
69 xInit
.initialize(ExArgs
);
70 } catch (com
.sun
.star
.uno
.Exception e
) {
71 log
.println("Expected Exception 'com.sun.star.uno.Exception' occurred -> OK") ;
73 } catch (com
.sun
.star
.uno
.RuntimeException e
) {
74 log
.println("Expected Exception 'com.sun.star.uno.RuntimeException' occurred -> OK") ;
76 } catch (Exception e
) {
77 log
.println("Un-Expected Exception occurred -> FALSE") ;
78 log
.println(e
.toString());
83 } catch (com
.sun
.star
.uno
.Exception e
) {
84 log
.println("Exception occurred while method calling.") ;
89 tRes
.tested("initialize()", result
) ;
90 } // finished _initialize()
93 * Disposes object environment.
97 disposeEnvironment() ;
100 } // finished class _XInitialization