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 .
19 package ifc
.reflection
;
21 import com
.sun
.star
.lang
.XMultiServiceFactory
;
22 import com
.sun
.star
.reflection
.XIdlClass
;
23 import com
.sun
.star
.reflection
.XIdlReflection
;
24 import com
.sun
.star
.uno
.TypeClass
;
25 import lib
.MultiMethodTest
;
28 * Testing <code>com.sun.star.reflection.XIdlReflection</code>
31 * <li><code> forName()</code></li>
32 * <li><code> getType()</code></li>
34 * @see com.sun.star.reflection.XIdlReflection
36 public class _XIdlReflection
extends MultiMethodTest
{
37 public XIdlReflection oObj
= null;
38 protected final static String typeName
= "com.sun.star.container.XNameAccess";
41 * Test calls the method and checks returned interface
42 * <code>com.sun.star.container.XNameAccess</code>: gets the name and the
43 * type and checks it. <p>
44 * Has <b> OK </b> status if returned name is equal to the name of the
45 * interface that was passed as parameter in the method call and if returned
46 * type is equal to <code>com.sun.star.uno.TypeClass.INTERFACE</code>. <p>
48 public void _forName() {
49 boolean result
= true;
50 XIdlClass cls
= oObj
.forName(typeName
);
53 log
.println("Class name: " + cls
.getName());
54 result
&= cls
.getTypeClass() == TypeClass
.INTERFACE
;
55 result
&= typeName
.equals(cls
.getName());
57 log
.println("Method returned null");
61 tRes
.tested("forName()", result
);
65 * Test creates the instance of <code>com.sun.star.io.Pipe</code>,
66 * calls the method using this instance as parameter and checks returned
68 * Has <b> OK </b> status if the instance was created successfully, if
69 * returned value isn't null and no exceptions were thrown. <p>
71 public void _getType() {
75 obj
= ((XMultiServiceFactory
)tParam
.getMSF()).
76 createInstance("com.sun.star.io.Pipe") ;
77 } catch (com
.sun
.star
.uno
.Exception e
) {
78 log
.println("Can't create object");
79 tRes
.tested("getType()", false);
84 log
.println("Object wasn't created !");
85 tRes
.tested("getType()", false);
88 XIdlClass cls
= oObj
.getType(obj
);
90 log
.println("The name is " + cls
.getName());
92 tRes
.tested("getType()", cls
!= null);