@Test
public void testAccessStructMembers ()
{
String msg;
String memberName = null;
TCKind memberKind = null;
org.omg.CORBA.TypeCode tc = null;
org.omg.DynamicAny.DynStruct dynAny = null;
tc = NonEmptyExceptionHelper.type ();
dynAny = createDynAnyFromTypeCode (tc);
// test getting the name of the current member
msg = "Failed to get the correct name of the first member using ";
msg += "DynStruct::current_member_name operation";
try
{
memberName = dynAny.current_member_name ();
assertEquals (msg, "field1", memberName); // specific to IDL
}
catch (AssertionFailedError ex)
{
throw ex;
}
catch (Throwable ex)
{
fail (msg + ": " + ex);
}
// test getting the kind of the current member
msg = "Failed to get the correct kind of the first member using ";
msg += "DynStruct::current_member_kind operation";
try
{
memberKind = dynAny.current_member_kind ();
// specific to IDL
assertEquals (msg, TCKind._tk_long, memberKind.value ());
}
catch (AssertionFailedError ex)
{
throw ex;
}
catch (Throwable ex)
{
fail (msg + ": " + ex);
}
// move to the next position
dynAny.next ();
// test getting the name of the current member
msg = "Failed to get the correct name of the second member using ";
msg += "DynStruct::current_member_name operation";
try
{
memberName = dynAny.current_member_name ();
assertEquals (msg, "field2", memberName); // specific to IDL
}
catch (AssertionFailedError ex)
{
throw ex;
}
catch (Throwable ex)
{
fail (msg + ": " + ex);
}
// test getting the kind of the current member
msg = "Failed to get the correct kind of the second member using ";
msg += "DynStruct::current_member_kind operation";
try
{
memberKind = dynAny.current_member_kind ();
// specific to IDL
assertEquals (msg, TCKind._tk_string, memberKind.value ());
}
catch (AssertionFailedError ex)
{
throw ex;
}