public void testSecuredStatelessSessionBeanSingleTimer()
throws Exception
{
login();
TimerSLSBHome home = (TimerSLSBHome) getEJBHome(TimerSLSBHome.SECURED_JNDI_NAME);
TimerSLSB bean = home.create();
byte[] handle = bean.startSingleTimer(SHORT_PERIOD);
Thread.sleep(5 * SHORT_PERIOD);
int count = bean.getTimeoutCount(handle);
assertTrue("Timeout was expected to be called only once but was called: "
+ count + " times",
count == 1);
try
{
bean.stopTimer(handle);
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;
}
}
}
bean.remove();
logout();
}