use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method testIncrementHourAndRollover.
@Test
public void testIncrementHourAndRollover() throws Exception {
CronTrigger trigger = new CronTrigger("0 0 * * * *", timeZone);
calendar.set(Calendar.MONTH, 9);
calendar.set(Calendar.DAY_OF_MONTH, 10);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 1);
calendar.set(Calendar.SECOND, 0);
Date date = calendar.getTime();
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.DAY_OF_MONTH, 11);
TriggerContext context1 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
calendar.set(Calendar.HOUR_OF_DAY, 1);
TriggerContext context2 = getTriggerContext(date);
assertEquals(calendar.getTime(), trigger.nextExecutionTime(context2));
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method testLeapYearSpecificDate.
@Test
public void testLeapYearSpecificDate() throws Exception {
CronTrigger trigger = new CronTrigger("0 0 0 29 2 *", timeZone);
calendar.set(Calendar.YEAR, 2007);
calendar.set(Calendar.DAY_OF_MONTH, 10);
// 2=February
calendar.set(Calendar.MONTH, 1);
Date date = calendar.getTime();
TriggerContext context1 = getTriggerContext(date);
calendar.set(Calendar.YEAR, 2008);
calendar.set(Calendar.DAY_OF_MONTH, 29);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
calendar.add(Calendar.YEAR, 4);
TriggerContext context2 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context2));
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method testDailyTriggerOnDaylightSavingBoundary.
@Test
public void testDailyTriggerOnDaylightSavingBoundary() throws Exception {
CronTrigger trigger = new CronTrigger("0 0 0 * * *", timeZone);
// October: 31 days and a daylight saving boundary in CET
calendar.set(Calendar.MONTH, 9);
calendar.set(Calendar.DAY_OF_MONTH, 30);
Date date = calendar.getTime();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.DAY_OF_MONTH, 31);
TriggerContext context1 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
// November
calendar.set(Calendar.MONTH, 10);
calendar.set(Calendar.DAY_OF_MONTH, 1);
TriggerContext context2 = getTriggerContext(date);
assertEquals(calendar.getTime(), trigger.nextExecutionTime(context2));
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method testDailyTriggerInLongMonth.
@Test
public void testDailyTriggerInLongMonth() throws Exception {
CronTrigger trigger = new CronTrigger("0 0 0 * * *", timeZone);
// August: 31 days and not a daylight saving boundary
calendar.set(Calendar.MONTH, 7);
calendar.set(Calendar.DAY_OF_MONTH, 30);
Date date = calendar.getTime();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.DAY_OF_MONTH, 31);
TriggerContext context1 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
// September
calendar.set(Calendar.MONTH, 8);
calendar.set(Calendar.DAY_OF_MONTH, 1);
TriggerContext context2 = getTriggerContext(date);
assertEquals(calendar.getTime(), trigger.nextExecutionTime(context2));
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method testIncrementHour.
@Test
public void testIncrementHour() throws Exception {
CronTrigger trigger = new CronTrigger("0 0 * * * *", timeZone);
calendar.set(Calendar.MONTH, 9);
calendar.set(Calendar.DAY_OF_MONTH, 30);
calendar.set(Calendar.HOUR_OF_DAY, 11);
calendar.set(Calendar.MINUTE, 1);
calendar.set(Calendar.SECOND, 0);
Date date = calendar.getTime();
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.HOUR_OF_DAY, 12);
TriggerContext context1 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
calendar.set(Calendar.HOUR_OF_DAY, 13);
TriggerContext context2 = getTriggerContext(date);
assertEquals(calendar.getTime(), trigger.nextExecutionTime(context2));
}
Aggregations