merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _cpld / DLLComponentLoader.java
blobb864a6b6eea981290992ee1c3d24d45e4543998b
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._cpld;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.utils;
41 import com.sun.star.lang.XMultiServiceFactory;
42 import com.sun.star.uno.XInterface;
44 /**
45 * Test for <code>com.sun.star.comp.stoc.DLLComponentLoader</code> service <p>
46 * Files which are used :
47 * <ul>
48 * <li> <code>XImpReg.dll</code> : DLL which will be loaded in
49 * <code>XImplementationLoader</code> interface test. </li>
50 * <ul>
51 * Multithread testing compilant.
52 * @see com.sun.star.loader.XImplementationLoader
53 * @see com.sun.star.lang.XServiceInfo
54 * @see ifc.loader._XImplementationLoader
55 * @see ifc.lang._XServiceInfo
57 public class DLLComponentLoader extends TestCase {
59 /**
60 * Does nothing.
62 protected void initialize ( TestParameters Param, PrintWriter log) {
66 /**
67 * Creating a Testenvironment for the interfaces to be tested.
68 * Creates <code>com.sun.star.comp.stoc.DLLComponentLoader</code>
69 * service. <p>
70 * The following object relations created :
71 * <ul>
72 * <li> <code>'ImplementationLoader'</code> : service which is
73 * responsible for loading DLL implementations. </li>
74 * <li> <code>'ImplementationUrl'</code> : DLL file location. </li>
75 * <li> <code>'ImplementationName'</code> : Name of the implementation.</li>
76 * </ul>
78 protected TestEnvironment createTestEnvironment
79 (TestParameters Param, PrintWriter log) {
80 XInterface oObj = null;
81 Object oInterface = null;
83 try {
84 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
85 oInterface = xMSF.createInstance
86 ( "com.sun.star.comp.stoc.DLLComponentLoader" );
88 catch( Exception e ) {
89 log.println("DLLComponentLoader Service not available" );
92 oObj = (XInterface) oInterface;
94 log.println( " creating a new environment for DLLComponentLoader object" );
95 TestEnvironment tEnv = new TestEnvironment( oObj );
97 // adding object relation for XImplementationLoader ifc test
98 tEnv.addObjRelation("ImplementationLoader",
99 "com.sun.star.loader.SharedLibrary") ;
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";
106 if (!os.equals("wntmsci"))
107 name = "lib" + name + ".so";
108 else
109 name += ".dll";
110 String implURL = utils.getFullTestURL(os + "/" + 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