use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testSecond.
@Test(timeout = 5000)
public void testSecond() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().hour("*").minute("*").second(5).start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 1, 5, 0, 0, 5).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 1, 5, 0, 0, 4).getTime()));
assertEquals(new GregorianCalendar(2011, 1, 5, 0, 1, 5).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 1, 5, 0, 0, 6).getTime()));
}
use of org.apache.openejb.core.timer.EJBCronTrigger 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 org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testRangeDayOfMonthD.
@Test(timeout = 5000)
public void testRangeDayOfMonthD() throws ParseException {
// current day is later than start day of range.
final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("-7-1").hour(23).minute(1).second(59).start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2011, 5, 28, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 5, 28, 23, 0, 0).getTime()));
}
use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testSimpleDate.
@Test(timeout = 1000)
public void testSimpleDate() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year(2008).month(12).dayOfMonth(1).start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
Calendar calendar = new GregorianCalendar(2008, 1, 1);
final Date firstTime = trigger.getFireTimeAfter(calendar.getTime());
final Date finalTime = trigger.getFinalFireTime();
// The trigger only fires once so these should be the same
assertEquals(firstTime, finalTime);
// Let's make sure that single fire time is what we wanted
calendar = new GregorianCalendar(2008, 11, 1);
assertEquals(calendar.getTime(), firstTime);
}
use of org.apache.openejb.core.timer.EJBCronTrigger in project tomee by apache.
the class EJBCronTriggerTest method testRangeDayOfMonthA.
@Test(timeout = 5000)
public void testRangeDayOfMonthA() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("3-27").hour(23).minute(1).second(59).start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2010, 6, 3, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 1, 23, 0, 0).getTime()));
assertEquals(new GregorianCalendar(2010, 6, 4, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 3, 23, 2, 0).getTime()));
assertEquals(new GregorianCalendar(2010, 6, 26, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 26, 23, 0, 0).getTime()));
assertEquals(new GregorianCalendar(2010, 6, 27, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 26, 23, 3, 0).getTime()));
assertEquals(new GregorianCalendar(2010, 7, 3, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 27, 23, 2, 0).getTime()));
}
Aggregations