use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testBothDayOfMonthAndDayOfWeekC.
@Test(timeout = 5000)
public void testBothDayOfMonthAndDayOfWeekC() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year(2011).dayOfMonth("18").dayOfWeek("3").hour(23).minute(59).second(58).start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 4, 25, 23, 59, 58).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 18, 23, 59, 59).getTime()));
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testBothDayOfMonthAndDayOfWeekD.
@Test(timeout = 5000)
public void testBothDayOfMonthAndDayOfWeekD() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year(2011).dayOfMonth("19").dayOfWeek("3").hour(23).minute(59).second(59).start(new GregorianCalendar(2011, 4, 18, 23, 59, 58).getTime());
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 4, 18, 23, 59, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 18, 23, 59, 58).getTime()));
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testOrdinalNumbersDayOfMonthA.
@Test(timeout = 5000)
public void testOrdinalNumbersDayOfMonthA() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("2nd mon").hour(23).minute(1).second(59).start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 4, 9, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 1, 0, 0, 0).getTime()));
assertEquals(new GregorianCalendar(2011, 5, 13, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 10, 0, 0, 0).getTime()));
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testEndTime.
@Test(timeout = 1000)
public void testEndTime() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfMonth(20).dayOfWeek("sat").start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
// Should not be fired at all since the first Saturday the 20th is in September
Calendar calendar = new GregorianCalendar(2008, 0, 4);
trigger.setEndTime(calendar.getTime());
calendar = new GregorianCalendar(2008, 0, 1);
assertNull(trigger.getFireTimeAfter(calendar.getTime()));
//Since we did not specify the start time, the trigger will backward until finding the target time
//assertNull(trigger.getFinalFireTime());
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testRangeYearsA.
@Test(timeout = 5000)
public void testRangeYearsA() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year("2009-2013").month(2).dayOfMonth(29).hour(23).minute(1).second(0).start(new Date(0));
;
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2012, 1, 29, 23, 1, 0).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2009, 1, 1, 23, 0, 0).getTime()));
}
Aggregations