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