1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package mod._shlibloader.uno; 29 30 import com.sun.star.lang.XMultiServiceFactory; 31 import com.sun.star.uno.XInterface; 32 import java.io.PrintWriter; 33 import lib.StatusException; 34 import lib.TestCase; 35 import lib.TestEnvironment; 36 import lib.TestParameters; 37 import util.utils; 38 39 /** 40 * Test for <code>com.sun.star.comp.stoc.DLLComponentLoader</code> service <p> 41 * Files which are used : 42 * <ul> 43 * <li> <code>XImpReg.dll</code> : DLL which will be loaded in 44 * <code>XImplementationLoader</code> interface test. </li> 45 * <ul> 46 * Multithread testing compilant. 47 * @see com.sun.star.loader.XImplementationLoader 48 * @see com.sun.star.lang.XServiceInfo 49 * @see ifc.loader._XImplementationLoader 50 * @see ifc.lang._XServiceInfo 51 */ 52 public class DLLComponentLoader extends TestCase { 53 54 /** 55 * Does nothing. 56 */ 57 protected void initialize ( TestParameters Param, PrintWriter log) { 58 59 } 60 61 /** 62 * Creating a Testenvironment for the interfaces to be tested. 63 * Creates <code>com.sun.star.comp.stoc.DLLComponentLoader</code> 64 * service. <p> 65 * The following object relations created : 66 * <ul> 67 * <li> <code>'ImplementationLoader'</code> : service which is 68 * responsible for loading DLL implementations. </li> 69 * <li> <code>'ImplementationUrl'</code> : DLL file location. </li> 70 * <li> <code>'ImplementationName'</code> : Name of the implementation.</li> 71 * </ul> 72 */ 73 protected TestEnvironment createTestEnvironment 74 (TestParameters Param, PrintWriter log) { 75 XInterface oObj = null; 76 Object oInterface = null; 77 XMultiServiceFactory xMSF = null; 78 79 try { 80 xMSF = (XMultiServiceFactory)Param.getMSF(); 81 oInterface = xMSF.createInstance 82 ( "com.sun.star.comp.stoc.DLLComponentLoader" ); 83 } 84 catch( Exception e ) { 85 log.println("DLLComponentLoader Service not available" ); 86 } 87 88 oObj = (XInterface) oInterface; 89 90 log.println( " creating a new environment for DLLComponentLoader object" ); 91 TestEnvironment tEnv = new TestEnvironment( oObj ); 92 93 // adding object relation for XImplementationLoader ifc test 94 tEnv.addObjRelation("ImplementationLoader", 95 "com.sun.star.loader.SharedLibrary") ; 96 //String fs = System.getProperty("file.separator"); 97 String os = (String) Param.get("OS"); 98 if (os == null || os == "") 99 throw new StatusException( 100 "Couldn't determine operating system for naming convention.", 101 new NullPointerException()); 102 String name = "javaloader.uno"; 103 if (!os.equals("wntmsci")) 104 name = name + ".so"; 105 else 106 name += ".dll"; 107 String implURL = utils.getOfficeURL(xMSF)+"/"+name; 108 tEnv.addObjRelation("ImplementationUrl", implURL) ; 109 log.println("looking for shared lib: " + implURL); 110 tEnv.addObjRelation("ImplementationName", 111 "com.sun.star.comp.stoc.JavaComponentLoader") ; 112 113 return tEnv; 114 } // finish method getTestEnvironment 115 116 } // finish class DLLComponentLoader 117 118