use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testBothDayOfMonthAndDayOfWeekE.
@Test(timeout = 5000)
public void testBothDayOfMonthAndDayOfWeekE() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year(2011).dayOfMonth("19").dayOfWeek("3").hour(23).minute(59).second(58).start(new GregorianCalendar(2011, 4, 18, 23, 59, 58).getTime());
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 4, 19, 23, 59, 58).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 18, 23, 59, 59).getTime()));
}
use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testCompoundListDayOfWeek.
@Test(timeout = 5000)
public void testCompoundListDayOfWeek() throws ParseException {
final String[] dayOfWeeks = { "tue,wed,thu-fri", "wed,thu-fri,tue", "tue,wed,thu,thu-fri,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()));
}
}
use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testRangeDayOfWeekA.
@Test(timeout = 500)
public void testRangeDayOfWeekA() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfWeek("tue-fri").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()));
}
use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testOrdinalNumbersDayOfMonthB.
@Test(timeout = 5000)
public void testOrdinalNumbersDayOfMonthB() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("last mon").hour(23).minute(1).second(59);
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2100, 1, 22, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2100, 1, 1, 0, 0, 0).getTime()));
}
use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testOrdinalNumbersDayOfMonthE.
@Test(timeout = 5000)
public void testOrdinalNumbersDayOfMonthE() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("5th Sun-Last Sun").hour(23).minute(1).second(59);
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2100, 0, 31, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2100, 0, 1, 0, 0, 0).getTime()));
}
Aggregations