Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _cpld / DLLComponentLoader.java
blob480c0e3bd7a873098b1a6f1f9bfc46e7d5b211de
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._cpld;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.utils;
29 import com.sun.star.lang.XMultiServiceFactory;
30 import com.sun.star.uno.XInterface;
32 /**
33 * Test for <code>com.sun.star.comp.stoc.DLLComponentLoader</code> service <p>
34 * Files which are used :
35 * <ul>
36 * <li> <code>XImpReg.dll</code> : DLL which will be loaded in
37 * <code>XImplementationLoader</code> interface test. </li>
38 * <ul>
39 * Multithread testing compliant.
40 * @see com.sun.star.loader.XImplementationLoader
41 * @see com.sun.star.lang.XServiceInfo
42 * @see ifc.loader._XImplementationLoader
43 * @see ifc.lang._XServiceInfo
45 public class DLLComponentLoader extends TestCase {
47 /**
48 * Does nothing.
50 @Override
51 protected void initialize ( TestParameters Param, PrintWriter log) {
55 /**
56 * Creating a Testenvironment for the interfaces to be tested.
57 * Creates <code>com.sun.star.comp.stoc.DLLComponentLoader</code>
58 * service. <p>
59 * The following object relations created :
60 * <ul>
61 * <li> <code>'ImplementationLoader'</code> : service which is
62 * responsible for loading DLL implementations. </li>
63 * <li> <code>'ImplementationUrl'</code> : DLL file location. </li>
64 * <li> <code>'ImplementationName'</code> : Name of the implementation.</li>
65 * </ul>
67 @Override
68 protected TestEnvironment createTestEnvironment
69 (TestParameters Param, PrintWriter log) {
70 XInterface oObj = null;
71 Object oInterface = null;
73 try {
74 XMultiServiceFactory xMSF = Param.getMSF();
75 oInterface = xMSF.createInstance
76 ( "com.sun.star.comp.stoc.DLLComponentLoader" );
78 catch( Exception e ) {
79 log.println("DLLComponentLoader Service not available" );
82 oObj = (XInterface) oInterface;
84 log.println( " creating a new environment for DLLComponentLoader object" );
85 TestEnvironment tEnv = new TestEnvironment( oObj );
87 // adding object relation for XImplementationLoader ifc test
88 tEnv.addObjRelation("ImplementationLoader",
89 "com.sun.star.loader.SharedLibrary") ;
90 String os = (String) Param.get("OS");
91 if (os == null || os.equals(""))
92 throw new StatusException(
93 "Couldn't determine operating system for naming convention.",
94 new NullPointerException());
95 String name = "javaloader";
96 if (!os.equals("wntmsci"))
97 name = "lib" + name + ".so";
98 else
99 name += ".dll";
100 String implURL = utils.getFullTestURL(os + "/" + name);
101 tEnv.addObjRelation("ImplementationUrl", implURL) ;
102 log.println("looking for shared lib: " + implURL);
103 tEnv.addObjRelation("ImplementationName",
104 "com.sun.star.comp.stoc.JavaComponentLoader") ;
106 return tEnv;
107 } // finish method getTestEnvironment
109 } // finish class DLLComponentLoader