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