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._cpld; 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.DLLComponentLoader</code> service <p> 39 * Files which are used : 40 * <ul> 41 * <li> <code>XImpReg.dll</code> : DLL 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 DLLComponentLoader extends TestCase { 51 52 /** 53 * Does nothing. 54 */ initialize( TestParameters Param, PrintWriter log)55 protected void initialize ( TestParameters Param, PrintWriter log) { 56 57 } 58 59 /** 60 * Creating a Testenvironment for the interfaces to be tested. 61 * Creates <code>com.sun.star.comp.stoc.DLLComponentLoader</code> 62 * service. <p> 63 * The following object relations created : 64 * <ul> 65 * <li> <code>'ImplementationLoader'</code> : service which is 66 * responsible for loading DLL implementations. </li> 67 * <li> <code>'ImplementationUrl'</code> : DLL file location. </li> 68 * <li> <code>'ImplementationName'</code> : Name of the implementation.</li> 69 * </ul> 70 */ createTestEnvironment(TestParameters Param, PrintWriter log)71 protected TestEnvironment createTestEnvironment 72 (TestParameters Param, PrintWriter log) { 73 XInterface oObj = null; 74 Object oInterface = null; 75 76 try { 77 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF(); 78 oInterface = xMSF.createInstance 79 ( "com.sun.star.comp.stoc.DLLComponentLoader" ); 80 } 81 catch( Exception e ) { 82 log.println("DLLComponentLoader Service not available" ); 83 } 84 85 oObj = (XInterface) oInterface; 86 87 log.println( " creating a new environment for DLLComponentLoader object" ); 88 TestEnvironment tEnv = new TestEnvironment( oObj ); 89 90 // adding object relation for XImplementationLoader ifc test 91 tEnv.addObjRelation("ImplementationLoader", 92 "com.sun.star.loader.SharedLibrary") ; 93 String os = (String) Param.get("OS"); 94 if (os == null || os == "") 95 throw new StatusException( 96 "Couldn't determine operating system for naming convention.", 97 new NullPointerException()); 98 String name = "javaloader"; 99 if (!os.equals("wntmsci")) 100 name = "lib" + name + ".so"; 101 else 102 name += ".dll"; 103 String implURL = utils.getFullTestURL(os + "/" + name); 104 tEnv.addObjRelation("ImplementationUrl", implURL) ; 105 log.println("looking for shared lib: " + implURL); 106 tEnv.addObjRelation("ImplementationName", 107 "com.sun.star.comp.stoc.JavaComponentLoader") ; 108 109 return tEnv; 110 } // finish method getTestEnvironment 111 112 } // finish class DLLComponentLoader 113 114