assertTrue(wasConcurrentException);
}
public void testDestroyException() throws Exception
{
EntityFacade stateful = (EntityFacade)getInitialContext().lookup("EntityFacadeBean/remote");
assertNotNull(stateful);
stateful.setThrowRemoveException(EntityFacade.REMOVE_EXCEPTION_TYPE.RUNTIME);
stateful.createEntity("Kalin");
try
{
stateful.remove();
fail("should catch RuntimeException");
}
catch (RuntimeException e)
{
System.out.println("*** caught " + e.getMessage());
}
try
{
stateful.createEntity("Nogo");
fail("expected NoSuchEJBException");
}
catch(NoSuchEJBException e)
{
// ok
}
stateful = (EntityFacade)getInitialContext().lookup("EntityFacadeBean/remote");
assertNotNull(stateful);
stateful.setThrowRemoveException(EntityFacade.REMOVE_EXCEPTION_TYPE.CHECKED);
stateful.createEntity("Napa");
try
{
stateful.remove();
fail("should catch RuntimeException");
}
catch (CheckedApplicationException e)
{
System.out.println("*** caught " + e.getMessage());
}
stateful.setThrowRemoveException(EntityFacade.REMOVE_EXCEPTION_TYPE.APPLICATION);
stateful.createEntity("Cabernet");
try
{
stateful.removeWithTx();
fail("should catch RuntimeException");
}
catch (AnnotatedAppException e)
{
System.out.println("*** caught " + e.getMessage());
}
stateful.createEntity("Bailey");
stateful = (EntityFacade)getInitialContext().lookup("EntityFacadeBean/remote");
assertNotNull(stateful);
stateful.setThrowRemoveException(EntityFacade.REMOVE_EXCEPTION_TYPE.NONE);
}