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