Search in sources :

Example 1 with ScheduleExpression

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

the class TimerServiceImpl method copy.

private ScheduleExpression copy(final ScheduleExpression scheduleExpression) {
    final ScheduleExpression scheduleExpressionCopy = new ScheduleExpression();
    scheduleExpressionCopy.year(scheduleExpression.getYear());
    scheduleExpressionCopy.month(scheduleExpression.getMonth());
    scheduleExpressionCopy.dayOfMonth(scheduleExpression.getDayOfMonth());
    scheduleExpressionCopy.dayOfWeek(scheduleExpression.getDayOfWeek());
    scheduleExpressionCopy.hour(scheduleExpression.getHour());
    scheduleExpressionCopy.minute(scheduleExpression.getMinute());
    scheduleExpressionCopy.second(scheduleExpression.getSecond());
    scheduleExpressionCopy.start(scheduleExpression.getStart());
    scheduleExpressionCopy.end(scheduleExpression.getEnd());
    scheduleExpressionCopy.timezone(scheduleExpression.getTimezone());
    return scheduleExpressionCopy;
}
Also used : ScheduleExpression(jakarta.ejb.ScheduleExpression)

Example 2 with ScheduleExpression

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

the class EJBCronTriggerTest method testRangeMonthA.

@Test(timeout = 500)
public void testRangeMonthA() throws ParseException {
    final ScheduleExpression expr = new ScheduleExpression().year("2011").month("dec-dec").dayOfMonth(29).hour(23).minute(1).second(0).start(new Date(0));
    ;
    final EJBCronTrigger trigger = new EJBCronTrigger(expr);
    assertEquals(new GregorianCalendar(2011, 11, 29, 23, 1, 0).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2009, 1, 1, 23, 0, 0).getTime()));
}
Also used : ScheduleExpression(jakarta.ejb.ScheduleExpression) EJBCronTrigger(org.apache.openejb.core.timer.EJBCronTrigger) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) Test(org.junit.Test)

Example 3 with ScheduleExpression

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

Example 4 with ScheduleExpression

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

Example 5 with ScheduleExpression

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

the class EJBCronTriggerTest method testOrdinalNumbersDayOfMonthC.

@Test(timeout = 5000)
public void testOrdinalNumbersDayOfMonthC() throws ParseException {
    final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("last sun").hour(23).minute(1).second(59);
    final EJBCronTrigger trigger = new EJBCronTrigger(expr);
    assertEquals(new GregorianCalendar(2100, 1, 28, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2100, 1, 1, 0, 0, 0).getTime()));
}
Also used : ScheduleExpression(jakarta.ejb.ScheduleExpression) EJBCronTrigger(org.apache.openejb.core.timer.EJBCronTrigger) GregorianCalendar(java.util.GregorianCalendar) Test(org.junit.Test)

Aggregations

ScheduleExpression (jakarta.ejb.ScheduleExpression)53 Test (org.junit.Test)48 EJBCronTrigger (org.apache.openejb.core.timer.EJBCronTrigger)46 GregorianCalendar (java.util.GregorianCalendar)42 Date (java.util.Date)37 Calendar (java.util.Calendar)5 TimerConfig (jakarta.ejb.TimerConfig)2 ParseException (org.apache.openejb.core.timer.EJBCronTrigger.ParseException)2 PostConstruct (jakarta.annotation.PostConstruct)1 Timer (jakarta.ejb.Timer)1 IOException (java.io.IOException)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 ScheduleData (org.apache.openejb.core.timer.ScheduleData)1