1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package mod._dbaccess;
25 
26 import java.io.PrintWriter;
27 
28 import lib.Status;
29 import lib.StatusException;
30 import lib.TestCase;
31 import lib.TestEnvironment;
32 import lib.TestParameters;
33 
34 import com.sun.star.lang.XMultiServiceFactory;
35 import com.sun.star.uno.XInterface;
36 
37 /**
38 * Test for object which is represented by service
39 * <code>com.sun.star.sdb.ContentLoader</code>. <p>
40 * Object implements the following interfaces :
41 * <ul>
42 *  <li> <code>com::sun::star::beans::XPropertySet</code></li>
43 *  <li> <code>com::sun::star::frame::FrameLoader</code></li>
44 *  <li> <code>com::sun::star::frame::XFrameLoader</code></li>
45 *  <li> <code>com::sun::star::lang::XInitialization</code></li>
46 * </ul>
47 * This object test <b> is NOT </b> designed to be run in several
48 * threads concurently.
49 * @see com.sun.star.beans.XPropertySet
50 * @see com.sun.star.frame.FrameLoader
51 * @see com.sun.star.frame.XSynchronousFrameLoader
52 * @see com.sun.star.lang.XInitialization
53 * @see ifc.beans._XPropertySet
54 * @see ifc.frame._FrameLoader
55 * @see ifc.frame._XSynchronousFrameLoader
56 * @see ifc.lang._XInitialization
57 */
58 public class DBContentLoader extends TestCase {
59 
60     /**
61     * Creating a Testenvironment for the interfaces to be tested.
62     * Creates an instance of the service
63     * <code>com.sun.star.sdb.ContentLoader</code>. <p>
64     *     Object relations created :
65     * <ul>
66     *  <li> <code>'FrameLoader.URL"'</code> for
67     *      {@link ifc.frame._XFrameLoader} </li>
68     * </ul>
69     */
createTestEnvironment( TestParameters Param, PrintWriter log )70     public TestEnvironment createTestEnvironment( TestParameters Param,
71                                                   PrintWriter log )
72                                                     throws StatusException {
73         XInterface oObj = null;
74         Object oInterface = null ;
75 
76         //now get the OButtonControl
77         try {
78             oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance
79                 ("com.sun.star.sdb.ContentLoader") ;
80         } catch (com.sun.star.uno.Exception e) {
81             log.println("Couldn't get service");
82             e.printStackTrace(log);
83             throw new StatusException("Couldn't get GridControl", e );
84         }
85 
86         if (oInterface == null) {
87             log.println("Service wasn't created") ;
88             throw new StatusException(Status.failed("Service wasn't created")) ;
89         }
90 
91         oObj = (XInterface) oInterface ;
92 
93         log.println("ImplementationName " + util.utils.getImplName(oObj));
94         log.println( "creating a new environment for object" );
95         TestEnvironment tEnv = new TestEnvironment( oObj );
96 
97         // adding relation for XFrameLoader
98         tEnv.addObjRelation("FrameLoader.URL",
99             ".component:DB/DataSourceBrowser") ;
100 
101 
102         return tEnv;
103     } // finish method getTestEnvironment
104 
105 }
106 
107