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 mod._streams.uno; 29 30 import com.sun.star.io.XInputStream; 31 import com.sun.star.lang.XMultiServiceFactory; 32 import com.sun.star.uno.UnoRuntime; 33 import com.sun.star.uno.XInterface; 34 import java.io.PrintWriter; 35 import lib.StatusException; 36 import lib.TestCase; 37 import lib.TestEnvironment; 38 import lib.TestParameters; 39 40 /** 41 * Test for object which is represented by service 42 * <code>com.sun.star.io.Pipe</code>. <p> 43 * Object implements the following interfaces : 44 * <ul> 45 * <li> <code>com::sun::star::io::XInputStream</code></li> 46 * <li> <code>com::sun::star::io::XOutputStream</code></li> 47 * </ul> 48 * @see com.sun.star.io.Pipe 49 * @see com.sun.star.io.XInputStream 50 * @see com.sun.star.io.XOutputStream 51 * @see ifc.io._XInputStream 52 * @see ifc.io._XOutputStream 53 */ 54 public class Pipe extends TestCase { 55 56 /** 57 * Creating a Testenvironment for the interfaces to be tested. 58 * Creates an instance of the service <code>com.sun.star.io.Pipe</code>. 59 * Writes some information to the created pipe. 60 * Object relations created : 61 * <ul> 62 * <li> <code>'XOutputStream.StreamChecker'</code> for 63 * {@link ifc.io._XOutputStream}( implementation of the interface 64 * ifc.io._XOutputStream.StreamChecker ) </li> 65 * </ul> 66 * @see com.sun.star.io.Pipe 67 */ 68 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 69 70 XInterface oObj = null; 71 Object oInterface = null; 72 73 try { 74 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF(); 75 oInterface = xMSF.createInstance( "com.sun.star.io.Pipe" ); 76 } catch(com.sun.star.uno.Exception e) { 77 e.printStackTrace(log); 78 throw new StatusException("Couldn't create instance", e); 79 } 80 81 oObj = (XInterface) oInterface; 82 83 // writing some information to the pipe 84 byte[] byteData = new byte[] { 85 1, 2, 3, 4, 5, 6, 7, 8 } ; 86 87 log.println( "creating a new environment for object" ); 88 TestEnvironment tEnv = new TestEnvironment( oObj ); 89 90 //add relation for io.XOutputStream 91 final XInputStream iStream = (XInputStream) 92 UnoRuntime.queryInterface(XInputStream.class, oObj); 93 94 tEnv.addObjRelation("ByteData", byteData); 95 tEnv.addObjRelation("StreamWriter", oObj); 96 97 tEnv.addObjRelation("XOutputStream.StreamChecker", 98 new ifc.io._XOutputStream.StreamChecker() { 99 public void resetStreams() { 100 } 101 102 public XInputStream getInStream() { 103 return iStream; 104 } 105 }); 106 107 return tEnv; 108 } // finish method getTestEnvironment 109 110 } 111 112