1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XActiveDataSink.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.io
.XActiveDataSink
;
36 import com
.sun
.star
.io
.XInputStream
;
37 import com
.sun
.star
.uno
.UnoRuntime
;
38 import com
.sun
.star
.uno
.XInterface
;
41 * Testing <code>com.sun.star.io.XActiveDataSink</code>
44 * <li><code> setInputStream()</code></li>
45 * <li><code> getInputStream()</code></li>
47 * Test is <b> NOT </b> multithread compilant. <p>
49 * This test needs the following object relations :
51 * <li> <code>'InputStream'</code>
52 * (of type <code>com.sun.star.io.XInputStream</code>):
53 * acceptable input stream which can be set by <code>setInputStream</code> </li>
56 * After test completion object environment has to be recreated.
57 * @see com.sun.star.io.XActiveDataSink
59 public class _XActiveDataSink
extends MultiMethodTest
{
61 public XActiveDataSink oObj
= null;
63 private XInputStream iStream
= null;
66 * Take the XInputStream from the environment for setting and getting
68 public void before() {
69 XInterface x
= (XInterface
)tEnv
.getObjRelation("InputStream");
70 iStream
= (XInputStream
) UnoRuntime
.queryInterface
71 (XInputStream
.class, x
) ;
75 * Just sets new input stream. <p>
76 * Has <b>OK</b> status if no runtime exceptions occured.
78 public void _setInputStream() {
79 oObj
.setInputStream(iStream
) ;
81 tRes
.tested("setInputStream()", true) ;
85 * First retrieves current input stream, then sets to new
86 * input stream (if old was <code>null</code>) or to null.
87 * Then input stream retrieved again and checked to be not
88 * equal to the old one. <p>
89 * Has <b>OK</b> status if old and new streams retrieved are
91 * The following method tests are to be completed successfully before :
93 * <li> <code> setInputStream() </code> : to be sure the method
94 * works without exceptions. </li>
97 public void _getInputStream() {
98 requiredMethod("setInputStream()") ;
100 Object oldStream
= oObj
.getInputStream() ;
101 XInputStream newStream
= oldStream
== null ? iStream
: null ;
103 oObj
.setInputStream(newStream
) ;
104 Object getStream
= oObj
.getInputStream() ;
106 tRes
.tested("getInputStream()", getStream
!= oldStream
) ;
109 public void after() {
110 this.disposeEnvironment() ;