Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _javaloader / uno / JavaComponentLoader.java
blobb0b03ab00ab764cfa265b0cab02f7493ed499902
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package mod._javaloader.uno;
21 import com.sun.star.lang.XMultiServiceFactory;
22 import com.sun.star.uno.XInterface;
23 import java.io.PrintWriter;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.utils;
29 /**
30 * Test for <code>com.sun.star.comp.stoc.Java2</code> service <p>
31 * Files which are used :
32 * <ul>
33 * <li> <code>MyPersistObjectImpl.jar</code> : jar which will be loaded in
34 * <code>XImplementationLoader</code> interface test. </li>
35 * <ul>
36 * Multithread testing compliant.
37 * @see com.sun.star.loader.XImplementationLoader
38 * @see com.sun.star.lang.XServiceInfo
39 * @see ifc.loader._XImplementationLoader
40 * @see ifc.lang._XServiceInfo
42 public class JavaComponentLoader extends TestCase {
44 /**
45 * Creating a Testenvironment for the interfaces to be tested.
46 * Creates <code>com.sun.star.comp.stoc.Java2</code>
47 * service. <p>
48 * The following object relations created :
49 * <ul>
50 * <li> <code>'ImplementationLoader'</code> : service which is
51 * responsible for loading jar implementations. </li>
52 * <li> <code>'ImplementationUrl'</code> : jar file location. </li>
53 * <li> <code>'ImplementationName'</code> : Name of the implementation.</li>
54 * </ul>
56 @Override
57 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
58 XInterface oObj = null;
59 Object oInterface = null;
61 try {
62 XMultiServiceFactory xMSF = Param.getMSF();
63 oInterface = xMSF.createInstance(
64 "com.sun.star.comp.stoc.JavaComponentLoader" );
66 catch( Exception e ) {
67 log.println("JavaComponentLoader Service not available" );
70 oObj = (XInterface) oInterface;
72 log.println( " creating a new environment for JavaComponentLoader object" );
73 TestEnvironment tEnv = new TestEnvironment( oObj );
75 // adding object relation for XImplementationLoader ifc test
76 tEnv.addObjRelation("ImplementationLoader",
77 "com.sun.star.loader.JavaComponentLoader") ;
79 String implURL = utils.getFullTestURL("qadevlibs/MyPersistObjectImpl.jar");
80 tEnv.addObjRelation("ImplementationUrl", implURL) ;
81 log.println("looking for shared lib: " + implURL);
82 tEnv.addObjRelation("ImplementationName",
83 "com.sun.star.cmp.MyPersistObject") ;
85 return tEnv;
86 } // finish method createTestEnvironment