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._cnt;
25 
26 import java.io.PrintWriter;
27 
28 import lib.StatusException;
29 import lib.TestCase;
30 import lib.TestEnvironment;
31 import lib.TestParameters;
32 
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.ucb.XContentIdentifierFactory;
35 import com.sun.star.uno.UnoRuntime;
36 import com.sun.star.uno.XInterface;
37 
38 /**
39 * Test for object which is represented by service
40 * <code>com.sun.star.cnt.ChaosContentProvider</code>. <p>
41 * Object implements the following interfaces :
42 * <ul>
43 *  <li> <code>com::sun::star::ucb::XContentProvider</code></li>
44 * </ul>
45 * This object test <b> is NOT </b> designed to be run in several
46 * threads concurently.
47 * @see com.sun.star.ucb.XContentProvider
48 * @see com.sun.star.ucb.ChaosContentProvider
49 * @see ifc.ucb._XContentProvider
50 */
51 public class ChaosContentProvider extends TestCase {
52 
53     /**
54     * Creating a Testenvironment for the interfaces to be tested.
55     * Creates an instance of the service
56     * <code>com.sun.star.cnt.ChaosContentProvider</code>. <p>
57     *     Object relations created :
58     * <ul>
59     *  <li> <code>'FACTORY'</code> for
60     *      {@link ifc.ucb._XContentProvider} factory for
61     *   content identifiers. Here it is
62     *   <code>UniversalContentBroker</code> service.</li>
63     *  <li> <code>'CONTENT1'</code> for
64     *     {@link ifc.ucb._XContentProvider}: suitable
65     *   content URL for this provider </li>
66     *  <li> <code>'CONTENT2'</code> for
67     *     {@link ifc.ucb._XContentProvider}: another suitable
68     *   content URL for this provider </li>
69     * </ul>
70     */
createTestEnvironment( TestParameters Param, PrintWriter log )71     public TestEnvironment createTestEnvironment( TestParameters Param,
72                                                   PrintWriter log )
73                                                     throws StatusException {
74         XInterface oObj = null;
75         Object oInterface = null;
76         XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
77         Object cntFactory = null ;
78 
79         try {
80             oInterface = xMSF.createInstance
81                 ( "com.sun.star.ucb.ChaosContentProvider" );
82             cntFactory = xMSF.createInstance
83                 ( "com.sun.star.comp.ucb.UniversalContentBroker" );
84         }
85         catch( com.sun.star.uno.Exception e ) {
86             log.println("Can't create an object." );
87             throw new StatusException( "Can't create an object", e );
88         }
89 
90         oObj = (XInterface) oInterface;
91 
92         TestEnvironment tEnv = new TestEnvironment( oObj );
93 
94         // adding relation for XContentProvider
95         XContentIdentifierFactory CIF = (XContentIdentifierFactory)
96         UnoRuntime.queryInterface(XContentIdentifierFactory.class, cntFactory);
97 
98         tEnv.addObjRelation("FACTORY", CIF) ;
99         tEnv.addObjRelation("CONTENT1", "ftp://localhost") ;
100         tEnv.addObjRelation("CONTENT2", "ftp://sva.dorms.spbu.ru") ;
101 
102         return tEnv;
103     } // finish method getTestEnvironment
104 
105 }
106 
107