1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package mod._tdmgr;
25 
26 import java.io.PrintWriter;
27 
28 import lib.StatusException;
29 import lib.TestCase;
30 import lib.TestEnvironment;
31 import lib.TestParameters;
32 
33 import com.sun.star.beans.XPropertySet;
34 import com.sun.star.lang.XMultiServiceFactory;
35 import com.sun.star.uno.UnoRuntime;
36 import com.sun.star.uno.XComponentContext;
37 import com.sun.star.uno.XInterface;
38 
39 public class TypeDescriptionManager extends TestCase {
40 
initialize( TestParameters Param, PrintWriter log)41     protected void initialize ( TestParameters Param, PrintWriter log) {
42 
43     }
44 
45     /**
46      *    creating a Testenvironment for the interfaces to be tested
47      */
createTestEnvironment( TestParameters Param, PrintWriter log )48     public TestEnvironment createTestEnvironment( TestParameters Param,
49                                                   PrintWriter log )
50                                                     throws StatusException {
51         XInterface oObj = null;
52         Object oInterface = null;
53 
54         try {
55             XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
56             XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(
57                                                 XPropertySet.class, xMSF);
58             // get context
59             XComponentContext xContext = (XComponentContext)
60                             UnoRuntime.queryInterface(XComponentContext.class,
61                             xProp.getPropertyValue("DefaultContext"));
62             // get the type description manager from context
63             oInterface = xContext.getValueByName("/singletons/" +
64                         "com.sun.star.reflection.theTypeDescriptionManager");
65         }
66         catch( Exception e ) {
67             log.println("Introspection Service not available" );
68         }
69         oObj = (XInterface) oInterface;
70 
71 
72 
73         log.println( "    creating a new environment for Introspection object" );
74         TestEnvironment tEnv = new TestEnvironment( oObj );
75 
76         // Object relation for XHierarchicalNameAccess ifc
77         // Name of the existing object
78         tEnv.addObjRelation("ElementName", "com.sun.star.container.XNameAccess") ;
79         tEnv.addObjRelation("SearchString", "com.sun.star.loader");
80 
81         return tEnv;
82     } // finish method getTestEnvironment
83 
84 }    // finish class TypeDescriptionManager
85 
86