1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Pipe.java,v $
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
._streams
.uno
;
33 import com
.sun
.star
.io
.XInputStream
;
34 import com
.sun
.star
.lang
.XMultiServiceFactory
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.uno
.XInterface
;
37 import java
.io
.PrintWriter
;
38 import lib
.StatusException
;
40 import lib
.TestEnvironment
;
41 import lib
.TestParameters
;
44 * Test for object which is represented by service
45 * <code>com.sun.star.io.Pipe</code>. <p>
46 * Object implements the following interfaces :
48 * <li> <code>com::sun::star::io::XInputStream</code></li>
49 * <li> <code>com::sun::star::io::XOutputStream</code></li>
51 * @see com.sun.star.io.Pipe
52 * @see com.sun.star.io.XInputStream
53 * @see com.sun.star.io.XOutputStream
54 * @see ifc.io._XInputStream
55 * @see ifc.io._XOutputStream
57 public class Pipe
extends TestCase
{
60 * Creating a Testenvironment for the interfaces to be tested.
61 * Creates an instance of the service <code>com.sun.star.io.Pipe</code>.
62 * Writes some information to the created pipe.
63 * Object relations created :
65 * <li> <code>'XOutputStream.StreamChecker'</code> for
66 * {@link ifc.io._XOutputStream}( implementation of the interface
67 * ifc.io._XOutputStream.StreamChecker ) </li>
69 * @see com.sun.star.io.Pipe
71 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
73 XInterface oObj
= null;
74 Object oInterface
= null;
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
);
84 oObj
= (XInterface
) oInterface
;
86 // writing some information to the pipe
87 byte[] byteData
= new byte[] {
88 1, 2, 3, 4, 5, 6, 7, 8 } ;
90 log
.println( "creating a new environment for object" );
91 TestEnvironment tEnv
= new TestEnvironment( oObj
);
93 //add relation for io.XOutputStream
94 final XMultiServiceFactory msf
= (XMultiServiceFactory
)Param
.getMSF();
95 final XInputStream iStream
= (XInputStream
)
96 UnoRuntime
.queryInterface(XInputStream
.class, oObj
);
98 tEnv
.addObjRelation("ByteData", byteData
);
99 tEnv
.addObjRelation("StreamWriter", oObj
);
101 tEnv
.addObjRelation("XOutputStream.StreamChecker",
102 new ifc
.io
._XOutputStream
.StreamChecker() {
103 XInputStream inStream
= null;
104 public void resetStreams() {
107 public XInputStream
getInStream() {
113 } // finish method getTestEnvironment