Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / ifc / io / _XActiveDataSink.java
blobec1dad459570b355ffc464a93e18b6daa9174a3b
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.io;
21 import lib.MultiMethodTest;
23 import com.sun.star.io.XActiveDataSink;
24 import com.sun.star.io.XInputStream;
25 import com.sun.star.uno.UnoRuntime;
26 import com.sun.star.uno.XInterface;
28 /**
29 * Testing <code>com.sun.star.io.XActiveDataSink</code>
30 * interface methods :
31 * <ul>
32 * <li><code> setInputStream()</code></li>
33 * <li><code> getInputStream()</code></li>
34 * </ul> <p>
35 * Test is <b> NOT </b> multithread compliant. <p>
37 * This test needs the following object relations :
38 * <ul>
39 * <li> <code>'InputStream'</code>
40 * (of type <code>com.sun.star.io.XInputStream</code>):
41 * acceptable input stream which can be set by <code>setInputStream</code> </li>
42 * <ul> <p>
44 * After test completion object environment has to be recreated.
45 * @see com.sun.star.io.XActiveDataSink
47 public class _XActiveDataSink extends MultiMethodTest {
49 public XActiveDataSink oObj = null;
51 private XInputStream iStream = null;
53 /**
54 * Take the XInputStream from the environment for setting and getting
56 @Override
57 public void before() {
58 XInterface x = (XInterface)tEnv.getObjRelation("InputStream");
59 iStream = UnoRuntime.queryInterface
60 (XInputStream.class, x) ;
63 /**
64 * Just sets new input stream. <p>
65 * Has <b>OK</b> status if no runtime exceptions occurred.
67 public void _setInputStream() {
68 oObj.setInputStream(iStream) ;
70 tRes.tested("setInputStream()", true) ;
73 /**
74 * First retrieves current input stream, then sets to new
75 * input stream (if old was <code>null</code>) or to null.
76 * Then input stream retrieved again and checked to be not
77 * equal to the old one. <p>
78 * Has <b>OK</b> status if old and new streams retrieved are
79 * not equal. <p>
80 * The following method tests are to be completed successfully before :
81 * <ul>
82 * <li> <code> setInputStream() </code> : to be sure the method
83 * works without exceptions. </li>
84 * </ul>
86 public void _getInputStream() {
87 requiredMethod("setInputStream()") ;
89 Object oldStream = oObj.getInputStream() ;
90 XInputStream newStream = oldStream == null ? iStream : null ;
92 oObj.setInputStream(newStream) ;
93 Object getStream = oObj.getInputStream() ;
95 tRes.tested("getInputStream()", getStream != oldStream) ;
98 @Override
99 public void after() {
100 this.disposeEnvironment() ;