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