コード例 #1
0
  /** Test initializing a DynAny object from an Any value. */
  public void testInitDynAnyFromAny() {
    String msg;
    EmptyException type;
    org.omg.CORBA.Any any = null;
    org.omg.CORBA.TypeCode tc = null;
    org.omg.DynamicAny.DynStruct dynAny = null;
    org.omg.DynamicAny.DynStruct dynAny2 = null;

    tc = EmptyExceptionHelper.type();
    dynAny = createDynAnyFromTypeCode(tc);

    type = new EmptyException();
    any = orb.create_any();
    EmptyExceptionHelper.insert(any, type);
    dynAny2 = createDynAnyFromAny(any);

    msg = "Failed to initialize a DynAny object from an Any object ";
    msg += "using the DynAny::from_any operation";
    try {
      dynAny.from_any(any);
    } catch (Throwable ex) {
      fail(msg + ": " + ex);
    }
    assertTrue(msg, dynAny.equal(dynAny2));
  }
コード例 #2
0
  /** Test creating a copy of a DynAny object. */
  public void testCopyDynAny() {
    String msg;
    org.omg.CORBA.TypeCode tc = null;
    org.omg.DynamicAny.DynStruct dynAny = null;
    org.omg.DynamicAny.DynStruct dynAny2 = null;

    tc = EmptyExceptionHelper.type();
    dynAny = createDynAnyFromTypeCode(tc);
    dynAny2 = (org.omg.DynamicAny.DynStruct) dynAny.copy();

    msg = "The DynAny object created with the DynAny::copy operation ";
    msg += "is not equal to the DynAny object it was copied from";
    assertTrue(msg, dynAny.equal(dynAny2));
  }
コード例 #3
0
  /** Test generating an Any value from a DynAny object. */
  public void testGenerateAnyFromDynAny() {
    String msg;
    org.omg.CORBA.Any any = null;
    org.omg.CORBA.TypeCode tc = null;
    org.omg.DynamicAny.DynStruct dynAny = null;
    org.omg.DynamicAny.DynStruct dynAny2 = null;

    tc = EmptyExceptionHelper.type();
    dynAny = createDynAnyFromTypeCode(tc);

    any = orb.create_any();
    any = dynAny.to_any();
    dynAny2 = createDynAnyFromAny(any);

    msg = "The DynAny::to_any operation failed to create an Any ";
    msg += "object with the same value as the DynAny object";
    assertTrue(msg, dynAny.equal(dynAny2));
  }
コード例 #4
0
  /** Test iterating through components of a DynAny. */
  public void testIterateDynAny() {
    String msg;
    int compCount = -1;
    boolean seek;
    org.omg.CORBA.TypeCode tc = null;
    org.omg.DynamicAny.DynStruct dynAny = null;

    tc = EmptyExceptionHelper.type();
    dynAny = createDynAnyFromTypeCode(tc);

    // test the component count
    try {
      compCount = dynAny.component_count();
    } catch (Throwable ex) {
      // should not be needed, but it prevents compiler errors
      fail("Unexpected error raised by DynAny::component_count operation");
    }
    msg = "The number of components returned from the ";
    msg += "DynAny::component_count operation is incorrect";
    assertEquals(msg, 0, compCount);

    // test if there is a first component
    msg = "The DynAny::seek operation indicates that a valid component ";
    msg += "exists but the DynAny should have no components";
    seek = dynAny.seek(0);
    assertTrue(msg, !seek);

    // test getting the current component
    try {
      dynAny.current_component();

      msg = "A TypeMismatch exception was not raised by the ";
      msg += "DynAny::current_component operation when trying to access ";
      msg += "the current component of a DynAny with no components";
      fail(msg);
    } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex) {
      // success
    }
  }
コード例 #5
0
  /**
   * Tests creating a DynAny object from a TypeCode object generated from IDL using the
   * DynAnyFactory object.
   */
  public void testFactoryCreateFromIDLTypeCode() {
    org.omg.CORBA.TypeCode tc = null;

    tc = EmptyExceptionHelper.type();
    createDynAnyFromTypeCode(tc);
  }