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