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 ifc.io;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.io.XActiveDataSource;
29 import com.sun.star.io.XOutputStream;
30 import com.sun.star.uno.UnoRuntime;
31 import com.sun.star.uno.XInterface;
32 
33 /**
34 * Testing <code>com.sun.star.io.XActiveDataSource</code>
35 * interface methods:
36 * <ul>
37 *   <li><code>setOutputStream()</code></li>
38 *   <li><code>getOutputStream()</code></li>
39 * </ul> <p>
40 *
41 * This test needs the following object relations :
42 * <ul>
43 *  <li> <code>'OutputStream'</code>
44 *  (of type <code>com.sun.star.io.OutputStream</code>):
45 *   acceptable output stream which can be set by <code>setOutputStream</code> </li>
46 * <ul> <p>
47 *
48 * After test completion object environment has to be recreated.
49 * @see com.sun.star.io.XActiveDataSource
50 * @see com.sun.star.io.XOutputStream
51 */
52 public class _XActiveDataSource extends MultiMethodTest {
53 
54     public XActiveDataSource oObj = null;
55 
56     private XOutputStream oStream = null;
57 
58     /**
59     * Take the XOutputStream from the environment for setting and getting.
60     */
before()61     public void before() {
62         XInterface x = (XInterface)tEnv.getObjRelation("OutputStream");
63         oStream = (XOutputStream) UnoRuntime.queryInterface
64                 (XOutputStream.class, x) ;
65     }
66 
67     /**
68     * Test calls the method using interface <code>XOutputStream</code>
69     * received in method <code>before()</code> as parameter. <p>
70     * Has <b> OK </b> status if the method successfully returns. <p>
71     */
_setOutputStream()72     public void _setOutputStream() {
73         oObj.setOutputStream(oStream);
74         tRes.tested("setOutputStream()", true);
75     }
76 
77     /**
78     * Test calls the method and compares returned value with value that was
79     * set in the method <code>setOutputStream()</code>. <p>
80     * Has <b> OK </b> status if values are equal. <p>
81     * The following method tests are to be completed successfully before :
82     * <ul>
83     *  <li> <code> setOutputStream() </code></li>
84     * </ul>
85     */
_getOutputStream()86     public void _getOutputStream() {
87         requiredMethod("setOutputStream()");
88 
89         tRes.tested("getOutputStream()",
90             oStream.equals(oObj.getOutputStream()));
91     }
92 
93     /**
94     * Forces object environment recreation.
95     */
after()96     public void after() {
97         this.disposeEnvironment() ;
98     }
99 }
100 
101