List timerHandles = pp.listTimerHandles();
assertEquals("unexpected handle count", 0, timerHandles.size());
InitialContext iniCtx = getInitialContext();
TimerSessionHome home = (TimerSessionHome)iniCtx.lookup(TimerSessionHome.JNDI_NAME);
TimerSession session = home.create();
session.resetCallCount();
try
{
// insert a timer into the db
ObjectName oname = ObjectNameFactory.create("jboss.j2ee:jndiName=test/txtimer/TimerSession,service=EJB");
TimedObjectId targetId = new TimedObjectId(oname);
pp.insertTimer("pk1", targetId, new Date(), 0, null);
sleep(500);
timerHandles = pp.listTimerHandles();
assertEquals("unexpected handle count", 1, timerHandles.size());
// fake restore on server startup
// we cannot test that the PersistencePolicy is notified after startup
try
{
getServer().invoke(
EJBTimerService.OBJECT_NAME,
"restoreTimers",
new Object[] { oname, null },
new String[]{"javax.management.ObjectName", "java.lang.ClassLoader" }
);
}
catch (Exception e)
{
log.warn("Could not restore ejb timers", e);
}
sleep(500);
assertEquals("unexpected call count", 1, session.getGlobalCallCount());
timerHandles = pp.listTimerHandles();
assertEquals("unexpected handle count", 0, timerHandles.size());
}
finally
{
session.remove();
}
}