xref: /AOO41X/main/qadevOOo/tests/java/mod/_ucprmt/ContentProvider.java (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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._ucprmt;
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.ucb.XContentIdentifierFactory;
40 import com.sun.star.uno.UnoRuntime;
41 import com.sun.star.uno.XInterface;
42 
43 /**
44 * Test for object which is represented by service
45 * <code>com.sun.star.ucb.RemoteAccessContentProvider</code>. <p>
46 * Object implements the following interfaces :
47 * <ul>
48 *  <li> <code>com::sun::star::ucb::XContentProvider</code></li>
49 *  <li> <code>com::sun::star::ucb::XFileIdentifierConverter</code></li>
50 *  <li> <code>com::sun::star::ucb::XContentIdentifierFactory</code></li>
51 *  <li> <code>com::sun::star::ucb::XParameterizedContentProvider</code></li>
52 * </ul>
53 * This object test <b> is NOT </b> designed to be run in several
54 * threads concurently.
55 * @see com.sun.star.ucb.XContentProvider
56 * @see com.sun.star.ucb.XFileIdentifierConverter
57 * @see com.sun.star.ucb.XContentIdentifierFactory
58 * @see com.sun.star.ucb.XParameterizedContentProvider
59 * @see ifc.ucb._XContentProvider
60 * @see ifc.ucb._XFileIdentifierConverter
61 * @see ifc.ucb._XContentIdentifierFactory
62 * @see ifc.ucb._XParameterizedContentProvider
63 */
64 public class ContentProvider extends TestCase {
65 
66     /**
67     * Creating a Testenvironment for the interfaces to be tested.
68     * Creates an instance of the service
69     * <code>com.sun.star.ucprmt.ContentProvider</code>. <p>
70     *     Object relations created :
71     * <ul>
72     *  <li> <code>'FACTORY'</code> for
73     *      {@link ifc.ucb._XContentProvider} factory for
74     *   content identifiers. Here it is
75     *   <code>UniversalContentBroker</code> service.</li>
76     *  <li> <code>'CONTENT1'</code> for
77     *     {@link ifc.ucb._XContentProvider}: suitable
78     *   content URL for this provider </li>
79     *  <li> <code>'CONTENT2'</code> for
80     *     {@link ifc.ucb._XContentProvider}: another suitable
81     *   content URL for this provider </li>
82     * </ul>
83     */
84     public TestEnvironment createTestEnvironment
85             (TestParameters Param, PrintWriter log ) {
86         XInterface oObj = null;
87         XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
88         XContentIdentifierFactory cntIDFac = null ;
89 
90         try {
91             oObj = (XInterface) xMSF.createInstance
92                 ("com.sun.star.ucb.RemoteAccessContentProvider");
93             cntIDFac = (XContentIdentifierFactory) UnoRuntime.queryInterface
94                     (XContentIdentifierFactory.class, oObj) ;
95         }
96         catch( com.sun.star.uno.Exception e ) {
97             log.println("Can't create an object." );
98             throw new StatusException( "Can't create an object", e );
99         }
100 
101         if (oObj == null) {
102             log.println("!!! Object wasn't created !!!") ;
103             throw new StatusException(Status.failed
104                     ("!!! Object wasn't created !!!")) ;
105         }
106 
107         TestEnvironment tEnv = new TestEnvironment( oObj );
108 
109         // adding relation for XContentProvider
110         tEnv.addObjRelation("FACTORY", cntIDFac) ;
111         tEnv.addObjRelation("CONTENT1","vnd.sun.star.wfs:///user/work");
112         tEnv.addObjRelation("CONTENT2","vnd.sun.star.wfs:///user/config");
113 
114         return tEnv;
115     } // finish method getTestEnvironment
116 
117 }
118 
119