use of javax.ejb.TimerHandle in project wildfly by wildfly.
the class TimerServicePersistenceFirstTestCase method createAndCancelTimerService.
@Test
public void createAndCancelTimerService() throws NamingException {
InitialContext ctx = new InitialContext();
CancelledTimerServiceBean bean = (CancelledTimerServiceBean) ctx.lookup("java:module/" + CancelledTimerServiceBean.class.getSimpleName());
TimerHandle handle = bean.createTimer();
Assert.assertTrue(CancelledTimerServiceBean.awaitTimerCall());
Assert.assertEquals("info", handle.getTimer().getInfo());
handle.getTimer().cancel();
}
use of javax.ejb.TimerHandle in project wildfly by wildfly.
the class TimerServiceCancellationTestCase method testCancelCalendarWhileTimeoutActive.
@Test
public void testCancelCalendarWhileTimeoutActive() throws NamingException, InterruptedException {
InitialContext ctx = new InitialContext();
CalendarTimerServiceBean bean = (CalendarTimerServiceBean) ctx.lookup("java:module/" + CalendarTimerServiceBean.class.getSimpleName());
TimerHandle handle = bean.createTimer();
Assert.assertTrue(bean.getTimerEntry().await(TIMER_CALL_WAITING_S, TimeUnit.SECONDS));
//now the timeout is in progress cancel the timer
handle.getTimer().cancel();
bean.getTimerExit().countDown();
Assert.assertFalse(CalendarTimerServiceBean.quickAwaitTimerCall());
Assert.assertEquals(0, bean.getTimerCount());
}
use of javax.ejb.TimerHandle in project wildfly by wildfly.
the class TimerServiceCancellationTestCase method testCancelSimpleWhileTimeoutActive.
@Test
public void testCancelSimpleWhileTimeoutActive() throws NamingException, InterruptedException {
InitialContext ctx = new InitialContext();
SimpleTimerServiceBean bean = (SimpleTimerServiceBean) ctx.lookup("java:module/" + SimpleTimerServiceBean.class.getSimpleName());
TimerHandle handle = bean.createTimer();
Assert.assertTrue(bean.getTimerEntry().await(TIMER_CALL_WAITING_S, TimeUnit.SECONDS));
//now the timeout is in progress cancel the timer
handle.getTimer().cancel();
bean.getTimerExit().countDown();
Assert.assertFalse(SimpleTimerServiceBean.quickAwaitTimerCall());
Assert.assertEquals(0, bean.getTimerCount());
}
Aggregations