1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package mod._dbaccess;
29 
30 import java.io.PrintWriter;
31 
32 import lib.Status;
33 import lib.StatusException;
34 import lib.TestCase;
35 import lib.TestEnvironment;
36 import lib.TestParameters;
37 
38 import com.sun.star.lang.XMultiServiceFactory;
39 import com.sun.star.uno.XInterface;
40 
41 /**
42 * Test for object which is represented by service
43 * <code>com.sun.star.sdb.ContentLoader</code>. <p>
44 * Object implements the following interfaces :
45 * <ul>
46 *  <li> <code>com::sun::star::beans::XPropertySet</code></li>
47 *  <li> <code>com::sun::star::frame::FrameLoader</code></li>
48 *  <li> <code>com::sun::star::frame::XFrameLoader</code></li>
49 *  <li> <code>com::sun::star::lang::XInitialization</code></li>
50 * </ul>
51 * This object test <b> is NOT </b> designed to be run in several
52 * threads concurently.
53 * @see com.sun.star.beans.XPropertySet
54 * @see com.sun.star.frame.FrameLoader
55 * @see com.sun.star.frame.XSynchronousFrameLoader
56 * @see com.sun.star.lang.XInitialization
57 * @see ifc.beans._XPropertySet
58 * @see ifc.frame._FrameLoader
59 * @see ifc.frame._XSynchronousFrameLoader
60 * @see ifc.lang._XInitialization
61 */
62 public class DBContentLoader extends TestCase {
63 
64     /**
65     * Creating a Testenvironment for the interfaces to be tested.
66     * Creates an instance of the service
67     * <code>com.sun.star.sdb.ContentLoader</code>. <p>
68     *     Object relations created :
69     * <ul>
70     *  <li> <code>'FrameLoader.URL"'</code> for
71     *      {@link ifc.frame._XFrameLoader} </li>
72     * </ul>
73     */
74     public TestEnvironment createTestEnvironment( TestParameters Param,
75                                                   PrintWriter log )
76                                                     throws StatusException {
77         XInterface oObj = null;
78         Object oInterface = null ;
79 
80         //now get the OButtonControl
81         try {
82             oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance
83                 ("com.sun.star.sdb.ContentLoader") ;
84         } catch (com.sun.star.uno.Exception e) {
85             log.println("Couldn't get service");
86             e.printStackTrace(log);
87             throw new StatusException("Couldn't get GridControl", e );
88         }
89 
90         if (oInterface == null) {
91             log.println("Service wasn't created") ;
92             throw new StatusException(Status.failed("Service wasn't created")) ;
93         }
94 
95         oObj = (XInterface) oInterface ;
96 
97         log.println("ImplementationName " + util.utils.getImplName(oObj));
98         log.println( "creating a new environment for object" );
99         TestEnvironment tEnv = new TestEnvironment( oObj );
100 
101         // adding relation for XFrameLoader
102         tEnv.addObjRelation("FrameLoader.URL",
103             ".component:DB/DataSourceBrowser") ;
104 
105 
106         return tEnv;
107     } // finish method getTestEnvironment
108 
109 }
110 
111