bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _stm / Pipe.java
bloba1f84073c4bbf952d5c98a8fc5738d4007337241
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 @Override
62 public TestEnvironment createTestEnvironment(
63 TestParameters Param, PrintWriter log) throws StatusException {
65 XInterface oObj = null;
66 Object oInterface = null;
68 try {
69 XMultiServiceFactory xMSF = Param.getMSF();
70 oInterface = xMSF.createInstance( "com.sun.star.io.Pipe" );
71 } catch(com.sun.star.uno.Exception e) {
72 e.printStackTrace(log);
73 throw new StatusException("Couldn't create instance", e);
76 oObj = (XInterface) oInterface;
78 // writing some information to the pipe
79 byte[] byteData = new byte[] {
80 1, 2, 3, 4, 5, 6, 7, 8 } ;
82 log.println( "creating a new environment for object" );
83 TestEnvironment tEnv = new TestEnvironment( oObj );
85 //add relation for io.XOutputStream
86 final XInputStream iStream = UnoRuntime.queryInterface(XInputStream.class, oObj);
88 tEnv.addObjRelation("ByteData", byteData);
89 tEnv.addObjRelation("StreamWriter", oObj);
91 tEnv.addObjRelation("XOutputStream.StreamChecker",
92 new ifc.io._XOutputStream.StreamChecker() {
93 public void resetStreams() {
96 public XInputStream getInStream() {
97 return iStream;
99 });
101 return tEnv;
102 } // finish method getTestEnvironment