示例#1
0
  /**
   * 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));
  }
 public void _setViewData() {
   if (xAccess == null) {
     log.println("No view data to change available");
     tRes.tested("setViewData()", Status.skipped(true));
   } else {
     // 2do: provide an own implementation of the XIndexAccess to set.
     // this will work without "setViewData()", it just checks that a
     // setViewData can be done.
     oObj.setViewData(xAccess);
     XIndexAccess xAccess2 = oObj.getViewData();
     String newView = getViewID(xAccess2);
     tRes.tested("setViewData()", newView.equals(myview));
   }
 }
 /** Just log output */
 @Override
 protected void after() {
   log.println(
       "Skipping all XApproveActionBroadcaster methods, since they" + " need user interaction");
   throw new StatusException(Status.skipped(true));
 }