summaryrefslogtreecommitdiffstats
path: root/qadevOOo/tests/java/ifc/io
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/tests/java/ifc/io')
-rw-r--r--qadevOOo/tests/java/ifc/io/_XActiveDataControl.java238
-rw-r--r--qadevOOo/tests/java/ifc/io/_XActiveDataSink.java104
-rw-r--r--qadevOOo/tests/java/ifc/io/_XActiveDataSource.java97
-rw-r--r--qadevOOo/tests/java/ifc/io/_XConnectable.java125
-rw-r--r--qadevOOo/tests/java/ifc/io/_XDataInputStream.java414
-rw-r--r--qadevOOo/tests/java/ifc/io/_XDataOutputStream.java245
-rw-r--r--qadevOOo/tests/java/ifc/io/_XInputStream.java238
-rw-r--r--qadevOOo/tests/java/ifc/io/_XMarkableStream.java188
-rw-r--r--qadevOOo/tests/java/ifc/io/_XObjectInputStream.java165
-rw-r--r--qadevOOo/tests/java/ifc/io/_XObjectOutputStream.java84
-rw-r--r--qadevOOo/tests/java/ifc/io/_XOutputStream.java170
-rw-r--r--qadevOOo/tests/java/ifc/io/_XPersistObject.java247
12 files changed, 2315 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/ifc/io/_XActiveDataControl.java b/qadevOOo/tests/java/ifc/io/_XActiveDataControl.java
new file mode 100644
index 000000000..9ac7c7308
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XActiveDataControl.java
@@ -0,0 +1,238 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import lib.MultiMethodTest;
+import lib.Status;
+import lib.StatusException;
+
+import com.sun.star.io.XActiveDataControl;
+import com.sun.star.io.XStreamListener;
+import com.sun.star.lang.EventObject;
+
+/**
+ * Testing <code>com.sun.star.io.XActiveDataControl</code>
+ * interface methods :
+ * <ul>
+ * <li><code> addListener()</code></li>
+ * <li><code> removeListener()</code></li>
+ * <li><code> start()</code></li>
+ * <li><code> terminate()</code></li>
+ * </ul> <p>
+ *
+ * Tests <code>XActiveDataControl</code> interface. First, it registers a listener
+ * and performs <code>start()</code> and <code>terminate()</code> calls. The
+ * events received in the listener are analyzed to verify the result.<p>
+ *
+ * @see com.sun.star.io.XActiveDataControl
+ */
+public class _XActiveDataControl extends MultiMethodTest {
+
+ /**
+ * Contains the object under test.
+ */
+ public XActiveDataControl oObj = null;
+
+ /**
+ * Indicates that the <code>XStreamListener.started()</code> method has
+ * been called.
+ */
+ private boolean startCalled = false;
+
+ /**
+ * Indicates that the <code>XStreamListener.terminated()</code> method has
+ * been called.
+ */
+ private boolean terminateCalled = false;
+
+ /**
+ * Indicates that the <code>XEventListener.closed()</code> method has
+ * been called.
+ */
+ private boolean closeCalled = false;
+
+ /**
+ * Indicates that the <code>XStreamListener.error()</code> method has
+ * been called.
+ */
+ private boolean errorCalled = false;
+
+ /**
+ * Contains the error, if <code>XStreamListener.error(Object error)</code>
+ * method was called.
+ */
+ private Object error;
+
+ /**
+ * Indicates that the <code>XEventListener.disposing()</code> method has
+ * been called.
+ */
+ private boolean smthngElseCalled = false;
+
+ /**
+ * The listener is used to verify results of the methods.
+ */
+ private final TestStreamListener listener = new TestStreamListener();
+
+ /**
+ * XStreamListener implementation. Sets variables
+ * (<cod>startedCalled</code>, <code>terminatedCalled</code>, etc.) to
+ * <tt>true</tt> if the appropriate method was called (for example, if
+ * <code>started()</code> was called, the <code>startedCalled</code>
+ * field is set).
+ */
+ private class TestStreamListener implements XStreamListener {
+ public void started() {
+ startCalled = true ;
+ }
+ public void terminated() {
+ terminateCalled = true ;
+ }
+ public void error(Object e) {
+ error = e;
+ errorCalled = true ;
+ }
+ public void closed() {
+ closeCalled = true ;
+ }
+ public void disposing(EventObject e) {
+ smthngElseCalled = true ;
+ }
+
+ }
+
+ /**
+ * Tests <code>addListener()</code>. The verification is performed later, in
+ * <code>_terminate()</code> method.
+ */
+ public void _addListener() {
+ oObj.addListener(listener);
+ }
+
+ /**
+ * Starts the data activity (e.g. data pump). Verification is performed
+ * later, in <code>_terminate()</code> method.
+ */
+ public void _start() {
+ executeMethod("addListener()");
+
+ oObj.start();
+
+ // waiting a little bit for data transferred
+ util.utils.pause(200);
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ throw new StatusException(e, Status.failed(e.getMessage()));
+ }
+ }
+
+ /**
+ * Tests <code>removeListener()</code>. Before, it ensures that other
+ * tests are performed and that <code>addListener()</code> is okay. Then,
+ * calls <code>XActiveDataControl.start()</code> and checks that no method
+ * of the listener was called.
+ */
+ public void _removeListener() {
+ // performing other tests before, so, that don't break them
+ try {
+ executeMethod("terminate()");
+ } catch (StatusException e) {
+ // the result doesn't matter
+ }
+
+ // check that addListener() is okay
+ requiredMethod("addListener()");
+
+ // clearing previous records
+ startCalled = false;
+ terminateCalled = false;
+ errorCalled = false;
+ error = null;
+ smthngElseCalled = false;
+
+ // removing the listener
+ oObj.removeListener(listener);
+
+ // starting the activity
+ oObj.start();
+
+ // wait a little bit to allow for listeners to be called
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ throw new StatusException(e, Status.failed(e.getMessage()));
+ }
+
+ // check that no removed listener's method was called
+ tRes.tested("removeListener()",!startCalled &&
+ !terminateCalled && !errorCalled && !smthngElseCalled) ;
+ }
+
+ /**
+ * Tests <code>terminate()</code>. First, ensures that <code>start()</code>
+ * has been called. Then, verifies <code>start()</code>,
+ * <code>addListener()</code> and <code>terminate()</code> results, by
+ * checking that the appropriate listener's methods have been called.
+ */
+ public void _terminate() {
+ // ensuring that the activity has been started
+ executeMethod("start()");
+
+ // terminating the activity
+ oObj.terminate();
+
+ // waiting a little bit for listeners to be called
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ throw new StatusException(e, Status.failed(e.getMessage()));
+ }
+
+ // check, if any error occurred
+ if (errorCalled) {
+ log.println("Unexpected error " + error);
+ ((Exception)error).printStackTrace(log);
+ }
+
+ // verification of start() method - startedCalled method should be
+ // called
+ if (!tRes.tested("start()", startCalled)) {
+ log.println("XStreamListener.started() was not called()");
+ }
+
+ // check that any listener method is called
+ tRes.tested("addListener()", startCalled ||
+ terminateCalled || errorCalled || smthngElseCalled);
+
+ // checking that terminated() has been called or streams were closed
+ // before terminate() call, in this case termination has no sense.
+ tRes.tested("terminate()", terminateCalled || closeCalled);
+ }
+
+ /**
+ * Disposes the test environment, since it is used.
+ */
+ @Override
+ public void after() {
+ this.disposeEnvironment();
+ }
+}
+
+
diff --git a/qadevOOo/tests/java/ifc/io/_XActiveDataSink.java b/qadevOOo/tests/java/ifc/io/_XActiveDataSink.java
new file mode 100644
index 000000000..ec1dad459
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XActiveDataSink.java
@@ -0,0 +1,104 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import lib.MultiMethodTest;
+
+import com.sun.star.io.XActiveDataSink;
+import com.sun.star.io.XInputStream;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+/**
+* Testing <code>com.sun.star.io.XActiveDataSink</code>
+* interface methods :
+* <ul>
+* <li><code> setInputStream()</code></li>
+* <li><code> getInputStream()</code></li>
+* </ul> <p>
+* Test is <b> NOT </b> multithread compliant. <p>
+*
+* This test needs the following object relations :
+* <ul>
+* <li> <code>'InputStream'</code>
+* (of type <code>com.sun.star.io.XInputStream</code>):
+* acceptable input stream which can be set by <code>setInputStream</code> </li>
+* <ul> <p>
+*
+* After test completion object environment has to be recreated.
+* @see com.sun.star.io.XActiveDataSink
+*/
+public class _XActiveDataSink extends MultiMethodTest {
+
+ public XActiveDataSink oObj = null;
+
+ private XInputStream iStream = null;
+
+ /**
+ * Take the XInputStream from the environment for setting and getting
+ */
+ @Override
+ public void before() {
+ XInterface x = (XInterface)tEnv.getObjRelation("InputStream");
+ iStream = UnoRuntime.queryInterface
+ (XInputStream.class, x) ;
+ }
+
+ /**
+ * Just sets new input stream. <p>
+ * Has <b>OK</b> status if no runtime exceptions occurred.
+ */
+ public void _setInputStream() {
+ oObj.setInputStream(iStream) ;
+
+ tRes.tested("setInputStream()", true) ;
+ }
+
+ /**
+ * First retrieves current input stream, then sets to new
+ * input stream (if old was <code>null</code>) or to null.
+ * Then input stream retrieved again and checked to be not
+ * equal to the old one. <p>
+ * Has <b>OK</b> status if old and new streams retrieved are
+ * not equal. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> setInputStream() </code> : to be sure the method
+ * works without exceptions. </li>
+ * </ul>
+ */
+ public void _getInputStream() {
+ requiredMethod("setInputStream()") ;
+
+ Object oldStream = oObj.getInputStream() ;
+ XInputStream newStream = oldStream == null ? iStream : null ;
+
+ oObj.setInputStream(newStream) ;
+ Object getStream = oObj.getInputStream() ;
+
+ tRes.tested("getInputStream()", getStream != oldStream) ;
+ }
+
+ @Override
+ public void after() {
+ this.disposeEnvironment() ;
+ }
+}
+
+
diff --git a/qadevOOo/tests/java/ifc/io/_XActiveDataSource.java b/qadevOOo/tests/java/ifc/io/_XActiveDataSource.java
new file mode 100644
index 000000000..5cd2dd3ef
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XActiveDataSource.java
@@ -0,0 +1,97 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import lib.MultiMethodTest;
+
+import com.sun.star.io.XActiveDataSource;
+import com.sun.star.io.XOutputStream;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+/**
+* Testing <code>com.sun.star.io.XActiveDataSource</code>
+* interface methods:
+* <ul>
+* <li><code>setOutputStream()</code></li>
+* <li><code>getOutputStream()</code></li>
+* </ul> <p>
+*
+* This test needs the following object relations :
+* <ul>
+* <li> <code>'OutputStream'</code>
+* (of type <code>com.sun.star.io.OutputStream</code>):
+* acceptable output stream which can be set by <code>setOutputStream</code> </li>
+* <ul> <p>
+*
+* After test completion object environment has to be recreated.
+* @see com.sun.star.io.XActiveDataSource
+* @see com.sun.star.io.XOutputStream
+*/
+public class _XActiveDataSource extends MultiMethodTest {
+
+ public XActiveDataSource oObj = null;
+
+ private XOutputStream oStream = null;
+
+ /**
+ * Take the XOutputStream from the environment for setting and getting.
+ */
+ @Override
+ public void before() {
+ XInterface x = (XInterface)tEnv.getObjRelation("OutputStream");
+ oStream = UnoRuntime.queryInterface
+ (XOutputStream.class, x) ;
+ }
+
+ /**
+ * Test calls the method using interface <code>XOutputStream</code>
+ * received in method <code>before()</code> as parameter. <p>
+ * Has <b> OK </b> status if the method successfully returns. <p>
+ */
+ public void _setOutputStream() {
+ oObj.setOutputStream(oStream);
+ tRes.tested("setOutputStream()", true);
+ }
+
+ /**
+ * Test calls the method and compares returned value with value that was
+ * set in the method <code>setOutputStream()</code>. <p>
+ * Has <b> OK </b> status if values are equal. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> setOutputStream() </code></li>
+ * </ul>
+ */
+ public void _getOutputStream() {
+ requiredMethod("setOutputStream()");
+
+ tRes.tested("getOutputStream()",
+ oStream.equals(oObj.getOutputStream()));
+ }
+
+ /**
+ * Forces object environment recreation.
+ */
+ @Override
+ public void after() {
+ this.disposeEnvironment() ;
+ }
+}
+
diff --git a/qadevOOo/tests/java/ifc/io/_XConnectable.java b/qadevOOo/tests/java/ifc/io/_XConnectable.java
new file mode 100644
index 000000000..8efb86def
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XConnectable.java
@@ -0,0 +1,125 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import lib.MultiMethodTest;
+
+import com.sun.star.io.XConnectable;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+/**
+* Testing <code>com.sun.star.io.XConnectable</code>
+* interface methods:
+* <ul>
+* <li><code>setPredecessor()</code></li>
+* <li><code>getPredecessor()</code></li>
+* <li><code>setSuccessor()</code></li>
+* <li><code>getSuccessor()</code></li>
+* </ul> <p>
+* This test needs the following object relations :
+* <ul>
+* <li> <code>'Connectable'</code> (supports the <code>XConnectable</code>
+* interface):
+* another object to connect </li>
+* </ul>
+* After test completion object environment has to be recreated.
+* @see com.sun.star.io.XConnectable
+*/
+public class _XConnectable extends MultiMethodTest {
+
+ public XConnectable oObj = null;
+
+ private XConnectable xConnect = null ;
+
+ /**
+ * Get another connectable object from object relations.
+ */
+ @Override
+ public void before() {
+ XInterface x = (XInterface)tEnv.getObjRelation("Connectable");
+ xConnect = UnoRuntime.queryInterface(
+ XConnectable.class, x) ;
+ }
+
+ /**
+ * Test calls the method using interface <code>XConnectable</code>
+ * received in method <code>before()</code> as parameter. <p>
+ * Has <b> OK </b> status if the method successfully returns. <p>
+ */
+ public void _setPredecessor() {
+ oObj.setPredecessor(xConnect) ;
+
+ tRes.tested("setPredecessor()", true) ;
+ }
+
+ /**
+ * Test calls the method and compares returned value with value that was
+ * set in the method <code>setPredecessor()</code>. <p>
+ * Has <b> OK </b> status if values are equal. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> setPredecessor() </code></li>
+ * </ul>
+ */
+ public void _getPredecessor() {
+ requiredMethod("setPredecessor()") ;
+
+ XConnectable gConnect = oObj.getPredecessor() ;
+
+ tRes.tested("getPredecessor()", xConnect.equals(gConnect)) ;
+ }
+
+ /**
+ * Test calls the method using interface <code>XConnectable</code>
+ * received in method <code>before()</code> as parameter. <p>
+ * Has <b> OK </b> status if the method successfully returns. <p>
+ */
+ public void _setSuccessor() {
+ oObj.setSuccessor(xConnect) ;
+
+ tRes.tested("setSuccessor()", true) ;
+ }
+
+ /**
+ * Test calls the method and compares returned value with value that was
+ * set in the method <code>setSuccessor()</code>. <p>
+ * Has <b> OK </b> status if values are equal. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> setSuccessor() </code></li>
+ * </ul>
+ */
+ public void _getSuccessor() {
+ requiredMethod("setSuccessor()") ;
+
+ XConnectable gConnect = oObj.getSuccessor() ;
+
+ tRes.tested("getSuccessor()", xConnect.equals(gConnect)) ;
+ }
+
+ /**
+ * Forces object environment recreation.
+ */
+ @Override
+ public void after() {
+ this.disposeEnvironment() ;
+ }
+}
+
diff --git a/qadevOOo/tests/java/ifc/io/_XDataInputStream.java b/qadevOOo/tests/java/ifc/io/_XDataInputStream.java
new file mode 100644
index 000000000..5ab320fa5
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XDataInputStream.java
@@ -0,0 +1,414 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import java.util.List;
+
+import lib.MultiMethodTest;
+import lib.Status;
+import lib.StatusException;
+
+import com.sun.star.io.XDataInputStream;
+import com.sun.star.io.XDataOutputStream;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+/**
+* Testing <code>com.sun.star.io.XDataInputStream</code>
+* interface methods:
+* <ul>
+* <li><code>readBoolean()</code></li>
+* <li><code>readByte()</code></li>
+* <li><code>readChar()</code></li>
+* <li><code>readShort()</code></li>
+* <li><code>readLong()</code></li>
+* <li><code>readHyper()</code></li>
+* <li><code>readFloat()</code></li>
+* <li><code>readDouble()</code></li>
+* <li><code>readUTF()</code></li>
+* </ul> <p>
+* This test needs the following object relations :
+* <ul>
+* <li> <code>'StreamData'</code> (of type <code>Vector</code>):
+* vector of data for comparing with data that obtained from stream </li>
+* <li> <code>'StreamWriter'</code> (of type <code>XDataOutputStream</code>):
+* a possibility to write values to the stream. </li>
+* <ul> <p>
+* After test completion object environment has to be recreated.
+* @see com.sun.star.io.XDataInputStream
+* @see java.util.Vector
+*/
+public class _XDataInputStream extends MultiMethodTest {
+
+ public XDataInputStream oObj = null;
+ public XDataOutputStream oStream = null;
+
+ // values that are written
+ private boolean writeBoolean;
+ private byte writeByte;
+ private char writeChar;
+ private double writeDouble;
+ private float writeFloat;
+ private long writeHyper;
+ private int writeLong;
+ private short writeShort;
+ private String writeUTF;
+
+
+ /**
+ * Retrieves relations. From relation 'StreamData' extracts
+ * data of different types and fills the appropriate variables.
+ * @throws StatusException If one of relations not found.
+ */
+ @Override
+ public void before(){
+
+ XInterface x = (XInterface)tEnv.getObjRelation("StreamWriter") ;
+ oStream = UnoRuntime.queryInterface(
+ XDataOutputStream.class, x);
+ List<Object> data = (List<Object>) tEnv.getObjRelation("StreamData") ;
+ if (data == null || oStream == null) {
+ throw new StatusException(Status.failed("Object relation not found."));
+ }
+
+ // extract data from vector
+ Object dataElem = null ;
+ for (int i = 0; i < data.size(); i++) {
+ dataElem = data.get(i) ;
+
+ if (dataElem instanceof Boolean) {
+ writeBoolean = ((Boolean)dataElem).booleanValue();
+ } else
+ if (dataElem instanceof Byte) {
+ writeByte = ((Byte)dataElem).byteValue();
+ } else
+ if (dataElem instanceof Character) {
+ writeChar = ((Character)dataElem).charValue();
+ } else
+ if (dataElem instanceof Short) {
+ writeShort = ((Short)dataElem).shortValue();
+ } else
+ if (dataElem instanceof Integer) {
+ writeLong = ((Integer)dataElem).intValue();
+ } else
+ if (dataElem instanceof Long) {
+ writeHyper = ((Long)dataElem).longValue();
+ } else
+ if (dataElem instanceof Float) {
+ writeFloat = ((Float)dataElem).floatValue();
+ } else
+ if (dataElem instanceof Double) {
+ writeDouble = ((Double)dataElem).doubleValue();
+ } else
+ if (dataElem instanceof String) {
+ writeUTF = (String)dataElem;
+ }
+ }
+ }
+
+ /**
+ * First writes a value to outStream then reads it from input. <p>
+ *
+ * Has <b> OK </b> status if read and written values are equal. <p>
+ */
+ public void _readBoolean() {
+ boolean res = true ;
+ try {
+ oStream.writeBoolean(writeBoolean);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ throw new StatusException("Can't write data to the stream", e);
+ }
+ byte readElem;
+ try {
+ readElem = oObj.readBoolean();
+ res = ((readElem != 0) == writeBoolean);
+
+ if (!res)
+ log.println("Must be read " +
+ writeBoolean +
+ " but was read " + (readElem != 0)) ;
+ } catch (com.sun.star.io.IOException e) {
+ log.println("Couldn't read Boolean from stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+
+ tRes.tested("readBoolean()", res) ;
+ }
+
+ /**
+ * First writes a value to outStream then reads it from input. <p>
+ *
+ * Has <b> OK </b> status if read and written values are equal. <p>
+ */
+ public void _readByte() {
+ boolean res = true ;
+ try {
+ oStream.writeByte(writeByte);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ throw new StatusException("Can't write data to the stream", e);
+ }
+ byte readElem;
+ try {
+ readElem = oObj.readByte() ;
+ res = (readElem == writeByte);
+
+ if (!res)
+ log.println("Must be read " +
+ writeByte +
+ " but was read " + readElem);
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't read Byte from stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+
+ tRes.tested("readByte()", res) ;
+ }
+
+ /**
+ * First writes a value to outStream then reads it from input. <p>
+ *
+ * Has <b> OK </b> status if read and written values are equal. <p>
+ */
+ public void _readChar() {
+ boolean res = true ;
+ try {
+ oStream.writeChar(writeChar);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ throw new StatusException("Can't write data to the stream", e);
+ }
+ char readElem;
+ try {
+ readElem = oObj.readChar() ;
+ res = (readElem == writeChar);
+
+ if (!res)
+ log.println("Must be read " +
+ writeChar +
+ " but was read " + readElem) ;
+ } catch( com.sun.star.io.IOException e ) {
+ log.println("Couldn't read Char from stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("readChar()", res);
+ }
+
+ /**
+ * First writes a value to outStream then reads it from input. <p>
+ *
+ * Has <b> OK </b> status if read and written values are equal. <p>
+ */
+ public void _readShort() {
+ boolean res = true ;
+ try {
+ oStream.writeShort(writeShort);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ throw new StatusException("Can't write data to the stream", e);
+ }
+ short readElem;
+ try {
+ readElem = oObj.readShort() ;
+ res = (readElem == writeShort);
+
+ if (!res)
+ log.println("Must be read " +
+ writeShort +
+ " but was read " + readElem) ;
+ } catch( com.sun.star.io.IOException e ) {
+ log.println("Couldn't read Short from stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("readShort()", res);
+ }
+
+ /**
+ * First writes a value to outStream then reads it from input. <p>
+ *
+ * Has <b> OK </b> status if read and written values are equal. <p>
+ */
+ public void _readLong() {
+ try {
+ oStream.writeLong(writeLong);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ throw new StatusException("Can't write data to the stream", e);
+ }
+ boolean res = true ;
+ int readElem;
+ try {
+ readElem = oObj.readLong() ;
+ res = (readElem == writeLong);
+
+ if (!res)
+ log.println("Must be read " +
+ writeLong +
+ " but was read " + readElem) ;
+ } catch( com.sun.star.io.IOException e ) {
+ log.println("Couldn't read Long from stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("readLong()", res);
+ }
+
+ /**
+ * First writes a value to outStream then reads it from input. <p>
+ *
+ * Has <b> OK </b> status if read and written values are equal. <p>
+ */
+ public void _readHyper() {
+ boolean res = true ;
+ try {
+ oStream.writeHyper(writeHyper);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ throw new StatusException("Can't write data to the stream", e);
+ }
+ long readElem;
+ try {
+ readElem = oObj.readHyper() ;
+ res = (readElem == writeHyper);
+
+ if (!res)
+ log.println("Must be read " +
+ writeHyper +
+ " but was read " + readElem) ;
+ } catch( com.sun.star.io.IOException e ) {
+ log.println("Couldn't read Hyper from stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("readHyper()", res);
+ }
+
+ /**
+ * First writes a value to outStream then reads it from input. <p>
+ *
+ * Has <b> OK </b> status if read and written values are equal. <p>
+ */
+ public void _readFloat() {
+ boolean res = true ;
+ try {
+ oStream.writeFloat(writeFloat);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ throw new StatusException("Can't write data to the stream", e);
+ }
+ float readElem;
+ try {
+ readElem = oObj.readFloat() ;
+ res = (readElem == writeFloat);
+
+ if (!res)
+ log.println("Must be read " +
+ writeFloat +
+ " but was read " + readElem) ;
+ } catch( com.sun.star.io.IOException e ) {
+ log.println("Couldn't read Float from stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("readFloat()", res);
+ }
+
+ /**
+ * First writes a value to outStream then reads it from input. <p>
+ *
+ * Has <b> OK </b> status if read and written values are equal. <p>
+ */
+ public void _readDouble() {
+ boolean res = true ;
+ try {
+ oStream.writeDouble(writeDouble);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ throw new StatusException("Can't write data to the stream", e);
+ }
+ double readElem;
+ try {
+ readElem = oObj.readDouble() ;
+ res = (readElem == writeDouble);
+
+ if (!res)
+ log.println("Must be read " +
+ writeDouble +
+ " but was read " + readElem) ;
+ } catch( com.sun.star.io.IOException e ) {
+ log.println("Couldn't read Double from stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("readDouble()", res);
+ }
+
+ /**
+ * First writes a value to outStream then reads it from input. <p>
+ *
+ * Has <b> OK </b> status if read and written values are equal. <p>
+ */
+ public void _readUTF() {
+ boolean res = true ;
+ try {
+ oStream.writeUTF(writeUTF);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ throw new StatusException("Can't write data to the stream", e);
+ }
+ String readElem;
+ try {
+ readElem = oObj.readUTF() ;
+ res = writeUTF.equals(readElem) ;
+
+ if (!res)
+ log.println("Must be read '" +
+ writeUTF +
+ "' but was read '" + readElem + "'") ;
+ } catch( com.sun.star.io.IOException e ) {
+ log.println("Couldn't read String from stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("readUTF()", res);
+ }
+
+ /**
+ * Forces object environment recreation.
+ */
+ @Override
+ public void after() {
+ try {
+ oStream.flush();
+ } catch (com.sun.star.io.NotConnectedException e) {
+ e.printStackTrace(log);
+ } catch (com.sun.star.io.BufferSizeExceededException e) {
+ e.printStackTrace(log);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ }
+ this.disposeEnvironment() ;
+ }
+}
+
diff --git a/qadevOOo/tests/java/ifc/io/_XDataOutputStream.java b/qadevOOo/tests/java/ifc/io/_XDataOutputStream.java
new file mode 100644
index 000000000..3ea11193d
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XDataOutputStream.java
@@ -0,0 +1,245 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import java.util.List;
+
+import lib.MultiMethodTest;
+
+import com.sun.star.io.XDataOutputStream;
+
+/**
+* Testing <code>com.sun.star.io.XDataOutputStream</code>
+* interface methods:
+* <ul>
+* <li><code>writeBoolean()</code></li>
+* <li><code>writeByte()</code></li>
+* <li><code>writeChar()</code></li>
+* <li><code>writeShort()</code></li>
+* <li><code>writeLong()</code></li>
+* <li><code>writeHyper()</code></li>
+* <li><code>writeFloat()</code></li>
+* <li><code>writeDouble()</code></li>
+* <li><code>writeUTF()</code></li>
+* </ul> <p>
+* This test needs the following object relations :
+* <ul>
+* <li> <code>'StreamData'</code> (of type <code>Vector</code>):
+* vector of data for writing to the stream </li>
+* <ul> <p>
+* After test completion object environment has to be recreated.
+* @see com.sun.star.io.XDataOutputStream
+*/
+public class _XDataOutputStream extends MultiMethodTest {
+
+ public XDataOutputStream oObj = null;
+
+ /**
+ * Retrieves object relation <code>'StreamData'</code>
+ * and executes methods of interface depending of data in stream.
+ * If relation or data of some type in stream not found then
+ * tests of corresponding methods are skipped.
+ */
+ @Override
+ public void before() throws RuntimeException {
+
+ List<Object> data = (List<Object>) tEnv.getObjRelation("StreamData") ;
+ if (data == null) {
+ throw new RuntimeException("Object relation 'StreamData' not found.");
+ }
+
+ // extract data from vector
+ Object dataElem = null ;
+ for (int i = 0; i < data.size(); i++) {
+ dataElem = data.get(i) ;
+
+ if (!(dataElem instanceof Boolean ||
+ dataElem instanceof Byte) ||
+ dataElem instanceof Character ||
+ dataElem instanceof Short ||
+ dataElem instanceof Integer ||
+ dataElem instanceof Float ||
+ dataElem instanceof Double) {
+ throw new RuntimeException("Object dataElem type not found.");
+ }
+ }
+ }
+
+ /**
+ * Test writes some data to stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _writeBoolean() {
+ boolean res = true;
+ try {
+ oObj.writeBoolean(true) ;
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't write Boolean to stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("writeBoolean()", res) ;
+ }
+
+ /**
+ * Test writes some data to stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _writeByte() {
+ boolean res = true;
+ try {
+ oObj.writeByte((byte) 123);
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't write Byte to stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("writeByte()", res);
+ }
+
+ /**
+ * Test writes some data to stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _writeChar() {
+ boolean res = true;
+ try {
+ oObj.writeChar((char)12345);
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't write Char to stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("writeChar()", res);
+ }
+
+ /**
+ * Test writes some data to stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _writeShort() {
+ boolean res = true;
+ try {
+ oObj.writeShort((short)12345) ;
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't write Short to stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("writeShort()", res);
+ }
+
+ /**
+ * Test writes some data to stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _writeLong() {
+ boolean res = true;
+ try {
+ oObj.writeLong(123456);
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't write Long to stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("writeLong()", res);
+ }
+
+ /**
+ * Test writes some data to stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _writeHyper() {
+ boolean res = true;
+ try {
+ oObj.writeHyper(123456789);
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't write Hyper to stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("writeHyper()", res);
+ }
+
+ /**
+ * Test writes some data to stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _writeFloat() {
+ boolean res = true;
+ try {
+ oObj.writeFloat((float)1.2345);
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't write Float to stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("writeFloat()", res);
+ }
+
+ /**
+ * Test writes some data to stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _writeDouble() {
+ boolean res = true;
+ try {
+ oObj.writeDouble(1.2345);
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't write Double to stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("writeDouble()", res);
+ }
+
+ /**
+ * Test writes some data to stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _writeUTF() {
+ boolean res = true;
+ try {
+ oObj.writeUTF("XDataOutputStream") ;
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't write String to stream");
+ e.printStackTrace(log);
+ res = false;
+ }
+ tRes.tested("writeUTF()", res);
+ }
+
+ /**
+ * Forces object environment recreation.
+ */
+ @Override
+ public void after() {
+ this.disposeEnvironment() ;
+ }
+}
+
diff --git a/qadevOOo/tests/java/ifc/io/_XInputStream.java b/qadevOOo/tests/java/ifc/io/_XInputStream.java
new file mode 100644
index 000000000..90ee86afb
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XInputStream.java
@@ -0,0 +1,238 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import lib.MultiMethodTest;
+import lib.Status;
+
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XOutputStream;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+/**
+* Testing <code>com.sun.star.io.XInputStream</code>
+* interface methods:
+* <ul>
+* <li><code>readBytes()</code></li>
+* <li><code>readSomeBytes()</code></li>
+* <li><code>skipBytes()</code></li>
+* <li><code>available()</code></li>
+* <li><code>closeInput()</code></li>
+* </ul> <p>
+* This test needs the following object relations :
+* <ul>
+* <li> <code>'StreamWriter'</code>:
+* object that supports interface <code>XOutputStream</code>;
+* a stream to write data to</li>
+* <li> <code>'ByteData'</code> (of type <code>byte []</code>):
+* data to write to the stream</li>
+* <ul> <p>
+
+* @see com.sun.star.io.XInputStream
+*/
+public class _XInputStream extends MultiMethodTest {
+
+ public XInputStream oObj = null;
+ public XOutputStream oStream = null;
+
+ byte[] bytes = null;
+
+ int bytesReady = 0 ;
+
+ /**
+ * Before the test, the stream writer and the data are extracted from
+ * the object relations and the data is written to the stream.
+ */
+ @Override
+ public void before() {
+ XInterface x = (XInterface)tEnv.getObjRelation("StreamWriter");
+ oStream = UnoRuntime.queryInterface(
+ XOutputStream.class, x) ;
+ bytes = (byte[])tEnv.getObjRelation("ByteData");
+ try {
+ oStream.writeBytes(bytes);
+ }
+ catch(com.sun.star.io.NotConnectedException e) {}
+ catch(com.sun.star.io.BufferSizeExceededException e) {}
+ catch(com.sun.star.io.IOException e) {}
+ }
+
+ /**
+ * After the test, the stream writer is closed and the
+ * environment is disposed.
+ */
+ @Override
+ public void after() {
+ try {
+ oStream.flush();
+ oStream.closeOutput();
+ }
+ catch(com.sun.star.io.NotConnectedException e) {}
+ catch(com.sun.star.io.BufferSizeExceededException e) {}
+ catch(com.sun.star.io.IOException e) {}
+ this.disposeEnvironment();
+ }
+ /**
+ * Test calls the method and stores number of available bytes. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _available() {
+ boolean result = true ;
+ try {
+ bytesReady = oObj.available() ;
+ log.println("Bytes available :" + bytesReady) ;
+ } catch (com.sun.star.io.IOException e){
+ e.printStackTrace(log) ;
+ result = false ;
+ }
+
+ tRes.tested("available()", result) ;
+ }
+
+ /**
+ * Test reads one byte from stream. If no bytes available
+ * then test of method is skipped. <p>
+ * Has <b> OK </b> status if returned value equal to number of read bytes,
+ * no exceptions were thrown and read data is not null. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> available() </code> : to have available number
+ * of bytes in stream </li>
+ * </ul>
+ */
+ public void _readBytes() {
+ requiredMethod("available()") ;
+ boolean result ;
+
+ if (bytesReady-- > 0) {
+ try {
+ byte[][] data = new byte[1][1] ;
+ int read = oObj.readBytes(data, 1) ;
+
+ result = read == 1 &&
+ data.length == 1 ;
+ } catch (com.sun.star.io.IOException e){
+ e.printStackTrace(log) ;
+ result = false ;
+ }
+
+ tRes.tested("readBytes()", result) ;
+ } else {
+ log.println("No more bytes available in the stream");
+ tRes.tested("readBytes()", Status.skipped(false));
+ }
+ }
+
+ /**
+ * Test reads one byte from stream. If no bytes available
+ * then test of method is skipped. <p>
+ * Has <b> OK </b> status if returned value equal to number of read bytes,
+ * no exceptions were thrown and read data is not null. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> available() </code> : to have available number
+ * of bytes in stream </li>
+ * </ul>
+ */
+ public void _readSomeBytes() {
+ requiredMethod("available()") ;
+ boolean result ;
+
+ if (bytesReady-- > 0) {
+ try {
+ byte[][] data = new byte [1][1] ;
+ int read = oObj.readSomeBytes(data, 1) ;
+
+ result = read == 1 &&
+ data.length == 1 ;
+ } catch (com.sun.star.io.IOException e){
+ e.printStackTrace(log) ;
+ result = false ;
+ }
+ tRes.tested("readSomeBytes()", result) ;
+ } else {
+ log.println("No more bytes available in the stream") ;
+ tRes.tested("readBytes()", Status.skipped(false));
+ }
+ }
+
+ /**
+ * Test skips one byte from stream. If no bytes available
+ * then test of method is skipped. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> available() </code> : to have available number
+ * of bytes in stream </li>
+ * </ul>
+ */
+ public void _skipBytes() {
+ requiredMethod("available()") ;
+ boolean result ;
+
+ if (bytesReady-- > 0) {
+ try {
+ oObj.skipBytes(1) ;
+
+ result = true ;
+ } catch (com.sun.star.io.IOException e){
+ e.printStackTrace(log) ;
+ result = false ;
+ }
+ tRes.tested("skipBytes()", result) ;
+ } else {
+ log.println("No more bytes available in the stream") ;
+ tRes.tested("readBytes()", Status.skipped(false));
+ }
+ }
+
+ /**
+ * Test calls the method and forces object environment recreation. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ * The following method tests are to be executed before :
+ * <ul>
+ * <li> <code> available() </code> </li>
+ * <li> <code> readBytes() </code> </li>
+ * <li> <code> readSomeBytes() </code> </li>
+ * <li> <code> skipBytes() </code> </li>
+ * </ul>
+ */
+ public void _closeInput() {
+ executeMethod("available()") ;
+ executeMethod("readBytes()") ;
+ executeMethod("readSomeBytes()") ;
+ executeMethod("skipBytes()") ;
+
+ boolean result = true ;
+ try {
+ oObj.closeInput() ;
+ } catch (com.sun.star.io.IOException e){
+ e.printStackTrace(log) ;
+ result = false ;
+ }
+
+ tRes.tested("closeInput()", result) ;
+ this.disposeEnvironment() ;
+ }
+}
+
diff --git a/qadevOOo/tests/java/ifc/io/_XMarkableStream.java b/qadevOOo/tests/java/ifc/io/_XMarkableStream.java
new file mode 100644
index 000000000..8c0888739
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XMarkableStream.java
@@ -0,0 +1,188 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import lib.MultiMethodTest;
+
+import com.sun.star.io.XMarkableStream;
+
+/**
+* Testing <code>com.sun.star.io.XMarkableStream</code>
+* interface methods:
+* <ul>
+* <li><code>createMark()</code></li>
+* <li><code>deleteMark()</code></li>
+* <li><code>jumpToFurthest()</code></li>
+* <li><code>jumpToMark()</code></li>
+* <li><code>offsetToMark()</code></li>
+* </ul> <p>
+* @see com.sun.star.io.XMarkableStream
+*/
+public class _XMarkableStream extends MultiMethodTest {
+
+ public XMarkableStream oObj = null;
+ private int mark = -1 ;
+
+ /**
+ * Test creates mark and stores it. <p>
+ * Has <b> OK </b> status if no exceptions were thrown
+ * and returned isn't less than zero. <p>
+ */
+ public void _createMark() {
+ boolean res;
+ try {
+ mark = oObj.createMark() ;
+ res = mark >= 0;
+ } catch (com.sun.star.io.IOException e) {
+ log.println("Couldn't create mark");
+ e.printStackTrace(log);
+ res = false;
+ }
+
+ tRes.tested("createMark()", res);
+ }
+
+ /**
+ * Test deletes the mark that was created by method <code>createMark()
+ * </code>.<p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> createMark() </code> : to have mark </li>
+ * </ul>
+ * The following method tests are to be executed before :
+ * <ul>
+ * <li> <code> jumpToFurthest() </code></li>
+ * <li> <code> jumpToMark() </code></li>
+ * <li> <code> offsetToMark() </code></li>
+ * </ul>
+ */
+ public void _deleteMark() {
+ requiredMethod("createMark()") ;
+
+ executeMethod("jumpToFurthest()") ;
+ executeMethod("jumpToMark()") ;
+ executeMethod("offsetToMark()") ;
+
+ boolean res;
+ try {
+ oObj.deleteMark(mark);
+ res = true;
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't delete mark");
+ e.printStackTrace(log);
+ res = false;
+ } catch(com.sun.star.lang.IllegalArgumentException e) {
+ log.println("Couldn't delete mark");
+ e.printStackTrace(log);
+ res = false;
+ }
+
+ tRes.tested("deleteMark()", res) ;
+ }
+
+ /**
+ * Test calls the method. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> createMark() </code></li>
+ * </ul>
+ */
+ public void _jumpToFurthest() {
+ requiredMethod("createMark()") ;
+
+ boolean res;
+ try {
+ oObj.jumpToFurthest() ;
+ res = true;
+ } catch (com.sun.star.io.IOException e) {
+ log.println("Couldn't jump to furthest");
+ e.printStackTrace(log);
+ res = false;
+ }
+
+ tRes.tested("jumpToFurthest()", res) ;
+ }
+
+ /**
+ * Test jumps to mark that was created by method <code>createMark()</code>.
+ * <p>Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> jumpToFurthest() </code> : for the right order of tests
+ * execution </li>
+ * </ul>
+ */
+ public void _jumpToMark() {
+ requiredMethod("jumpToFurthest()") ;
+ boolean res;
+
+ try {
+ oObj.jumpToMark(mark) ;
+ res = true;
+ } catch(com.sun.star.lang.IllegalArgumentException e) {
+ log.println("Couldn't jump to mark");
+ e.printStackTrace(log);
+ res = false;
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't jump to mark");
+ e.printStackTrace(log);
+ res = false;
+ }
+
+ tRes.tested("jumpToMark()", res) ;
+ }
+
+ /**
+ * Test obtains offset to mark that was created by
+ * method <code>createMark()</code> and checks returned value.<p>
+ * Has <b> OK </b> status if returned value is equal to zero
+ * and no exceptions were thrown. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> jumpToMark() </code> : to have current position at
+ * the mark position </li>
+ * </ul>
+ */
+ public void _offsetToMark() {
+
+ requiredMethod("jumpToMark()") ;
+
+ boolean res;
+ try {
+ int offset = oObj.offsetToMark(mark);
+ res = offset == 0;
+ } catch(com.sun.star.lang.IllegalArgumentException e) {
+ log.println("Couldn't get offset to mark");
+ e.printStackTrace(log);
+ res = false;
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't get offset to mark");
+ e.printStackTrace(log);
+ res = false;
+ }
+
+ tRes.tested("offsetToMark()", res);
+ }
+}
+
diff --git a/qadevOOo/tests/java/ifc/io/_XObjectInputStream.java b/qadevOOo/tests/java/ifc/io/_XObjectInputStream.java
new file mode 100644
index 000000000..bfcb3f6b3
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XObjectInputStream.java
@@ -0,0 +1,165 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import lib.MultiMethodTest;
+import lib.Status;
+import util.ValueComparer;
+
+import com.sun.star.beans.Property;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.io.XObjectInputStream;
+import com.sun.star.io.XObjectOutputStream;
+import com.sun.star.io.XPersistObject;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+* Testing <code>com.sun.star.io.XObjectInputStream</code>
+* interface methods:
+* <ul>
+* <li><code>readObject()</code></li>
+* </ul> <p>
+* This test needs the following object relations :
+* <ul>
+* <li> <code>'PersistObject'</code> (of type <code>Object</code>):
+* object that supports interface <code>XPersistObject</code> </li>
+* <ul> <p>
+* After test completion object environment has to be recreated.
+* @see com.sun.star.io.XObjectInputStream
+* @see com.sun.star.io.XPersistObject
+*/
+public class _XObjectInputStream extends MultiMethodTest {
+
+ public XObjectInputStream oObj = null;
+
+ /**
+ * Test reads persist object from stream and compares properties
+ * of the object with properties of persist object obtained
+ * from relation <code>'PersistObject'</code> <p>
+ * Has <b> OK </b> status if returned value isn't null and values
+ * of objects properties are equal. <p>
+ */
+ public void _readObject() {
+ Object objWrite = tEnv.getObjRelation("PersistObject") ;
+ if (objWrite == null) {
+ log.println("PersistObject not found in relations") ;
+ tRes.tested("readObject()", false) ;
+ return ;
+ }
+
+ // write the object
+ try {
+ XObjectOutputStream oStream = (XObjectOutputStream)
+ tEnv.getObjRelation("StreamWriter");
+ oStream.writeObject((XPersistObject)objWrite);
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't write object to stream");
+ e.printStackTrace(log);
+ tRes.tested("readObject()", Status.skipped(false));
+ return;
+ }
+
+ Object objRead = null ;
+ try {
+ objRead = oObj.readObject() ;
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't read object from stream");
+ e.printStackTrace(log);
+ tRes.tested("readObject()", false) ;
+ return ;
+ }
+
+ if (objRead == null) {
+ log.println("No object was read.") ;
+ tRes.tested("readObject()", false) ;
+ return ;
+ }
+
+ XPropertySet props1 = null ;
+ XPropertySet props2 = null ;
+
+ props1 = UnoRuntime.queryInterface
+ (XPropertySet.class, objRead) ;
+
+ props2 = UnoRuntime.queryInterface
+ (XPropertySet.class, objWrite) ;
+
+ if (props1 == null) {
+ log.println("Object read doesn't implement XPropertySet") ;
+ tRes.tested("readObject()", false) ;
+ return ;
+ }
+ if (props2 == null) {
+ log.println("Object written doesn't implement XPropertySet") ;
+ tRes.tested("readObject()", false) ;
+ return ;
+ }
+
+ tRes.tested("readObject()",
+ compareProperties(props1, props2)) ;
+ }
+
+ protected boolean compareProperties(XPropertySet props1,
+ XPropertySet props2) {
+
+ Property[] p1 = props1.getPropertySetInfo().getProperties() ;
+ Property[] p2 = props2.getPropertySetInfo().getProperties() ;
+
+ if (p1.length != p2.length) {
+ log.println("Number of properties differs") ;
+ return false ;
+ }
+
+ boolean result = true ;
+
+ for (int i = 0; i < p1.length; i++) {
+ String propName = p1[i].Name ;
+
+ log.print("Comparing property '" + propName + "' ...") ;
+ boolean res = false ;
+ try {
+ res = ValueComparer.equalValue
+ (props1.getPropertyValue(propName),
+ props2.getPropertyValue(propName)) ;
+ } catch (com.sun.star.beans.UnknownPropertyException e) {
+ log.println("Not found !") ;
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ log.println(e) ;
+ }
+
+ if (res)
+ log.println("OK.") ;
+ else
+ log.println("Different !") ;
+
+ result &= res ;
+ }
+
+ return result ;
+ }
+
+ /**
+ * Forces object environment recreation.
+ */
+ @Override
+ public void after() {
+ this.disposeEnvironment() ;
+ }
+}
+
diff --git a/qadevOOo/tests/java/ifc/io/_XObjectOutputStream.java b/qadevOOo/tests/java/ifc/io/_XObjectOutputStream.java
new file mode 100644
index 000000000..86efebe52
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XObjectOutputStream.java
@@ -0,0 +1,84 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import lib.MultiMethodTest;
+import lib.Status;
+import lib.StatusException;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.io.XObjectInputStream;
+import com.sun.star.io.XObjectOutputStream;
+import com.sun.star.io.XPersistObject;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+* Testing <code>com.sun.star.io.XObjectOutputStream</code>
+* interface methods:
+* <ul>
+* <li><code>writeObject()</code></li>
+* </ul> <p>
+* This test needs the following object relations :
+* <ul>
+* <li> <code>'InputStream'</code> (of type <code>XObjectInputStream</code>)</li>
+* persist object for testing of write to stream</ul>
+* @see com.sun.star.io.XObjectInputStream
+* @see com.sun.star.io.XObjectOutputStream
+* @see com.sun.star.io.XPersistObject
+*/
+public class _XObjectOutputStream extends MultiMethodTest {
+
+ public XObjectOutputStream oObj = null;
+
+ /**
+ * Test creates persist object, sets label of object,
+ * calls the method for created persist object
+ * and checks label of object that was read from input stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and labels are equals. <p>
+ */
+ public void _writeObject() throws Exception {
+ XObjectInputStream oInStream = (XObjectInputStream)
+ tEnv.getObjRelation("InputStream");
+ if (oInStream == null) throw
+ new StatusException(Status.failed("Relation 'InputStream' failed"));
+
+ // use own implementation of XPersistObject, so test runs
+ // without an office
+ XPersistObject objWrite = (XPersistObject)
+ tEnv.getObjRelation("PersistObject");
+ if (objWrite == null) throw
+ new StatusException(Status.failed("Relation 'PersistObject' failed"));
+
+ XPropertySet propObjWrite = UnoRuntime.queryInterface(XPropertySet.class, objWrite);
+
+ // This XPersistObject has a property called 'String'
+ propObjWrite.setPropertyValue("String", "XObjectOutputStream");
+
+ log.println("Writing object with label 'XObjectOutputStream'");
+ oObj.writeObject(objWrite);
+ XPersistObject readObj = oInStream.readObject();
+ XPropertySet propSet = UnoRuntime.queryInterface(XPropertySet.class, readObj);
+ String label = (String)propSet.getPropertyValue("String");
+ log.println("Object with label '" + label + "' was read");
+
+ tRes.tested("writeObject()", label.equals("XObjectOutputStream")) ;
+ }
+}
+
diff --git a/qadevOOo/tests/java/ifc/io/_XOutputStream.java b/qadevOOo/tests/java/ifc/io/_XOutputStream.java
new file mode 100644
index 000000000..9f619f383
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XOutputStream.java
@@ -0,0 +1,170 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import lib.MultiMethodTest;
+import lib.Status;
+import lib.StatusException;
+
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XOutputStream;
+
+/**
+* Testing <code>com.sun.star.io.XOutputStream</code>
+* interface methods:
+* <ul>
+* <li><code>writeBytes()</code></li>
+* <li><code>flush()</code></li>
+* <li><code>closeOutput()</code></li>
+* </ul> <p>
+* This test needs the following object relations :
+* <ul>
+* <li> <code>'ByteData'</code> : Data that is written on the stream.
+* </li>
+* <li> <code>'XOutputStream.StreamChecker'</code> : <code>
+* _XOutputStream.StreamChecker</code> interface implementation
+* which can reset streams and return input stream for check if the
+* data was successfully written.</li>
+* <ul> <p>
+* After test completion object environment has to be recreated.
+* @see com.sun.star.io.XOutputStream
+*/
+public class _XOutputStream extends MultiMethodTest {
+
+ public XOutputStream oObj = null;
+ StreamChecker checker = null;
+ byte[] data = null;
+
+ public interface StreamChecker {
+ XInputStream getInStream();
+ void resetStreams();
+ }
+
+ @Override
+ protected void before() {
+ checker = (StreamChecker)
+ tEnv.getObjRelation("XOutputStream.StreamChecker");
+ if (checker == null) throw
+ new StatusException(Status.failed(
+ "Couldn't get relation 'XOutputStream.StreamChecker'"));
+
+ data = (byte[])tEnv.getObjRelation("ByteData");
+ if (data == null) throw
+ new StatusException(Status.failed(
+ "Couldn't get relation 'ByteData'"));
+ }
+ /**
+ * Test writes data to stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ */
+ public void _writeBytes() {
+ boolean res = true;
+ try {
+ oObj.writeBytes(data);
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log) ;
+ res = false;
+ }
+
+ byte[][] readData = new byte[1][data.length];
+ XInputStream xInStream = checker.getInStream();
+ if (xInStream != null) {
+ try {
+ xInStream.readBytes(readData, data.length);
+ } catch(com.sun.star.io.IOException e) {
+ log.println("Couldn't read data:" + e);
+ res = false;
+ }
+ } else {
+ res = false;
+ }
+
+ for(int i = 0; i < readData[0].length; i++) {
+ log.println("Expected: "+data[i]+", actual is "+readData[0][i]);
+ res &= readData[0][i] == data[i];
+ }
+
+ tRes.tested("writeBytes()", res);
+ }
+
+ /**
+ * Test flushes out data from stream. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> writeBytes() </code></li>
+ * </ul>
+ */
+ public void _flush() {
+ requiredMethod("writeBytes()");
+
+ boolean res;
+ try {
+ oObj.flush();
+ res = true;
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log) ;
+ res = false;
+ }
+
+ tRes.tested("flush()", res);
+ }
+
+ /**
+ * Test calls the method. <p>
+ * Has <b> OK </b> status if the method successfully returns
+ * and no exceptions were thrown. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> writeBytes() </code></li>
+ * </ul>
+ * The following method tests are to be executed before :
+ * <ul>
+ * <li><code> flush() </code></li>
+ * </ul>
+ */
+ public void _closeOutput() {
+ requiredMethod("writeBytes()");
+ executeMethod("flush()");
+
+ boolean res;
+ try {
+ oObj.closeOutput();
+ res = true;
+ } catch (com.sun.star.io.IOException e) {
+ e.printStackTrace(log);
+ res = false;
+ }
+
+ log.println("This method is called in main module");
+
+ tRes.tested("closeOutput()", res);
+ }
+
+ /**
+ * Forces object environment recreation.
+ */
+ @Override
+ public void after() {
+ this.disposeEnvironment() ;
+ }
+}
+
diff --git a/qadevOOo/tests/java/ifc/io/_XPersistObject.java b/qadevOOo/tests/java/ifc/io/_XPersistObject.java
new file mode 100644
index 000000000..083d0f71c
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/io/_XPersistObject.java
@@ -0,0 +1,247 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package ifc.io;
+
+import lib.MultiMethodTest;
+import util.ValueComparer;
+import util.dbg;
+import util.utils;
+
+import com.sun.star.beans.Property;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.io.XActiveDataSink;
+import com.sun.star.io.XActiveDataSource;
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XObjectInputStream;
+import com.sun.star.io.XObjectOutputStream;
+import com.sun.star.io.XOutputStream;
+import com.sun.star.io.XPersistObject;
+import com.sun.star.uno.UnoRuntime;
+
+
+/**
+* Testing <code>com.sun.star.io.XPersistObject</code>
+* interface methods :
+* <ul>
+* <li><code> getServiceName()</code></li>
+* <li><code> write()</code></li>
+* <li><code> read()</code></li>
+* </ul> <p>
+* This test need the following object relations :
+* <ul>
+* <li> <code>'OBJNAME'</code> : <code>String</code> value that
+* contains service name which object represents.</li>
+* <ul> <p>
+* Test is <b> NOT </b> multithread compliant. <p>
+* After test completion object environment has to be recreated.
+* @see com.sun.star.io.XPersistObject
+* @see com.sun.star.io.XObjectInputStream
+* @see com.sun.star.io.XObjectOutputStream
+*/
+public class _XPersistObject extends MultiMethodTest {
+
+ public XPersistObject oObj = null;
+ XObjectInputStream iStream = null;
+ XObjectOutputStream oStream = null;
+ String sname = null;
+
+ boolean result = true;
+
+
+ /**
+ * Test calls the method and checks return value. <p>
+ * Has <b> OK </b> status if the method returns proper service names
+ * which is equal to <code>'OBJNAME'</code> relation value. <p>
+ */
+ public void _getServiceName() {
+ result = true;
+ sname = oObj.getServiceName();
+ log.println("Method returned '" + sname + "'") ;
+ String objName = (String)tEnv.getObjRelation("OBJNAME");
+ if (objName == null) {
+ log.println("No OBJNAME relation!");
+ result = false;
+ } else {
+ result &= sname.equals(objName);
+ if (!result)
+ log.println("Name of object must be '" + objName +
+ "' but returned name is '" + sname +"'");
+ }
+
+ tRes.tested("getServiceName()", result);
+ }
+
+ /**
+ * Creates service get by <code>getServiceName</code> method and tries
+ * to read object written to stream by <code>write</code> method test.
+ * Then properties of object written and object read are compared. <p>
+ * Has <b>OK</b> status if all properties of two objects are equal
+ * and no exceptions were thrown. <p>
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> getServiceName() </code> : to have service name
+ * which has to be created </li>
+ * <li> <code> write() </code> : to write object tested into stream</li>
+ * </ul>
+ */
+ public void _read() {
+ requiredMethod("getServiceName()");
+ requiredMethod("write()") ;
+
+ boolean bResult = true;
+
+ try {
+ Object noPS = tEnv.getObjRelation("noPS");
+ if ( noPS == null) {
+ XPropertySet objps = UnoRuntime.queryInterface(
+ XPropertySet.class, oObj);
+ XPropertySetInfo objpsi = objps.getPropertySetInfo();
+ Property[] objprops = objpsi.getProperties();
+
+ Object oCopy = tParam.getMSF().createInstance(sname);
+
+ XPersistObject persCopy = UnoRuntime.queryInterface(XPersistObject.class, oCopy);
+
+ persCopy.read(iStream);
+
+ XPropertySet copyps = UnoRuntime.queryInterface(
+ XPropertySet.class, oCopy);
+
+ XPropertySetInfo copypsi = copyps.getPropertySetInfo();
+ Property[] copyprops = copypsi.getProperties();
+
+ for (int i = 0; i < copyprops.length; i++) {
+ Object cps = copyps.getPropertyValue(copyprops[i].Name);
+ Object ops = objps.getPropertyValue(objprops[i].Name);
+ boolean locRes = ( (ValueComparer.equalValue(cps,ops)) ||
+ (utils.isVoid(cps) && utils.isVoid(ops)) );
+
+ //transient properties aren't stored
+ if (isTransient(objprops[i])) locRes = true;
+
+ Object pseudo = tEnv.getObjRelation("PSEUDOPERSISTENT");
+ if ( (pseudo != null) && !locRes) {
+ String str = copyprops[i].Name;
+ locRes = ( (str.equals("Time")) || (str.equals("Date"))
+ || (str.equals("FormatsSupplier"))
+ || (str.equals("Text"))
+ || (str.equals("Value"))
+ || (str.indexOf("UserDefined")>0)
+ );
+ }
+ if (!locRes) {
+ log.println("Property '" + copyprops[i].Name
+ + "' failed");
+ dbg.printPropertyInfo(objps, objprops[i].Name, log);
+ dbg.printPropertyInfo(copyps, copyprops[i].Name, log);
+ }
+ bResult &= locRes;
+ }
+ } else {
+ Object oCopy = tParam.getMSF().createInstance(sname);
+ XPersistObject persCopy = UnoRuntime.queryInterface(XPersistObject.class, oCopy);
+
+ persCopy.read(iStream);
+
+ bResult = persCopy.getServiceName().equals(sname);
+
+ }
+
+ } catch (com.sun.star.uno.Exception e) {
+ log.println("Exception occurred : ");
+ e.printStackTrace(log) ;
+ bResult = false;
+ }
+
+ tRes.tested("read()", bResult);
+ }
+
+ /**
+ * Test calls the method and checks that
+ * no exceptions were thrown. <p>
+ * Has <b> OK </b> status if no exceptions were thrown. <p>
+ */
+ public void _write() {
+ boolean bResult = true;
+ try {
+ initPipe();
+ oObj.write(oStream);
+ } catch (com.sun.star.io.IOException e) {
+ log.println("Exception occurred while test. " + e);
+ bResult = false;
+ }
+ tRes.tested("write()", bResult);
+ }
+
+
+ /**
+ * Creates the following stream scheme <code>
+ * ObjectOutputStream -> Pipe -> ObjectInputStream </code> for writing/reading
+ * object.
+ */
+ protected void initPipe() {
+ try {
+ Object aPipe = tParam.getMSF().createInstance
+ ("com.sun.star.io.Pipe");
+ Object istream = tParam.getMSF().createInstance
+ ("com.sun.star.io.ObjectInputStream");
+ Object ostream = tParam.getMSF().createInstance
+ ("com.sun.star.io.ObjectOutputStream");
+
+ // Now the objects that aren't described anywhere
+ Object mistream = tParam.getMSF().createInstance
+ ("com.sun.star.io.MarkableInputStream");
+ Object mostream = tParam.getMSF().createInstance
+ ("com.sun.star.io.MarkableOutputStream");
+
+ XActiveDataSink xdSi = UnoRuntime.queryInterface(XActiveDataSink.class, istream);
+ XActiveDataSource xdSo = UnoRuntime.queryInterface(XActiveDataSource.class, ostream);
+ XActiveDataSink xdSmi = UnoRuntime.queryInterface(XActiveDataSink.class, mistream);
+ XActiveDataSource xdSmo = UnoRuntime.queryInterface(XActiveDataSource.class, mostream);
+
+ XInputStream miStream = UnoRuntime.queryInterface(XInputStream.class, mistream);
+ XOutputStream moStream = UnoRuntime.queryInterface(XOutputStream.class, mostream);
+ XInputStream PipeIn = UnoRuntime.queryInterface(XInputStream.class, aPipe);
+ XOutputStream PipeOut = UnoRuntime.queryInterface(XOutputStream.class,aPipe);
+
+ xdSi.setInputStream(miStream);
+ xdSo.setOutputStream(moStream);
+ xdSmi.setInputStream(PipeIn);
+ xdSmo.setOutputStream(PipeOut);
+
+ iStream = UnoRuntime.queryInterface(XObjectInputStream.class, istream);
+ oStream = UnoRuntime.queryInterface(XObjectOutputStream.class, ostream);
+
+
+ } catch (com.sun.star.uno.Exception e) {
+ System.out.println("exc " + e);
+ }
+
+ }
+
+ public static boolean isTransient(Property prop) {
+ short attr = prop.Attributes;
+ return ((attr & com.sun.star.beans.PropertyAttribute.TRANSIENT) != 0);
+ }
+
+
+}
+
+