// Make pause and do a local call.
Thread.sleep(1000);
// Saying local hello.
poa_comTester Tester = poa_comTesterHelper.narrow(object);
Any a0 = orb.create_any();
a0.insert_string("Initial value for slot 0");
Any a1 = orb.create_any();
a1.insert_string("Initial value for slot 1");
ORB orb2 = ORB.init(new String[ 0 ], initialisers);
try
{
// Set the initial slot values.
Current current =
CurrentHelper.narrow(orb.resolve_initial_references("PICurrent"));
Current current2 =
CurrentHelper.narrow(orb2.resolve_initial_references("PICurrent"));
current.set_slot(ucInitialiser.slot_0, a0);
current.set_slot(ucInitialiser.slot_1, a1);
current2.set_slot(ucInitialiser.slot_0, a0);
current2.set_slot(ucInitialiser.slot_1, a1);
}
catch (Exception e)
{
fail("Exception " + e + " while setting slots.");
e.printStackTrace();
}
String lHello = Tester.sayHello();
// Saying remote hello.
Object object2 = orb2.string_to_object(ior);
poa_comTester Tester2 = poa_comTesterHelper.narrow(object2);
String hello = Tester2.sayHello();
assertEquals("Local and remote must return the same", lHello, hello);
// Saying remote hello via DII.
Request rq =
Tester2._create_request(null, "sayHello", orb2.create_list(0),
orb2.create_named_value("", orb.create_any(), 0)
);
rq.set_return_type(orb2.get_primitive_tc(TCKind.tk_string));
rq.invoke();
assertEquals("Remote Stub and DII call must return the same", hello,
rq.return_value().extract_string()
);
// Saying local hello via DII.
rq =
Tester._create_request(null, "sayHello", orb2.create_list(0),
orb2.create_named_value("", orb.create_any(), 0)
);
rq.set_return_type(orb2.get_primitive_tc(TCKind.tk_string));
rq.invoke();
assertEquals("Local Stub and DII call must return the same", hello,
rq.return_value().extract_string()
);
// Throw remote system exception
try
{
Tester2.throwException(-1);
fail("BAD_OPERATION should be thrown");
}
catch (BAD_OPERATION ex)
{
assertEquals("Minor code", ex.minor, 456);
assertEquals("Completion status", CompletionStatus.COMPLETED_YES,
ex.completed
);
}
// Throw remote user exception
try
{
Tester2.throwException(24);
fail("UserException should be thrown");
}
catch (ourUserException ex)
{
assertEquals("Custom field", ex.ourField, 24);
}
// Throw local system exception
try
{
Tester.throwException(-1);
fail("BAD_OPERATION should be thrown");
}
catch (BAD_OPERATION ex)
{
assertEquals("Minor code", ex.minor, 456);
assertEquals("Completion status", CompletionStatus.COMPLETED_YES,
ex.completed
);
}
// Throw local user exception
try
{
Tester.throwException(24);
fail("UserException should be thrown");
}
catch (ourUserException ex)
{
assertEquals("Custom field", ex.ourField, 24);
}
// Remote server side interceptor throws an exception
try
{
Tester2.passCharacters("", "");
fail("INV_FLAG should be thrown");
}
catch (INV_FLAG ex)
{
assertEquals("Minor", 52, ex.minor);
assertEquals("Completion status",
CompletionStatus.COMPLETED_MAYBE, ex.completed
);
}
// Local server side interceptor throws an exception
try
{
Tester.passCharacters("", "");
fail("INV_FLAG should be thrown");
}
catch (INV_FLAG ex)
{
assertEquals("Minor", 52, ex.minor);
assertEquals("Completion status",
CompletionStatus.COMPLETED_MAYBE, ex.completed
);
}
assertEquals("Forwarding test, remote", 16, Tester2.theField());
assertEquals("Forwarding test, local", 16, Tester.theField());
assertEquals("Forwarding test, remote", 16, Tester2.theField());
assertEquals("Forwarding test, local", 16, Tester.theField());
// Destroy orbs:
orb.destroy();
orb2.destroy();