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._javaloader; 25 26 import java.io.PrintWriter; 27 28 import lib.StatusException; 29 import lib.TestCase; 30 import lib.TestEnvironment; 31 import lib.TestParameters; 32 import util.utils; 33 34 import com.sun.star.lang.XMultiServiceFactory; 35 import com.sun.star.uno.XInterface; 36 37 /** 38 * Test for <code>com.sun.star.comp.stoc.Java2</code> service <p> 39 * Files which are used : 40 * <ul> 41 * <li> <code>MyPersistObjectImpl.jar</code> : jar which will be loaded in 42 * <code>XImplementationLoader</code> interface test. </li> 43 * <ul> 44 * Multithread testing compilant. 45 * @see com.sun.star.loader.XImplementationLoader 46 * @see com.sun.star.lang.XServiceInfo 47 * @see ifc.loader._XImplementationLoader 48 * @see ifc.lang._XServiceInfo 49 */ 50 public class JavaComponentLoader extends TestCase { 51 52 /** 53 * Creating a Testenvironment for the interfaces to be tested. 54 * Creates <code>com.sun.star.comp.stoc.Java2</code> 55 * service. <p> 56 * The following object relations created : 57 * <ul> 58 * <li> <code>'ImplementationLoader'</code> : service which is 59 * responsible for loading jar implementations. </li> 60 * <li> <code>'ImplementationUrl'</code> : jar file location. </li> 61 * <li> <code>'ImplementationName'</code> : Name of the implementation.</li> 62 * </ul> 63 */ createTestEnvironment( TestParameters Param, PrintWriter log )64 public TestEnvironment createTestEnvironment( TestParameters Param, 65 PrintWriter log ) 66 throws StatusException { 67 XInterface oObj = null; 68 Object oInterface = null; 69 70 try { 71 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF(); 72 oInterface = xMSF.createInstance( 73 "com.sun.star.comp.stoc.JavaComponentLoader" ); 74 } 75 catch( Exception e ) { 76 log.println("JavaComponentLoader Service not available" ); 77 } 78 79 oObj = (XInterface) oInterface; 80 81 log.println( " creating a new environment for JavaComponentLoader object" ); 82 TestEnvironment tEnv = new TestEnvironment( oObj ); 83 84 // adding object relation for XImplementationLoader ifc test 85 tEnv.addObjRelation("ImplementationLoader", 86 "com.sun.star.loader.JavaComponentLoader") ; 87 88 String implURL = utils.getFullTestURL("qadevlibs/MyPersistObjectImpl.jar"); 89 tEnv.addObjRelation("ImplementationUrl", implURL) ; 90 log.println("looking for shared lib: " + implURL); 91 tEnv.addObjRelation("ImplementationName", 92 "com.sun.star.cmp.MyPersistObject") ; 93 94 return tEnv; 95 } // finish method createTestEnvironment 96 } 97 98