use of org.apache.openejb.core.timer.EJBCronTrigger 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()));
}
}
use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testBothDayOfMonthAndDayOfWeekF.
@Test(timeout = 5000)
public void testBothDayOfMonthAndDayOfWeekF() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year(2011).dayOfMonth("19").dayOfWeek("3").hour(20).minute(59).second(59).start(new GregorianCalendar(2011, 4, 18, 20, 59, 58).getTime());
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 4, 18, 20, 59, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 18, 20, 59, 58).getTime()));
assertEquals(new GregorianCalendar(2011, 4, 19, 20, 59, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 18, 20, 59, 59).getTime()));
}
use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testWeekdaysA.
@Test(timeout = 1000)
public void testWeekdaysA() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year(2008).dayOfWeek("Wed").start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
// Should fire on January 16th
Calendar calendar = new GregorianCalendar(2008, 0, 16);
final Date startTime = new Date(calendar.getTimeInMillis() - 1000);
assertEquals(calendar.getTime(), trigger.getFireTimeAfter(startTime));
// And for the last time, on the 31st of December
calendar = new GregorianCalendar(2008, 11, 31);
final Date expectedTime = calendar.getTime();
assertEquals(expectedTime, trigger.getFinalFireTime());
}
use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testBothDayOfMonthAndDayOfWeekB.
@Test(timeout = 5000)
public void testBothDayOfMonthAndDayOfWeekB() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("last").dayOfWeek("3").year(2011).start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 4, 11, 0, 0, 0).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 7, 0, 0, 0).getTime()));
}
use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testBothDayOfMonthAndDayOfWeekG.
@Test(timeout = 5000)
public void testBothDayOfMonthAndDayOfWeekG() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year(2011).dayOfMonth("12").dayOfWeek("6").hour(20).minute(59).second(59).start(new GregorianCalendar(2011, 5, 11, 20, 59, 58).getTime());
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
//assertEquals(new GregorianCalendar(2011, 5, 11, 20, 59, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 5, 11, 20, 59, 58).getTime()));
assertEquals(new GregorianCalendar(2011, 5, 12, 20, 59, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 5, 11, 20, 59, 59).getTime()));
}
Aggregations