bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / io / _XDataOutputStream.java
blob90d049cbd05ff0c0622d94b514cf4f5d14f0fcc3
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 ifc.io;
21 import java.util.List;
23 import lib.MultiMethodTest;
25 import com.sun.star.io.XDataOutputStream;
27 /**
28 * Testing <code>com.sun.star.io.XDataOutputStream</code>
29 * interface methods:
30 * <ul>
31 * <li><code>writeBoolean()</code></li>
32 * <li><code>writeByte()</code></li>
33 * <li><code>writeChar()</code></li>
34 * <li><code>writeShort()</code></li>
35 * <li><code>writeLong()</code></li>
36 * <li><code>writeHyper()</code></li>
37 * <li><code>writeFloat()</code></li>
38 * <li><code>writeDouble()</code></li>
39 * <li><code>writeUTF()</code></li>
40 * </ul> <p>
41 * This test needs the following object relations :
42 * <ul>
43 * <li> <code>'StreamData'</code> (of type <code>Vector</code>):
44 * vector of data for writing to the stream </li>
45 * <ul> <p>
46 * After test completion object environment has to be recreated.
47 * @see com.sun.star.io.XDataOutputStream
49 public class _XDataOutputStream extends MultiMethodTest {
51 public XDataOutputStream oObj = null;
53 /**
54 * Retrieves object relation <code>'StreamData'</code>
55 * and executes methods of interface depending of data in stream.
56 * If relation or data of some type in stream not found then
57 * tests of corresponding methods are skipped.
59 public void before() throws RuntimeException {
61 List<Object> data = (List<Object>) tEnv.getObjRelation("StreamData") ;
62 if (data == null) {
63 throw new RuntimeException("Object relation 'StreamData' not found.");
66 // extract data from vector
67 Object dataElem = null ;
68 for (int i = 0; i < data.size(); i++) {
69 dataElem = data.get(i) ;
71 if (dataElem instanceof Boolean) {
72 ((Boolean)dataElem).booleanValue();
73 } else
74 if (dataElem instanceof Byte) {
75 ((Byte)dataElem).byteValue();
76 } else
77 if (dataElem instanceof Character) {
78 ((Character)dataElem).charValue();
79 } else
80 if (dataElem instanceof Short) {
81 ((Short)dataElem).shortValue();
82 } else
83 if (dataElem instanceof Integer) {
84 ((Integer)dataElem).intValue();
85 } else
86 if (dataElem instanceof Long) {
87 ((Long)dataElem).longValue();
88 } else
89 if (dataElem instanceof Float) {
90 ((Float)dataElem).floatValue();
91 } else
92 if (dataElem instanceof Double) {
93 ((Double)dataElem).doubleValue();
94 } else
95 if (dataElem instanceof String) {
101 * Test writes some data to stream. <p>
102 * Has <b> OK </b> status if the method successfully returns
103 * and no exceptions were thrown. <p>
105 public void _writeBoolean() {
106 boolean res = true;
107 try {
108 oObj.writeBoolean(true) ;
109 } catch(com.sun.star.io.IOException e) {
110 log.println("Couldn't write Boolean to stream");
111 e.printStackTrace(log);
112 res = false;
114 tRes.tested("writeBoolean()", res) ;
118 * Test writes some data to stream. <p>
119 * Has <b> OK </b> status if the method successfully returns
120 * and no exceptions were thrown. <p>
122 public void _writeByte() {
123 boolean res = true;
124 try {
125 oObj.writeByte((byte) 123);
126 } catch(com.sun.star.io.IOException e) {
127 log.println("Couldn't write Byte to stream");
128 e.printStackTrace(log);
129 res = false;
131 tRes.tested("writeByte()", res);
135 * Test writes some data to stream. <p>
136 * Has <b> OK </b> status if the method successfully returns
137 * and no exceptions were thrown. <p>
139 public void _writeChar() {
140 boolean res = true;
141 try {
142 oObj.writeChar((char)12345);
143 } catch(com.sun.star.io.IOException e) {
144 log.println("Couldn't write Char to stream");
145 e.printStackTrace(log);
146 res = false;
148 tRes.tested("writeChar()", res);
152 * Test writes some data to stream. <p>
153 * Has <b> OK </b> status if the method successfully returns
154 * and no exceptions were thrown. <p>
156 public void _writeShort() {
157 boolean res = true;
158 try {
159 oObj.writeShort((short)12345) ;
160 } catch(com.sun.star.io.IOException e) {
161 log.println("Couldn't write Short to stream");
162 e.printStackTrace(log);
163 res = false;
165 tRes.tested("writeShort()", res);
169 * Test writes some data to stream. <p>
170 * Has <b> OK </b> status if the method successfully returns
171 * and no exceptions were thrown. <p>
173 public void _writeLong() {
174 boolean res = true;
175 try {
176 oObj.writeLong(123456);
177 } catch(com.sun.star.io.IOException e) {
178 log.println("Couldn't write Long to stream");
179 e.printStackTrace(log);
180 res = false;
182 tRes.tested("writeLong()", res);
186 * Test writes some data to stream. <p>
187 * Has <b> OK </b> status if the method successfully returns
188 * and no exceptions were thrown. <p>
190 public void _writeHyper() {
191 boolean res = true;
192 try {
193 oObj.writeHyper(123456789);
194 } catch(com.sun.star.io.IOException e) {
195 log.println("Couldn't write Hyper to stream");
196 e.printStackTrace(log);
197 res = false;
199 tRes.tested("writeHyper()", res);
203 * Test writes some data to stream. <p>
204 * Has <b> OK </b> status if the method successfully returns
205 * and no exceptions were thrown. <p>
207 public void _writeFloat() {
208 boolean res = true;
209 try {
210 oObj.writeFloat((float)1.2345);
211 } catch(com.sun.star.io.IOException e) {
212 log.println("Couldn't write Float to stream");
213 e.printStackTrace(log);
214 res = false;
216 tRes.tested("writeFloat()", res);
220 * Test writes some data to stream. <p>
221 * Has <b> OK </b> status if the method successfully returns
222 * and no exceptions were thrown. <p>
224 public void _writeDouble() {
225 boolean res = true;
226 try {
227 oObj.writeDouble(1.2345);
228 } catch(com.sun.star.io.IOException e) {
229 log.println("Couldn't write Double to stream");
230 e.printStackTrace(log);
231 res = false;
233 tRes.tested("writeDouble()", res);
237 * Test writes some data to stream. <p>
238 * Has <b> OK </b> status if the method successfully returns
239 * and no exceptions were thrown. <p>
241 public void _writeUTF() {
242 boolean res = true;
243 try {
244 oObj.writeUTF("XDataOutputStream") ;
245 } catch(com.sun.star.io.IOException e) {
246 log.println("Couldn't write String to stream");
247 e.printStackTrace(log);
248 res = false;
250 tRes.tested("writeUTF()", res);
254 * Forces object environment recreation.
256 public void after() {
257 this.disposeEnvironment() ;