use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testSimpleDayOfWeek.
@Test(timeout = 500)
public void testSimpleDayOfWeek() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfWeek("7").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 testBothDayOfMonthAndDayOfWeekH.
@Test(timeout = 5000)
public void testBothDayOfMonthAndDayOfWeekH() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year(2011).dayOfMonth("28").dayOfWeek("3").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, 6, 28, 20, 59, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 6, 27, 21, 59, 59).getTime()));
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testIncrementsA.
@Test(timeout = 1000)
public void testIncrementsA() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year(2008).month(1).dayOfMonth(20).hour("6/3").minute(30).start(new Date(0));
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
// Should fire on Sunday, January 20th, first at 6:30
Calendar calendar = new GregorianCalendar(2008, 0, 20);
Date startTime = new Date(calendar.getTimeInMillis() - 1000);
calendar.set(Calendar.HOUR_OF_DAY, 6);
calendar.set(Calendar.MINUTE, 30);
assertEquals(calendar.getTime(), trigger.getFireTimeAfter(startTime));
// Next on 9:30
startTime = new Date(calendar.getTimeInMillis());
calendar.set(Calendar.HOUR_OF_DAY, 9);
assertEquals(calendar.getTime(), trigger.getFireTimeAfter(startTime));
// Won't be fired after the 20th so it should return null
calendar = new GregorianCalendar(2008, 0, 21);
startTime = new Date(calendar.getTimeInMillis());
assertNull(trigger.getFireTimeAfter(startTime));
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testRangeYearsB.
@Test(timeout = 500)
public void testRangeYearsB() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().year("2013-2016").month(2).dayOfMonth(29).hour(23).minute(1).second(0).start(new Date(0));
;
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2016, 1, 29, 23, 1, 0).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 1, 1, 23, 0, 0).getTime()));
}
use of javax.ejb.ScheduleExpression in project tomee by apache.
the class EJBCronTriggerTest method testOrdinalNumbersDayOfMonthD.
@Test(timeout = 5000)
public void testOrdinalNumbersDayOfMonthD() throws ParseException {
final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("1st sun").hour(23).minute(1).second(59);
final EJBCronTrigger trigger = new EJBCronTrigger(expr);
assertEquals(new GregorianCalendar(2100, 1, 7, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2100, 1, 1, 0, 0, 0).getTime()));
}
Aggregations