Search in sources :

Example 26 with ScheduleExpression

use of javax.ejb.ScheduleExpression 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()));
    }
}
Also used : ScheduleExpression(javax.ejb.ScheduleExpression) EJBCronTrigger(org.apache.openejb.core.timer.EJBCronTrigger) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) Test(org.junit.Test)

Example 27 with ScheduleExpression

use of javax.ejb.ScheduleExpression 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()));
}
Also used : ScheduleExpression(javax.ejb.ScheduleExpression) EJBCronTrigger(org.apache.openejb.core.timer.EJBCronTrigger) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) Test(org.junit.Test)

Example 28 with ScheduleExpression

use of javax.ejb.ScheduleExpression 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()));
}
Also used : ScheduleExpression(javax.ejb.ScheduleExpression) EJBCronTrigger(org.apache.openejb.core.timer.EJBCronTrigger) GregorianCalendar(java.util.GregorianCalendar) Test(org.junit.Test)

Example 29 with ScheduleExpression

use of javax.ejb.ScheduleExpression 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()));
}
Also used : ScheduleExpression(javax.ejb.ScheduleExpression) EJBCronTrigger(org.apache.openejb.core.timer.EJBCronTrigger) GregorianCalendar(java.util.GregorianCalendar) Test(org.junit.Test)

Example 30 with ScheduleExpression

use of javax.ejb.ScheduleExpression in project tomee by apache.

the class EJBCronTriggerTest method testIncrementsC.

@Test(timeout = 1000)
public void testIncrementsC() throws ParseException {
    final ScheduleExpression expr = new ScheduleExpression().year(2011).month(5).dayOfMonth(5).hour("*").minute("20/40").start(new GregorianCalendar(2011, 4, 5, 10, 21, 0).getTime());
    final EJBCronTrigger trigger = new EJBCronTrigger(expr);
    assertEquals(new GregorianCalendar(2011, 4, 5, 11, 20, 0).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 5, 10, 21, 0).getTime()));
}
Also used : ScheduleExpression(javax.ejb.ScheduleExpression) EJBCronTrigger(org.apache.openejb.core.timer.EJBCronTrigger) GregorianCalendar(java.util.GregorianCalendar) Test(org.junit.Test)

Aggregations

ScheduleExpression (javax.ejb.ScheduleExpression)75 GregorianCalendar (java.util.GregorianCalendar)60 Test (org.junit.Test)52 EJBCronTrigger (org.apache.openejb.core.timer.EJBCronTrigger)44 Date (java.util.Date)34 Calendar (java.util.Calendar)21 CalendarBasedTimeout (org.jboss.as.ejb3.timerservice.schedule.CalendarBasedTimeout)17 TimerConfig (javax.ejb.TimerConfig)4 TimeZone (java.util.TimeZone)3 ArrayList (java.util.ArrayList)2 ParseException (org.apache.openejb.core.timer.EJBCronTrigger.ParseException)2 IOException (java.io.IOException)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 PostConstruct (javax.annotation.PostConstruct)1 EJBException (javax.ejb.EJBException)1 NoSuchObjectLocalException (javax.ejb.NoSuchObjectLocalException)1 ScheduleData (org.apache.openejb.core.timer.ScheduleData)1 AutoTimer (org.jboss.as.ejb3.timerservice.AutoTimer)1 ModelNode (org.jboss.dmr.ModelNode)1