merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _stm / Pipe.java
blob01657d473c359f8fd036aa2333b3a6ddbca0998b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Pipe.java,v $
10 * $Revision: 1.5 $
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 ************************************************************************/
31 package mod._stm;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
40 import com.sun.star.io.XInputStream;
41 import com.sun.star.lang.XMultiServiceFactory;
42 import com.sun.star.uno.UnoRuntime;
43 import com.sun.star.uno.XInterface;
45 /**
46 * Test for object which is represented by service
47 * <code>com.sun.star.io.Pipe</code>. <p>
48 * Object implements the following interfaces :
49 * <ul>
50 * <li> <code>com::sun::star::io::XInputStream</code></li>
51 * <li> <code>com::sun::star::io::XOutputStream</code></li>
52 * </ul>
53 * @see com.sun.star.io.Pipe
54 * @see com.sun.star.io.XInputStream
55 * @see com.sun.star.io.XOutputStream
56 * @see ifc.io._XInputStream
57 * @see ifc.io._XOutputStream
59 public class Pipe extends TestCase {
61 /**
62 * Creating a Testenvironment for the interfaces to be tested.
63 * Creates an instance of the service <code>com.sun.star.io.Pipe</code>.
64 * Writes some information to the created pipe.
65 * Object relations created :
66 * <ul>
67 * <li> <code>'XOutputStream.StreamChecker'</code> for
68 * {@link ifc.io._XOutputStream}( implementation of the interface
69 * ifc.io._XOutputStream.StreamChecker ) </li>
70 * </ul>
71 * @see com.sun.star.io.Pipe
73 public TestEnvironment createTestEnvironment(
74 TestParameters Param, PrintWriter log) throws StatusException {
76 XInterface oObj = null;
77 Object oInterface = null;
79 try {
80 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
81 oInterface = xMSF.createInstance( "com.sun.star.io.Pipe" );
82 } catch(com.sun.star.uno.Exception e) {
83 e.printStackTrace(log);
84 throw new StatusException("Couldn't create instance", e);
87 oObj = (XInterface) oInterface;
89 // writing some information to the pipe
90 byte[] byteData = new byte[] {
91 1, 2, 3, 4, 5, 6, 7, 8 } ;
93 log.println( "creating a new environment for object" );
94 TestEnvironment tEnv = new TestEnvironment( oObj );
96 //add relation for io.XOutputStream
97 final XInputStream iStream = (XInputStream)
98 UnoRuntime.queryInterface(XInputStream.class, oObj);
100 tEnv.addObjRelation("ByteData", byteData);
101 tEnv.addObjRelation("StreamWriter", oObj);
103 tEnv.addObjRelation("XOutputStream.StreamChecker",
104 new ifc.io._XOutputStream.StreamChecker() {
105 XInputStream inStream = null;
106 public void resetStreams() {
109 public XInputStream getInStream() {
110 return iStream;
114 return tEnv;
115 } // finish method getTestEnvironment