}
}
public void testPassivationByTimeLocal()
{
StatefulSessionLocal sessionBean1 = null;
Handle handle = null;
try
{
Context ctx = new InitialContext();
log.debug("+++ testPassivationByTime");
StatefulSessionLocalHome sessionHome = ( StatefulSessionLocalHome ) ctx.lookup("ejbcts/StatefulSessionLocalBean");
sessionBean1 = sessionHome.create("testPassivationByTimeLocal");
sessionBean1.ping();
handle = sessionBean1.getHandle();
log.debug("Waiting 41 seconds for passivation...");
Thread.sleep(41*1000);
// Validate that sessionBean1 was passivated and activated
boolean passivated = sessionBean1.getWasPassivated();
if (passivated == false) throw new EJBException("sessionBean1 WasPassivated");
boolean activated = sessionBean1.getWasActivated();
if (activated == false) throw new EJBException("sessionBean1 WasActivated");
log.debug("Waiting 90 seconds for removal due to age...");
Thread.sleep(90*1000);
}
catch (CreateException e)
{
throw new EJBException(e.toString());
}
catch (NamingException e)
{
throw new EJBException(e.toString());
}
catch (InterruptedException e)
{
throw new EJBException(e.toString());
}
try
{
sessionBean1.ping();
throw new EJBException("Was able to ping for a removed session");
}
catch (NoSuchObjectLocalException expected)
{
log.debug("Session access failed as expected", expected);