List timerHandles = pp.listTimerHandles();
assertEquals("unexpected handle count", 0, timerHandles.size());
InitialContext iniCtx = getInitialContext();
TimerEntityHome home = (TimerEntityHome)iniCtx.lookup(TimerEntityHome.JNDI_NAME);
TimerEntity entity = home.create(new Integer(1));
try
{
// insert a timer into the db
ObjectName oname = ObjectNameFactory.create("jboss.j2ee:jndiName=test/txtimer/TimerEntity,service=EJB");
TimedObjectId targetId = new TimedObjectId(oname, new Integer(1));
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, entity.getCallCount());
timerHandles = pp.listTimerHandles();
assertEquals("unexpected handle count", 0, timerHandles.size());
}
finally
{
entity.remove();
}
}