* Tests handling user exceptions
*/
@Test
public void test_userExceptions() {
try {
CalcServant calc = new CalcServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(calc);
Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass);
DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
servant.setIds(ids);
bindServant(servant, "Calc");
Calc calcClient = CalcHelper.narrow(bindReference("Calc"));
calcClient.div(1, 0);
fail();
} catch (Exception e) {
if (e instanceof DivByZero) {
assertTrue(true);
} else {
e.printStackTrace();
fail();
}
}
try {
CalcServant calc = new CalcServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(calc);
Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass);
DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};