2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package mod
._streams
.uno
;
21 import com
.sun
.star
.io
.XInputStream
;
22 import com
.sun
.star
.lang
.XMultiServiceFactory
;
23 import com
.sun
.star
.uno
.UnoRuntime
;
24 import com
.sun
.star
.uno
.XInterface
;
25 import java
.io
.PrintWriter
;
26 import lib
.StatusException
;
28 import lib
.TestEnvironment
;
29 import lib
.TestParameters
;
32 * Test for object which is represented by service
33 * <code>com.sun.star.io.Pipe</code>. <p>
34 * Object implements the following interfaces :
36 * <li> <code>com::sun::star::io::XInputStream</code></li>
37 * <li> <code>com::sun::star::io::XOutputStream</code></li>
39 * @see com.sun.star.io.Pipe
40 * @see com.sun.star.io.XInputStream
41 * @see com.sun.star.io.XOutputStream
42 * @see ifc.io._XInputStream
43 * @see ifc.io._XOutputStream
45 public class Pipe
extends TestCase
{
48 * Creating a Testenvironment for the interfaces to be tested.
49 * Creates an instance of the service <code>com.sun.star.io.Pipe</code>.
50 * Writes some information to the created pipe.
51 * Object relations created :
53 * <li> <code>'XOutputStream.StreamChecker'</code> for
54 * {@link ifc.io._XOutputStream}( implementation of the interface
55 * ifc.io._XOutputStream.StreamChecker ) </li>
57 * @see com.sun.star.io.Pipe
60 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
62 XInterface oObj
= null;
63 Object oInterface
= null;
66 XMultiServiceFactory xMSF
= Param
.getMSF();
67 oInterface
= xMSF
.createInstance( "com.sun.star.io.Pipe" );
68 } catch(com
.sun
.star
.uno
.Exception e
) {
69 e
.printStackTrace(log
);
70 throw new StatusException("Couldn't create instance", e
);
73 oObj
= (XInterface
) oInterface
;
75 // writing some information to the pipe
76 byte[] byteData
= new byte[] {
77 1, 2, 3, 4, 5, 6, 7, 8 } ;
79 log
.println( "creating a new environment for object" );
80 TestEnvironment tEnv
= new TestEnvironment( oObj
);
82 //add relation for io.XOutputStream
83 final XInputStream iStream
= UnoRuntime
.queryInterface(XInputStream
.class, oObj
);
85 tEnv
.addObjRelation("ByteData", byteData
);
86 tEnv
.addObjRelation("StreamWriter", oObj
);
88 tEnv
.addObjRelation("XOutputStream.StreamChecker",
89 new ifc
.io
._XOutputStream
.StreamChecker() {
90 public void resetStreams() {
93 public XInputStream
getInStream() {
99 } // finish method getTestEnvironment