use of org.jboss.as.ejb3.timerservice.schedule.CalendarBasedTimeout in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testEveryMinuteEveryHourEveryDay.
//@Test
public void testEveryMinuteEveryHourEveryDay() {
ScheduleExpression everyMinEveryHourEveryDay = this.getTimezoneSpecificScheduleExpression();
everyMinEveryHourEveryDay.minute("*");
everyMinEveryHourEveryDay.hour("*");
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(everyMinEveryHourEveryDay);
Calendar firstTimeout = calendarTimeout.getFirstTimeout();
Calendar previousTimeout = firstTimeout;
for (int i = 1; i <= 65; i++) {
Calendar nextTimeout = calendarTimeout.getNextTimeout(previousTimeout);
Assert.assertNotNull(timeZoneDisplayName, nextTimeout);
Assert.assertNotNull(timeZoneDisplayName, nextTimeout.after(previousTimeout));
// logger.debug("First timeout was: " + firstTimeout.getTime() + " Previous timeout was: "
// + previousTimeout.getTime() + " Next timeout is " + nextTimeout.getTime());
long diff = nextTimeout.getTimeInMillis() - previousTimeout.getTimeInMillis();
long diffWithFirstTimeout = nextTimeout.getTimeInMillis() - firstTimeout.getTimeInMillis();
Assert.assertEquals(timeZoneDisplayName, 60 * 1000, diff);
Assert.assertEquals(timeZoneDisplayName, 60 * 1000 * i, diffWithFirstTimeout);
previousTimeout = nextTimeout;
}
}
use of org.jboss.as.ejb3.timerservice.schedule.CalendarBasedTimeout in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testEvery31stOfTheMonth.
//@Test
public void testEvery31stOfTheMonth() {
ScheduleExpression every31st9_30_15_AM = this.getTimezoneSpecificScheduleExpression();
every31st9_30_15_AM.dayOfMonth(31);
every31st9_30_15_AM.hour(9);
every31st9_30_15_AM.minute("30");
every31st9_30_15_AM.second(15);
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(every31st9_30_15_AM);
Calendar firstTimeout = calendarTimeout.getFirstTimeout();
Assert.assertNotNull(timeZoneDisplayName, firstTimeout);
int minute = firstTimeout.get(Calendar.MINUTE);
int second = firstTimeout.get(Calendar.SECOND);
int hour = firstTimeout.get(Calendar.HOUR_OF_DAY);
int amOrPm = firstTimeout.get(Calendar.AM_PM);
int dayOfMonth = firstTimeout.get(Calendar.DAY_OF_MONTH);
Assert.assertEquals(timeZoneDisplayName, 15, second);
Assert.assertEquals(timeZoneDisplayName, 30, minute);
Assert.assertEquals(timeZoneDisplayName, 9, hour);
Assert.assertEquals(timeZoneDisplayName, Calendar.AM, amOrPm);
Assert.assertEquals(timeZoneDisplayName, 31, dayOfMonth);
Calendar previousTimeout = firstTimeout;
for (int i = 1; i <= 18; i++) {
Calendar nextTimeout = calendarTimeout.getNextTimeout(previousTimeout);
Assert.assertNotNull(timeZoneDisplayName, nextTimeout);
Assert.assertNotNull(timeZoneDisplayName, nextTimeout.after(previousTimeout));
// logger.debug("First timeout was: " + firstTimeoutDate + " Previous timeout was: " + previousTimeout.getTime()
// + " Next timeout is " + nextTimeoutDate);
int nextMinute = nextTimeout.get(Calendar.MINUTE);
int nextSecond = nextTimeout.get(Calendar.SECOND);
int nextHour = nextTimeout.get(Calendar.HOUR_OF_DAY);
int nextAmOrPm = nextTimeout.get(Calendar.AM_PM);
int nextDayOfMonth = nextTimeout.get(Calendar.DAY_OF_MONTH);
Assert.assertEquals(timeZoneDisplayName, 15, nextSecond);
Assert.assertEquals(timeZoneDisplayName, 30, nextMinute);
Assert.assertEquals(timeZoneDisplayName, 9, nextHour);
Assert.assertEquals(timeZoneDisplayName, Calendar.AM, nextAmOrPm);
Assert.assertEquals(timeZoneDisplayName, 31, nextDayOfMonth);
previousTimeout = nextTimeout;
}
}
Aggregations