use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testSimpleDayOfWeekB.
@Test(timeout = 500)
public void testSimpleDayOfWeekB() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfWeek("5").hour(14).minute(1).second(59).start(new Date(0));
;
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 4, 6, 14, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 5, 23, 1, 30).getTime()));
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testLastDayOfMonthA.
@Test(timeout = 5000)
public void testLastDayOfMonthA() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("Last").hour(23).minute(59).second(59).start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2009, 1, 28, 23, 59, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2009, 1, 1, 0, 0, 0).getTime()));
//Test Leap year
assertEquals(new GregorianCalendar(2000, 1, 29, 23, 59, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2000, 1, 28, 0, 0, 0).getTime()));
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testRangeMonthA.
@Test(timeout = 500)
public void testRangeMonthA() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year("2011").month("dec-dec").dayOfMonth(29).hour(23).minute(1).second(0).start(new Date(0));
;
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 11, 29, 23, 1, 0).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2009, 1, 1, 23, 0, 0).getTime()));
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testSimpleDayOfWeekA.
@Test(timeout = 500)
public void testSimpleDayOfWeekA() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfWeek("0").hour(23).minute(1).second(59).start(new Date(0));
;
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 4, 8, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 5, 23, 1, 30).getTime()));
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testListDayOfWeekA.
@Test(timeout = 5000)
public void testListDayOfWeekA() throws ParseException {
final String[] dayOfWeeks = { "tue,wed,thu,fri", "wed,tue,thu,fri", "tue,wed,thu,fri,tue" };
for (final String dayOfWeek : dayOfWeeks) {
final ScheduleExpression expr = new ScheduleExpression().dayOfWeek(dayOfWeek).hour(23).minute(1).second(59).start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2010, 5, 29, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 5, 29, 23, 0, 0).getTime()));
assertEquals(new GregorianCalendar(2010, 5, 30, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 5, 29, 23, 2, 0).getTime()));
assertEquals(new GregorianCalendar(2010, 6, 1, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 1, 23, 0, 0).getTime()));
assertEquals(new GregorianCalendar(2010, 6, 2, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 1, 23, 3, 0).getTime()));
assertEquals(new GregorianCalendar(2010, 6, 6, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 2, 23, 2, 0).getTime()));
}
}
Aggregations