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._javaloader; 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.Java2</code> service <p> 43 * Files which are used : 44 * <ul> 45 * <li> <code>MyPersistObjectImpl.jar</code> : jar 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 JavaComponentLoader extends TestCase { 55 56 /** 57 * Creating a Testenvironment for the interfaces to be tested. 58 * Creates <code>com.sun.star.comp.stoc.Java2</code> 59 * service. <p> 60 * The following object relations created : 61 * <ul> 62 * <li> <code>'ImplementationLoader'</code> : service which is 63 * responsible for loading jar implementations. </li> 64 * <li> <code>'ImplementationUrl'</code> : jar file location. </li> 65 * <li> <code>'ImplementationName'</code> : Name of the implementation.</li> 66 * </ul> 67 */ 68 public TestEnvironment createTestEnvironment( TestParameters Param, 69 PrintWriter log ) 70 throws StatusException { 71 XInterface oObj = null; 72 Object oInterface = null; 73 74 try { 75 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF(); 76 oInterface = xMSF.createInstance( 77 "com.sun.star.comp.stoc.JavaComponentLoader" ); 78 } 79 catch( Exception e ) { 80 log.println("JavaComponentLoader Service not available" ); 81 } 82 83 oObj = (XInterface) oInterface; 84 85 log.println( " creating a new environment for JavaComponentLoader object" ); 86 TestEnvironment tEnv = new TestEnvironment( oObj ); 87 88 // adding object relation for XImplementationLoader ifc test 89 tEnv.addObjRelation("ImplementationLoader", 90 "com.sun.star.loader.JavaComponentLoader") ; 91 92 String implURL = utils.getFullTestURL("qadevlibs/MyPersistObjectImpl.jar"); 93 tEnv.addObjRelation("ImplementationUrl", implURL) ; 94 log.println("looking for shared lib: " + implURL); 95 tEnv.addObjRelation("ImplementationName", 96 "com.sun.star.cmp.MyPersistObject") ; 97 98 return tEnv; 99 } // finish method createTestEnvironment 100 } 101 102