public void testSecuredEntityBeanSingleTimer()
throws Exception
{
login();
TimerEntityHome home = (TimerEntityHome) getEJBHome(TimerEntityHome.SECURED_JNDI_NAME);
TimerEntity entity = home.create(new Integer(222));
entity.startSingleTimer(SHORT_PERIOD);
Thread.sleep(5 * SHORT_PERIOD);
int count = entity.getTimeoutCount();
assertTrue("Timeout was expected to be called only once but was called: "
+ count + " times",
count == 1);
try
{
entity.stopTimer();
fail("A single timer should expire after the first event and therefore this "
+ "has to throw an NoSuchObjectLocalException");
}
catch (RemoteException re)
{
Throwable lCause = re.detail;
if (lCause instanceof ServerException)
{
lCause = ((ServerException) lCause).detail;
if (lCause instanceof NoSuchObjectLocalException)
{
// This exception is expected -> ignore
}
else
{
throw re;
}
}
}
entity.remove();
logout();
}