use of org.jboss.as.ejb3.timerservice.schedule.CalendarBasedTimeout in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testRun29thOfFeb.
//@Test
public void testRun29thOfFeb() {
ScheduleExpression everyLeapYearOn29thFeb = this.getTimezoneSpecificScheduleExpression();
everyLeapYearOn29thFeb.dayOfMonth(29);
everyLeapYearOn29thFeb.month("fEb");
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(everyLeapYearOn29thFeb);
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);
int month = firstTimeout.get(Calendar.MONTH);
Assert.assertEquals(timeZoneDisplayName, 0, second);
Assert.assertEquals(timeZoneDisplayName, 0, minute);
Assert.assertEquals(timeZoneDisplayName, 0, hour);
Assert.assertEquals(timeZoneDisplayName, Calendar.AM, amOrPm);
Assert.assertEquals(timeZoneDisplayName, 29, dayOfMonth);
Assert.assertEquals(timeZoneDisplayName, Calendar.FEBRUARY, month);
Assert.assertTrue(timeZoneDisplayName, this.isLeapYear(firstTimeout));
Calendar previousTimeout = firstTimeout;
for (int i = 1; i <= 2; 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);
int nextMonth = nextTimeout.get(Calendar.MONTH);
Assert.assertEquals(timeZoneDisplayName, 0, nextSecond);
Assert.assertEquals(timeZoneDisplayName, 0, nextMinute);
Assert.assertEquals(timeZoneDisplayName, 0, nextHour);
Assert.assertEquals(timeZoneDisplayName, Calendar.AM, nextAmOrPm);
Assert.assertEquals(timeZoneDisplayName, 29, nextDayOfMonth);
Assert.assertEquals(timeZoneDisplayName, Calendar.FEBRUARY, nextMonth);
Assert.assertTrue(timeZoneDisplayName, this.isLeapYear(nextTimeout));
previousTimeout = nextTimeout;
}
}
use of org.jboss.as.ejb3.timerservice.schedule.CalendarBasedTimeout in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testEveryMonWedFriTwelveThirtyNoon.
//@Test
public void testEveryMonWedFriTwelveThirtyNoon() {
ScheduleExpression everyMonWedFriTwelveThirtyNoon = this.getTimezoneSpecificScheduleExpression();
everyMonWedFriTwelveThirtyNoon.hour(12);
everyMonWedFriTwelveThirtyNoon.second("30");
everyMonWedFriTwelveThirtyNoon.dayOfWeek("Mon,Wed,Fri");
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(everyMonWedFriTwelveThirtyNoon);
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 dayOfWeek = firstTimeout.get(Calendar.DAY_OF_WEEK);
Assert.assertEquals(timeZoneDisplayName, 30, second);
Assert.assertEquals(timeZoneDisplayName, 0, minute);
Assert.assertEquals(timeZoneDisplayName, 12, hour);
Assert.assertEquals(timeZoneDisplayName, Calendar.PM, amOrPm);
List<Integer> validDays = new ArrayList<Integer>();
validDays.add(Calendar.MONDAY);
validDays.add(Calendar.WEDNESDAY);
validDays.add(Calendar.FRIDAY);
Assert.assertTrue(timeZoneDisplayName, validDays.contains(dayOfWeek));
Calendar previousTimeout = firstTimeout;
for (int i = 1; i <= 180; 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 nextDayOfWeek = nextTimeout.get(Calendar.DAY_OF_WEEK);
Assert.assertEquals(timeZoneDisplayName, 30, nextSecond);
Assert.assertEquals(timeZoneDisplayName, 0, nextMinute);
Assert.assertEquals(timeZoneDisplayName, 12, nextHour);
Assert.assertEquals(timeZoneDisplayName, Calendar.PM, nextAmOrPm);
Assert.assertTrue(timeZoneDisplayName, validDays.contains(nextDayOfWeek));
previousTimeout = nextTimeout;
}
}
use of org.jboss.as.ejb3.timerservice.schedule.CalendarBasedTimeout in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testEvery10Seconds.
//@Test
public void testEvery10Seconds() {
ScheduleExpression every10Secs = this.getTimezoneSpecificScheduleExpression();
every10Secs.second("*/10");
every10Secs.minute("*");
every10Secs.hour("*");
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(every10Secs);
Calendar firstTimeout = calendarTimeout.getFirstTimeout();
int firstTimeoutSecond = firstTimeout.get(Calendar.SECOND);
Assert.assertTrue(timeZoneDisplayName, firstTimeoutSecond % 10 == 0);
Calendar previousTimeout = firstTimeout;
for (int i = 0; i < 5; i++) {
Calendar nextTimeout = calendarTimeout.getNextTimeout(previousTimeout);
int nextTimeoutSecond = nextTimeout.get(Calendar.SECOND);
Assert.assertTrue(timeZoneDisplayName, nextTimeoutSecond % 10 == 0);
previousTimeout = nextTimeout;
}
}
use of org.jboss.as.ejb3.timerservice.schedule.CalendarBasedTimeout in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testNextDayOfWeek.
private void testNextDayOfWeek(Date start) {
ScheduleExpression expression = new ScheduleExpression();
expression.dayOfWeek("6");
expression.hour("3");
expression.minute("21");
expression.second("50");
expression.start(start);
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(expression);
Calendar firstTimeout = calendarTimeout.getFirstTimeout();
Assert.assertNotNull(firstTimeout);
Assert.assertEquals(50, firstTimeout.get(Calendar.SECOND));
Assert.assertEquals(21, firstTimeout.get(Calendar.MINUTE));
Assert.assertEquals(3, firstTimeout.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(7, firstTimeout.get(Calendar.DAY_OF_WEEK));
Assert.assertEquals(29, firstTimeout.get(Calendar.DAY_OF_MONTH));
}
use of org.jboss.as.ejb3.timerservice.schedule.CalendarBasedTimeout in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testEveryMorningFiveFifteen.
//@Test
public void testEveryMorningFiveFifteen() {
ScheduleExpression everyMorningFiveFifteen = this.getTimezoneSpecificScheduleExpression();
everyMorningFiveFifteen.minute(15);
everyMorningFiveFifteen.hour(5);
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(everyMorningFiveFifteen);
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);
Assert.assertEquals(timeZoneDisplayName, 0, second);
Assert.assertEquals(timeZoneDisplayName, 15, minute);
Assert.assertEquals(timeZoneDisplayName, 5, hour);
Assert.assertEquals(timeZoneDisplayName, Calendar.AM, amOrPm);
Calendar previousTimeout = firstTimeout;
for (int i = 1; i <= 370; 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());
Assert.assertEquals(timeZoneDisplayName, 0, nextTimeout.get(Calendar.SECOND));
Assert.assertEquals(timeZoneDisplayName, 15, nextTimeout.get(Calendar.MINUTE));
Assert.assertEquals(timeZoneDisplayName, 5, nextTimeout.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(timeZoneDisplayName, Calendar.AM, nextTimeout.get(Calendar.AM_PM));
previousTimeout = nextTimeout;
}
}
Aggregations