// test inserting a member with an incorrect type
pairs = new NameValuePair [2];
any = orb.create_any ();
any.insert_char ('a');
pairs [0] = new NameValuePair (name1, any);
any = orb.create_any ();
any.insert_string ("WrongType");
pairs [0] = new NameValuePair (name2, any);
msg = "Failed to raise a TypeMismatch exception when passing in a ";
msg += "name/value pair containing an incorrect member value";
try
{
dynAny.set_members (pairs);
fail (msg);
}
catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex)
{
// success
}
catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex)
{
fail (msg + ": " + ex);
}
// test inserting a member with an incorrect name
pairs = new NameValuePair [2];
any = orb.create_any ();
any.insert_char ('a');
pairs [0] = new NameValuePair (name1, any);
any = orb.create_any ();
any.insert_longlong ((long) 1);
pairs [1] = new NameValuePair ("WrongName", any);
msg = "Failed to raise a TypeMismatch exception when passing in a ";
msg += "name/value pair containing an incorrect member name";
try
{
dynAny.set_members (pairs);
fail (msg);
}
catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex)
{
// success
}
catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex)
{
fail (msg + ": " + ex);
}
// test inserting a sequence with the wrong number of members
pairs = new NameValuePair [3];
any = orb.create_any ();
any.insert_char ('a');
pairs [0] = new NameValuePair (name1, any);
any = orb.create_any ();
any.insert_longlong ((long) 1);
pairs [1] = new NameValuePair (name2, any);
any = orb.create_any ();
any.insert_longlong ((long) 1);
pairs [2] = new NameValuePair (name2, any);
msg = "Failed to raise an InvalidValue exception when passing in a ";
msg += "name/value sequence containing too many members";
try
{