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.XActiveDataSink; 29 import com.sun.star.io.XInputStream; 30 import com.sun.star.uno.UnoRuntime; 31 import com.sun.star.uno.XInterface; 32 33 /** 34 * Testing <code>com.sun.star.io.XActiveDataSink</code> 35 * interface methods : 36 * <ul> 37 * <li><code> setInputStream()</code></li> 38 * <li><code> getInputStream()</code></li> 39 * </ul> <p> 40 * Test is <b> NOT </b> multithread compilant. <p> 41 * 42 * This test needs the following object relations : 43 * <ul> 44 * <li> <code>'InputStream'</code> 45 * (of type <code>com.sun.star.io.XInputStream</code>): 46 * acceptable input stream which can be set by <code>setInputStream</code> </li> 47 * <ul> <p> 48 * 49 * After test completion object environment has to be recreated. 50 * @see com.sun.star.io.XActiveDataSink 51 */ 52 public class _XActiveDataSink extends MultiMethodTest { 53 54 public XActiveDataSink oObj = null; 55 56 private XInputStream iStream = null; 57 58 /** 59 * Take the XInputStream from the environment for setting and getting 60 */ before()61 public void before() { 62 XInterface x = (XInterface)tEnv.getObjRelation("InputStream"); 63 iStream = (XInputStream) UnoRuntime.queryInterface 64 (XInputStream.class, x) ; 65 } 66 67 /** 68 * Just sets new input stream. <p> 69 * Has <b>OK</b> status if no runtime exceptions occurred. 70 */ _setInputStream()71 public void _setInputStream() { 72 oObj.setInputStream(iStream) ; 73 74 tRes.tested("setInputStream()", true) ; 75 } 76 77 /** 78 * First retrieves current input stream, then sets to new 79 * input stream (if old was <code>null</code>) or to null. 80 * Then input stream retrieved again and checked to be not 81 * equal to the old one. <p> 82 * Has <b>OK</b> status if old and new streams retrieved are 83 * not equal. <p> 84 * The following method tests are to be completed successfully before : 85 * <ul> 86 * <li> <code> setInputStream() </code> : to be sure the method 87 * works without exceptions. </li> 88 * </ul> 89 */ _getInputStream()90 public void _getInputStream() { 91 requiredMethod("setInputStream()") ; 92 93 Object oldStream = oObj.getInputStream() ; 94 XInputStream newStream = oldStream == null ? iStream : null ; 95 96 oObj.setInputStream(newStream) ; 97 Object getStream = oObj.getInputStream() ; 98 99 tRes.tested("getInputStream()", getStream != oldStream) ; 100 } 101 after()102 public void after() { 103 this.disposeEnvironment() ; 104 } 105 } 106 107 108