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._shlibloader.uno; 25 26 import com.sun.star.lang.XMultiServiceFactory; 27 import com.sun.star.uno.XInterface; 28 import java.io.PrintWriter; 29 import lib.StatusException; 30 import lib.TestCase; 31 import lib.TestEnvironment; 32 import lib.TestParameters; 33 import util.utils; 34 35 /** 36 * Test for <code>com.sun.star.comp.stoc.DLLComponentLoader</code> service <p> 37 * Files which are used : 38 * <ul> 39 * <li> <code>XImpReg.dll</code> : DLL which will be loaded in 40 * <code>XImplementationLoader</code> interface test. </li> 41 * <ul> 42 * Multithread testing compilant. 43 * @see com.sun.star.loader.XImplementationLoader 44 * @see com.sun.star.lang.XServiceInfo 45 * @see ifc.loader._XImplementationLoader 46 * @see ifc.lang._XServiceInfo 47 */ 48 public class DLLComponentLoader extends TestCase { 49 50 /** 51 * Does nothing. 52 */ initialize( TestParameters Param, PrintWriter log)53 protected void initialize ( TestParameters Param, PrintWriter log) { 54 55 } 56 57 /** 58 * Creating a Testenvironment for the interfaces to be tested. 59 * Creates <code>com.sun.star.comp.stoc.DLLComponentLoader</code> 60 * service. <p> 61 * The following object relations created : 62 * <ul> 63 * <li> <code>'ImplementationLoader'</code> : service which is 64 * responsible for loading DLL implementations. </li> 65 * <li> <code>'ImplementationUrl'</code> : DLL file location. </li> 66 * <li> <code>'ImplementationName'</code> : Name of the implementation.</li> 67 * </ul> 68 */ createTestEnvironment(TestParameters Param, PrintWriter log)69 protected TestEnvironment createTestEnvironment 70 (TestParameters Param, PrintWriter log) { 71 XInterface oObj = null; 72 Object oInterface = null; 73 XMultiServiceFactory xMSF = null; 74 75 try { 76 xMSF = (XMultiServiceFactory)Param.getMSF(); 77 oInterface = xMSF.createInstance 78 ( "com.sun.star.comp.stoc.DLLComponentLoader" ); 79 } 80 catch( Exception e ) { 81 log.println("DLLComponentLoader Service not available" ); 82 } 83 84 oObj = (XInterface) oInterface; 85 86 log.println( " creating a new environment for DLLComponentLoader object" ); 87 TestEnvironment tEnv = new TestEnvironment( oObj ); 88 89 // adding object relation for XImplementationLoader ifc test 90 tEnv.addObjRelation("ImplementationLoader", 91 "com.sun.star.loader.SharedLibrary") ; 92 //String fs = System.getProperty("file.separator"); 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.uno"; 99 if (!os.equals("wntmsci")) 100 name = name + ".so"; 101 else 102 name += ".dll"; 103 String implURL = utils.getOfficeURL(xMSF)+"/"+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