javax.ejb.ScheduleExpression Java Examples
The following examples show how to use
javax.ejb.ScheduleExpression.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimerServiceBean.java From development with Apache License 2.0 | 6 votes |
ScheduleExpression getExpressionForPeriod(Period period, Date startDate) { Calendar cal = Calendar.getInstance(); cal.setTime(startDate); ScheduleExpression schedleExpression = new ScheduleExpression(); schedleExpression.start(startDate); if (period == Period.DAY) { schedleExpression.second(cal.get(Calendar.SECOND)); schedleExpression.minute(cal.get(Calendar.MINUTE)); schedleExpression.hour(cal.get(Calendar.HOUR_OF_DAY)); } else if (period == Period.MONTH) { schedleExpression.second(cal.get(Calendar.SECOND)); schedleExpression.minute(cal.get(Calendar.MINUTE)); schedleExpression.hour(cal.get(Calendar.HOUR_OF_DAY)); schedleExpression.dayOfMonth(cal.get(Calendar.DAY_OF_MONTH)); } return schedleExpression; }
Example #2
Source File: TimerServiceBean2Test.java From development with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "deprecation" }) @Test public void getExpressionForPeriod_monthPeriod_midnightOfFirstDay() { // given Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, 0); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date startDate = cal.getTime(); // when ScheduleExpression result = tm.getExpressionForPeriod(Period.MONTH, startDate); // then assertEquals(startDate.getTime(), result.getStart().getTime()); assertEquals("0", result.getSecond()); assertEquals("0", result.getMinute()); assertEquals("0", result.getHour()); assertEquals(String.valueOf(startDate.getDate()), result.getDayOfMonth()); }
Example #3
Source File: TimerServiceBean2Test.java From development with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "deprecation" }) @Test public void getExpressionForPeriod_monthPeriod() { // given Date startDate = new Date(System.currentTimeMillis() + 10000); // when ScheduleExpression result = tm.getExpressionForPeriod(Period.MONTH, startDate); // then assertEquals(startDate.getTime(), result.getStart().getTime()); assertEquals(String.valueOf(startDate.getSeconds()), result.getSecond()); assertEquals(String.valueOf(startDate.getMinutes()), result.getMinute()); assertEquals(String.valueOf(startDate.getHours()), result.getHour()); assertEquals(String.valueOf(startDate.getDate()), result.getDayOfMonth()); }
Example #4
Source File: TimerServiceBean2Test.java From development with Apache License 2.0 | 6 votes |
@Test public void getExpressionForPeriod_dayPeriod_midnight() { // given Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, 1); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date startDate = cal.getTime(); // when ScheduleExpression result = tm.getExpressionForPeriod(Period.DAY, startDate); // then assertEquals(startDate.getTime(), result.getStart().getTime()); assertEquals("0", result.getSecond()); assertEquals("0", result.getMinute()); assertEquals("0", result.getHour()); }
Example #5
Source File: TimerServiceBean2Test.java From development with Apache License 2.0 | 6 votes |
@Test public void initTimers_interval() throws Exception { // given TimerServiceStub timeServiceStub = mock(TimerServiceStub.class); when(ctx.getTimerService()).thenReturn(timeServiceStub); TimerConfig timerConfig = new TimerConfig(); timerConfig.setInfo(TimerType.BILLING_INVOCATION); doReturn(new TimerStub(null, timerConfig)).when(timeServiceStub) .createCalendarTimer(any(ScheduleExpression.class), any(TimerConfig.class)); // when tm.initTimers(); // then verify(timeServiceStub, times(4)).createTimer(any(Date.class), eq(10000L), any(TimerType.class)); }
Example #6
Source File: TimerServiceBean.java From development with Apache License 2.0 | 6 votes |
void createTimerWithPeriod(TimerService timerService, TimerType timerType, long timerOffset, Period period) { if (isTimerCreated(timerType, timerService)) { return; } TimerConfig config = new TimerConfig(); config.setInfo(timerType); Date startDate = getDateForNextTimerExpiration(period, timerOffset); ScheduleExpression schedleExpression = getExpressionForPeriod(period, startDate); Timer timer = timerService.createCalendarTimer(schedleExpression, config); Date nextStart = timer.getNextTimeout(); SimpleDateFormat sdf = new SimpleDateFormat(); logger.logInfo(Log4jLogger.SYSTEM_LOG, LogMessageIdentifier.INFO_TIMER_CREATED, String.valueOf(timerType), sdf.format(nextStart)); }
Example #7
Source File: EjbTimerServiceImpl.java From tomee with Apache License 2.0 | 6 votes |
@Override public Timer createTimer(final Object primaryKey, final Method timeoutMethod, final ScheduleExpression scheduleExpression, final TimerConfig timerConfig) { if (scheduleExpression == null) { throw new IllegalArgumentException("scheduleExpression is null"); } //TODO add more schedule expression validation logic ? checkState(); try { final TimerData timerData = timerStore.createCalendarTimer(this, (String) deployment.getDeploymentID(), primaryKey, timeoutMethod, scheduleExpression, timerConfig, false); initializeNewTimer(timerData); return timerData.getTimer(); } catch (final TimerStoreException e) { throw new EJBException(e); } }
Example #8
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 500) public void testSimpleDayOfWeekA() throws ParseException { final ScheduleExpression expr = new ScheduleExpression().dayOfWeek("0").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())); }
Example #9
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@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())); }
Example #10
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 500) public void testRangeCDayOfWeek() throws ParseException { final ScheduleExpression expr = new ScheduleExpression().dayOfWeek("0-7").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, 2, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 2, 23, 0, 0).getTime())); assertEquals(new GregorianCalendar(2010, 6, 3, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 2, 23, 2, 0).getTime())); }
Example #11
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 5000) public void testListDayOfMonth() throws ParseException { final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("5,10,24").hour(23).minute(1).second(59).start(new Date(0)); final EJBCronTrigger trigger = new EJBCronTrigger(expr); assertEquals(new GregorianCalendar(2010, 6, 5, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 5, 29, 23, 0, 0).getTime())); assertEquals(new GregorianCalendar(2010, 6, 10, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 5, 23, 2, 0).getTime())); assertEquals(new GregorianCalendar(2010, 6, 24, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 24, 23, 0, 0).getTime())); assertEquals(new GregorianCalendar(2010, 7, 5, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 24, 23, 3, 0).getTime())); }
Example #12
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@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())); } }
Example #13
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 5000) public void testListDayOfWeekB() throws ParseException { final String[] dayOfWeeks = {"2,3,4,5", "3,2,4,5", "2,3,4,5,2"}; 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())); } }
Example #14
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@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())); } }
Example #15
Source File: QuartzPersistenceForEJBTimersTest.java From tomee with Apache License 2.0 | 5 votes |
public void newTimer() { final TimerConfig tc = new TimerConfig("my-timer", true); final ScheduleExpression se = new ScheduleExpression(); final Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.SECOND, 2); se.second(calendar.get(Calendar.SECOND) + "/3"); se.minute("*"); se.hour("*"); se.dayOfMonth("*"); se.dayOfWeek("*"); se.month("*"); timer = timerService.createCalendarTimer(se, tc); }
Example #16
Source File: TransactionRegistryInTimeoutTest.java From tomee with Apache License 2.0 | 5 votes |
public Timer setTimerNow() { final ScheduleExpression schedule = new ScheduleExpression().second("*/3").minute("*").hour("*"); final TimerConfig timerConfig = new TimerConfig(); timerConfig.setPersistent(false); return timerService.createCalendarTimer(schedule, timerConfig); }
Example #17
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 5000000) public void testRangeDayOfWeekB() throws ParseException { final ScheduleExpression expr = new ScheduleExpression().dayOfWeek("fri-tue").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, 6, 2, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 5, 29, 23, 2, 0).getTime())); assertEquals(new GregorianCalendar(2010, 6, 2, 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, 2, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 2, 23, 0, 0).getTime())); assertEquals(new GregorianCalendar(2010, 6, 3, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2010, 6, 2, 23, 2, 0).getTime())); }
Example #18
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 5000) public void testRangeYearsA() throws ParseException { final ScheduleExpression expr = new ScheduleExpression().year("2009-2013").month(2).dayOfMonth(29).hour(23).minute(1).second(0).start(new Date(0)); ; final EJBCronTrigger trigger = new EJBCronTrigger(expr); assertEquals(new GregorianCalendar(2012, 1, 29, 23, 1, 0).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2009, 1, 1, 23, 0, 0).getTime())); }
Example #19
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 5000) public void testSimpleDayOfWeekC() throws ParseException { final ScheduleExpression expr = new ScheduleExpression().year(2011).month(6).dayOfWeek("3").hour(22).minute(1).second(1).start(new Date(0)); ; final EJBCronTrigger trigger = new EJBCronTrigger(expr); assertEquals(null, trigger.getFireTimeAfter(new GregorianCalendar(2011, 5, 29, 23, 1, 1).getTime())); }
Example #20
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 500) public void testSimpleDayOfWeekB() throws ParseException { final ScheduleExpression expr = new ScheduleExpression().dayOfWeek("5").hour(14).minute(1).second(59).start(new Date(0)); ; final EJBCronTrigger trigger = new EJBCronTrigger(expr); assertEquals(new GregorianCalendar(2011, 4, 6, 14, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 5, 23, 1, 30).getTime())); }
Example #21
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@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())); }
Example #22
Source File: TimerServiceImpl.java From tomee with Apache License 2.0 | 5 votes |
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; }
Example #23
Source File: GetTimerTest.java From tomee with Apache License 2.0 | 5 votes |
public void newTimer() { final TimerConfig tc = new TimerConfig("my-timer", true); final ScheduleExpression se = new ScheduleExpression(); final Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.SECOND, 2); se.second(calendar.get(Calendar.SECOND) + "/3"); se.minute("*"); se.hour("*"); se.dayOfMonth("*"); se.dayOfWeek("*"); se.month("*"); timer = timerService.createCalendarTimer(se, tc); }
Example #24
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 5000) public void testOrdinalNumbersDayOfMonthA() throws ParseException { final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("2nd mon").hour(23).minute(1).second(59).start(new Date(0)); final EJBCronTrigger trigger = new EJBCronTrigger(expr); assertEquals(new GregorianCalendar(2011, 4, 9, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 1, 0, 0, 0).getTime())); assertEquals(new GregorianCalendar(2011, 5, 13, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2011, 4, 10, 0, 0, 0).getTime())); }
Example #25
Source File: EJBCronTrigger.java From tomee with Apache License 2.0 | 5 votes |
public EJBCronTrigger(final ScheduleExpression expr) throws ParseException { final Map<Integer, String> fieldValues = new LinkedHashMap<>(); fieldValues.put(Calendar.YEAR, expr.getYear()); fieldValues.put(Calendar.MONTH, expr.getMonth()); fieldValues.put(Calendar.DAY_OF_MONTH, expr.getDayOfMonth()); fieldValues.put(Calendar.DAY_OF_WEEK, expr.getDayOfWeek()); fieldValues.put(Calendar.HOUR_OF_DAY, expr.getHour()); fieldValues.put(Calendar.MINUTE, expr.getMinute()); fieldValues.put(Calendar.SECOND, expr.getSecond()); timezone = expr.getTimezone() == null ? TimeZone.getDefault() : TimeZone.getTimeZone(expr.getTimezone()); setStartTime(expr.getStart() == null ? new Date() : expr.getStart()); setEndTime(expr.getEnd()); // If parsing fails on a field, record the error and move to the next field final Map<Integer, ParseException> errors = new HashMap<>(); int index = 0; for (final Entry<Integer, String> entry : fieldValues.entrySet()) { final int field = entry.getKey(); final String value = entry.getValue(); try { expressions[index++] = parseExpression(field, value); } catch (final ParseException e) { errors.put(field, e); } } // If there were parsing errors, throw a "master exception" that contains all // exceptions from individual fields if (!errors.isEmpty()) { throw new ParseException(errors); } rawValue = expr.getYear() + DELIMITER + expr.getMonth() + DELIMITER + expr.getDayOfMonth() + DELIMITER + expr.getDayOfWeek() + DELIMITER + expr.getHour() + DELIMITER + expr.getMinute() + DELIMITER + expr.getSecond(); }
Example #26
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 5000) public void testMinusDayOfMonth() throws ParseException { final ScheduleExpression expr = new ScheduleExpression().dayOfMonth(-2).hour(23).minute(1).second(59).start(new Date(0)); final EJBCronTrigger trigger = new EJBCronTrigger(expr); assertEquals(new GregorianCalendar(2009, 1, 26, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2009, 1, 1, 0, 0, 0).getTime())); //Test Leap year assertEquals(new GregorianCalendar(2000, 1, 27, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2000, 1, 26, 0, 0, 0).getTime())); //Test next month assertEquals(new GregorianCalendar(2000, 1, 27, 23, 1, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2000, 1, 26, 0, 0, 0).getTime())); }
Example #27
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@Test(timeout = 5000) public void testLastDayOfMonthA() throws ParseException { final ScheduleExpression expr = new ScheduleExpression().dayOfMonth("Last").hour(23).minute(59).second(59).start(new Date(0)); final EJBCronTrigger trigger = new EJBCronTrigger(expr); assertEquals(new GregorianCalendar(2009, 1, 28, 23, 59, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2009, 1, 1, 0, 0, 0).getTime())); //Test Leap year assertEquals(new GregorianCalendar(2000, 1, 29, 23, 59, 59).getTime(), trigger.getFireTimeAfter(new GregorianCalendar(2000, 1, 28, 0, 0, 0).getTime())); }
Example #28
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@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())); }
Example #29
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@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())); }
Example #30
Source File: EJBCronTriggerTest.java From tomee with Apache License 2.0 | 5 votes |
@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())); }