ScheduleExpression everyWeekDayThreeFifteen = this.getTimezoneSpecificScheduleExpression();
everyWeekDayThreeFifteen.minute(15);
everyWeekDayThreeFifteen.hour(8);
everyWeekDayThreeFifteen.dayOfWeek("Mon-Fri");
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(everyWeekDayThreeFifteen);
Calendar firstTimeout = calendarTimeout.getFirstTimeout();
Assert.assertNotNull("first timeout is null", firstTimeout);
Date firstTimeoutDate = firstTimeout.getTime();
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("Unexpected second in first timeout " + firstTimeoutDate, 0, second);
Assert.assertEquals("Unexpected minute in first timeout " + firstTimeoutDate, 15, minute);
Assert.assertEquals("Unexpected hour in first timeout " + firstTimeoutDate, 8, hour);
Assert.assertEquals("Unexpected AM/PM in first timeout ", Calendar.AM, amOrPm);
Assert.assertTrue("Unexpected day of week: " + dayOfWeek + " in first timeout", this.isWeekDay(firstTimeout));
Calendar previousTimeout = firstTimeout;
for (int i = 1; i <= 180; i++) {
Calendar nextTimeout = calendarTimeout.getNextTimeout(previousTimeout);
Assert.assertNotNull("Next timeout is null", nextTimeout);
Assert.assertNotNull("Next timeout is *before* the current time", nextTimeout.after(previousTimeout));
Date nextTimeoutDate = nextTimeout.getTime();