/** 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));
  }
  /**
   * Test that a TypeMismatch exception is raised if there is a type mismatch between the DynAny and
   * Any types in an assignment.
   */
  public void testInitFromAnyTypeMismatchEx() {
    String msg;
    org.omg.CORBA.Any any = null;
    org.omg.CORBA.TypeCode tc = null;
    org.omg.DynamicAny.DynStruct dynAny = null;

    any = orb.create_any();
    any.insert_string("Hello");

    tc = orb.create_exception_tc(ID, NAME, MEMBERS);
    dynAny = createDynAnyFromTypeCode(tc);

    msg = "TypeMismatch exception not thrown by DynAny::from_any ";
    msg += "operation when DynAny and Any operands have different types";
    try {
      dynAny.from_any(any);

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