use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method testIncrementSecondAndRollover.
@Test
public void testIncrementSecondAndRollover() throws Exception {
CronTrigger trigger = new CronTrigger("10 * * * * *", timeZone);
calendar.set(Calendar.SECOND, 11);
Date date = calendar.getTime();
calendar.add(Calendar.SECOND, 59);
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 testWeekDaySequence.
@Test
public void testWeekDaySequence() throws Exception {
CronTrigger trigger = new CronTrigger("0 0 7 ? * MON-FRI", timeZone);
// This is a Saturday
calendar.set(2009, 8, 26);
Date date = calendar.getTime();
// 7 am is the trigger time
calendar.set(Calendar.HOUR_OF_DAY, 7);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
// Add two days because we start on Saturday
calendar.add(Calendar.DAY_OF_MONTH, 2);
TriggerContext context1 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
// Next day is a week day so add one
calendar.add(Calendar.DAY_OF_MONTH, 1);
TriggerContext context2 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context2));
calendar.add(Calendar.DAY_OF_MONTH, 1);
TriggerContext context3 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context3));
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method testSpecificDayOfMonthSecond.
@Test
public void testSpecificDayOfMonthSecond() throws Exception {
CronTrigger trigger = new CronTrigger("55 * * 3 * *", timeZone);
calendar.set(Calendar.DAY_OF_MONTH, 2);
calendar.set(Calendar.SECOND, 54);
Date date = calendar.getTime();
TriggerContext context1 = getTriggerContext(date);
calendar.add(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 55);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
calendar.add(Calendar.MINUTE, 1);
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 testIncrementDayOfMonthAndRollover.
@Test
public void testIncrementDayOfMonthAndRollover() throws Exception {
CronTrigger trigger = new CronTrigger("* * * 10 * *", timeZone);
calendar.set(Calendar.DAY_OF_MONTH, 11);
Date date = calendar.getTime();
calendar.add(Calendar.MONTH, 1);
calendar.set(Calendar.DAY_OF_MONTH, 10);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
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 testSpecificMinuteSecond.
@Test
public void testSpecificMinuteSecond() throws Exception {
CronTrigger trigger = new CronTrigger("55 5 * * * *", timeZone);
calendar.set(Calendar.MINUTE, 4);
calendar.set(Calendar.SECOND, 54);
Date date = calendar.getTime();
TriggerContext context1 = getTriggerContext(date);
calendar.add(Calendar.MINUTE, 1);
calendar.set(Calendar.SECOND, 55);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
calendar.add(Calendar.HOUR, 1);
TriggerContext context2 = getTriggerContext(date);
assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context2));
}
Aggregations