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