public void testEveryMorningFiveFifteen() {
ScheduleExpression everyMorningFiveFifteen = this.getTimezoneSpecificScheduleExpression();
everyMorningFiveFifteen.minute(15);
everyMorningFiveFifteen.hour(5);
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(everyMorningFiveFifteen);
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);
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, 5, hour);
Assert.assertEquals("Unexpected AM/PM in first timeout ", Calendar.AM, amOrPm);
Calendar previousTimeout = firstTimeout;
for (int i = 1; i <= 370; 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));
logger.debug("First timeout was: " + firstTimeout.getTime() + " Previous timeout was: "
+ previousTimeout.getTime() + " Next timeout is " + nextTimeout.getTime());