use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method testDaylightSavingMissingHour.
@Test
public void testDaylightSavingMissingHour() throws Exception {
// This trigger has to be somewhere in between 2am and 3am
CronTrigger trigger = new CronTrigger("0 10 2 * * *", timeZone);
calendar.set(Calendar.DAY_OF_MONTH, 31);
calendar.set(Calendar.MONTH, Calendar.MARCH);
calendar.set(Calendar.YEAR, 2013);
calendar.set(Calendar.HOUR_OF_DAY, 1);
calendar.set(Calendar.SECOND, 54);
Date date = calendar.getTime();
TriggerContext context1 = getTriggerContext(date);
if (timeZone.equals(TimeZone.getTimeZone("CET"))) {
// Clocks go forward an hour so 2am doesn't exist in CET for this date
calendar.add(Calendar.DAY_OF_MONTH, 1);
}
calendar.add(Calendar.HOUR_OF_DAY, 1);
calendar.set(Calendar.MINUTE, 10);
calendar.set(Calendar.SECOND, 0);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method testDailyTriggerInShortMonth.
@Test
public void testDailyTriggerInShortMonth() throws Exception {
CronTrigger trigger = new CronTrigger("0 0 0 * * *", timeZone);
// September: 30 days
calendar.set(Calendar.MONTH, 8);
calendar.set(Calendar.DAY_OF_MONTH, 30);
Date date = calendar.getTime();
// October
calendar.set(Calendar.MONTH, 9);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.DAY_OF_MONTH, 1);
TriggerContext context1 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
calendar.set(Calendar.DAY_OF_MONTH, 2);
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 testIncrementMonth.
@Test
public void testIncrementMonth() throws Exception {
CronTrigger trigger = new CronTrigger("0 0 0 1 * *", timeZone);
calendar.set(Calendar.MONTH, 9);
calendar.set(Calendar.DAY_OF_MONTH, 30);
Date date = calendar.getTime();
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MONTH, 10);
TriggerContext context1 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
calendar.set(Calendar.MONTH, 11);
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 testMatchAll.
@Test
public void testMatchAll() throws Exception {
CronTrigger trigger = new CronTrigger("* * * * * *", timeZone);
TriggerContext context = getTriggerContext(date);
assertEquals(calendar.getTime(), trigger.nextExecutionTime(context));
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method testIncrementMinuteAndRollover.
@Test
public void testIncrementMinuteAndRollover() throws Exception {
CronTrigger trigger = new CronTrigger("0 10 * * * *", timeZone);
calendar.set(Calendar.MINUTE, 11);
calendar.set(Calendar.SECOND, 0);
Date date = calendar.getTime();
calendar.add(Calendar.MINUTE, 59);
TriggerContext context = getTriggerContext(date);
assertEquals(calendar.getTime(), trigger.nextExecutionTime(context));
}
Aggregations