/** 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
    }
  }
  /** Test destroying a DynAny object. */
  public void testDestroyDynAny() {
    String msg;
    EmptyException type;
    org.omg.CORBA.Any any = null;
    org.omg.DynamicAny.DynStruct dynAny = null;

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

    try {
      dynAny.type();

      msg = "Failed to destroy DynAny using DynAny::destroy operation - ";
      msg += "calling DynAny::type operation on a destroyed DynAny object ";
      msg += "did not raise OBJECT_NOT_EXIST exception";
      fail(msg);
    } catch (org.omg.CORBA.OBJECT_NOT_EXIST ex) {
      // success
    }

    msg = "Failed to destroy DynAny using DynAny::destroy operation - ";
    msg += "calling DynAny::current_component operation on a destroyed ";
    msg += "DynAny object did not raise OBJECT_NOT_EXIST exception";
    try {
      dynAny.current_component();

      fail(msg);
    } catch (org.omg.CORBA.OBJECT_NOT_EXIST ex) {
      // success
    } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex) {
      fail(msg + ": " + ex);
    }
  }