merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _javaloader.uno / JavaComponentLoader.java
blobf4e45c671bab4f48c8df0db0c5ed3d719644eca2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: JavaComponentLoader.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package mod._javaloader.uno;
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.uno.XInterface;
35 import java.io.PrintWriter;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.utils;
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
54 public class JavaComponentLoader extends TestCase {
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>
68 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
69 XInterface oObj = null;
70 Object oInterface = null;
72 try {
73 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
74 oInterface = xMSF.createInstance(
75 "com.sun.star.comp.stoc.JavaComponentLoader" );
77 catch( Exception e ) {
78 log.println("JavaComponentLoader Service not available" );
81 oObj = (XInterface) oInterface;
83 log.println( " creating a new environment for JavaComponentLoader object" );
84 TestEnvironment tEnv = new TestEnvironment( oObj );
86 // adding object relation for XImplementationLoader ifc test
87 tEnv.addObjRelation("ImplementationLoader",
88 "com.sun.star.loader.JavaComponentLoader") ;
90 String jarname = "MyPersistentObjectImpl.jar";
91 String implURL = utils.getFullTestURL("qadevlibs/MyPersistObjectImpl.jar");
92 tEnv.addObjRelation("ImplementationUrl", implURL) ;
93 log.println("looking for shared lib: " + implURL);
94 tEnv.addObjRelation("ImplementationName",
95 "com.sun.star.cmp.MyPersistObject") ;
97 return tEnv;
98 } // finish method createTestEnvironment