merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _shlibloader.uno / DLLComponentLoader.java
blobc98bf83dfbd930ab50d5f0903957ec0bc6ceda60
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: DLLComponentLoader.java,v $
10 * $Revision: 1.5 $
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._shlibloader.uno;
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.uno.XInterface;
35 import java.io.PrintWriter;
36 import lib.StatusException;
37 import lib.TestCase;
38 import lib.TestEnvironment;
39 import lib.TestParameters;
40 import util.utils;
42 /**
43 * Test for <code>com.sun.star.comp.stoc.DLLComponentLoader</code> service <p>
44 * Files which are used :
45 * <ul>
46 * <li> <code>XImpReg.dll</code> : DLL which will be loaded in
47 * <code>XImplementationLoader</code> interface test. </li>
48 * <ul>
49 * Multithread testing compilant.
50 * @see com.sun.star.loader.XImplementationLoader
51 * @see com.sun.star.lang.XServiceInfo
52 * @see ifc.loader._XImplementationLoader
53 * @see ifc.lang._XServiceInfo
55 public class DLLComponentLoader extends TestCase {
57 /**
58 * Does nothing.
60 protected void initialize ( TestParameters Param, PrintWriter log) {
64 /**
65 * Creating a Testenvironment for the interfaces to be tested.
66 * Creates <code>com.sun.star.comp.stoc.DLLComponentLoader</code>
67 * service. <p>
68 * The following object relations created :
69 * <ul>
70 * <li> <code>'ImplementationLoader'</code> : service which is
71 * responsible for loading DLL implementations. </li>
72 * <li> <code>'ImplementationUrl'</code> : DLL file location. </li>
73 * <li> <code>'ImplementationName'</code> : Name of the implementation.</li>
74 * </ul>
76 protected TestEnvironment createTestEnvironment
77 (TestParameters Param, PrintWriter log) {
78 XInterface oObj = null;
79 Object oInterface = null;
80 XMultiServiceFactory xMSF = null;
82 try {
83 xMSF = (XMultiServiceFactory)Param.getMSF();
84 oInterface = xMSF.createInstance
85 ( "com.sun.star.comp.stoc.DLLComponentLoader" );
87 catch( Exception e ) {
88 log.println("DLLComponentLoader Service not available" );
91 oObj = (XInterface) oInterface;
93 log.println( " creating a new environment for DLLComponentLoader object" );
94 TestEnvironment tEnv = new TestEnvironment( oObj );
96 // adding object relation for XImplementationLoader ifc test
97 tEnv.addObjRelation("ImplementationLoader",
98 "com.sun.star.loader.SharedLibrary") ;
99 //String fs = System.getProperty("file.separator");
100 String os = (String) Param.get("OS");
101 if (os == null || os == "")
102 throw new StatusException(
103 "Couldn't determine operating system for naming convention.",
104 new NullPointerException());
105 String name = "javaloader.uno";
106 if (!os.equals("wntmsci"))
107 name = name + ".so";
108 else
109 name += ".dll";
110 String implURL = utils.getOfficeURL(xMSF)+"/"+name;
111 tEnv.addObjRelation("ImplementationUrl", implURL) ;
112 log.println("looking for shared lib: " + implURL);
113 tEnv.addObjRelation("ImplementationName",
114 "com.sun.star.comp.stoc.JavaComponentLoader") ;
116 return tEnv;
117 } // finish method getTestEnvironment
119 } // finish class DLLComponentLoader