use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method incrementSecondByOne.
@ParameterizedCronTriggerTest
void incrementSecondByOne(Date localDateTime, TimeZone timeZone) {
setup(localDateTime, timeZone);
CronTrigger trigger = new CronTrigger("11 * * * * *", timeZone);
this.calendar.set(Calendar.SECOND, 10);
Date localDate = this.calendar.getTime();
this.calendar.add(Calendar.SECOND, 1);
TriggerContext context = getTriggerContext(localDate);
assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime());
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method monthSequence.
@ParameterizedCronTriggerTest
void monthSequence(Date localDateTime, TimeZone timeZone) {
setup(localDateTime, timeZone);
CronTrigger trigger = new CronTrigger("0 30 23 30 1/3 ?", timeZone);
this.calendar.set(2010, 11, 30);
Date localDate = this.calendar.getTime();
// set expected next trigger time
this.calendar.set(Calendar.HOUR_OF_DAY, 23);
this.calendar.set(Calendar.MINUTE, 30);
this.calendar.set(Calendar.SECOND, 0);
this.calendar.add(Calendar.MONTH, 1);
TriggerContext context1 = getTriggerContext(localDate);
Object actual2 = localDate = trigger.nextExecutionTime(context1);
assertThat(actual2).isEqualTo(this.calendar.getTime());
// Next trigger is 3 months latter
this.calendar.add(Calendar.MONTH, 3);
TriggerContext context2 = getTriggerContext(localDate);
Object actual1 = localDate = trigger.nextExecutionTime(context2);
assertThat(actual1).isEqualTo(this.calendar.getTime());
// Next trigger is 3 months latter
this.calendar.add(Calendar.MONTH, 3);
TriggerContext context3 = getTriggerContext(localDate);
Object actual = trigger.nextExecutionTime(context3);
assertThat(actual).isEqualTo(this.calendar.getTime());
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method monthlyTriggerInShortMonth.
@ParameterizedCronTriggerTest
void monthlyTriggerInShortMonth(Date localDateTime, TimeZone timeZone) {
setup(localDateTime, timeZone);
CronTrigger trigger = new CronTrigger("0 0 0 1 * *", timeZone);
this.calendar.set(Calendar.MONTH, 9);
this.calendar.set(Calendar.DAY_OF_MONTH, 30);
Date localDate = this.calendar.getTime();
this.calendar.set(Calendar.MONTH, 10);
this.calendar.set(Calendar.DAY_OF_MONTH, 1);
this.calendar.set(Calendar.HOUR_OF_DAY, 0);
this.calendar.set(Calendar.MINUTE, 0);
this.calendar.set(Calendar.SECOND, 0);
TriggerContext context = getTriggerContext(localDate);
assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime());
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method incrementMonthAndRollover.
@ParameterizedCronTriggerTest
void incrementMonthAndRollover(Date localDateTime, TimeZone timeZone) {
setup(localDateTime, timeZone);
CronTrigger trigger = new CronTrigger("0 0 0 1 * *", timeZone);
this.calendar.set(Calendar.MONTH, 11);
this.calendar.set(Calendar.DAY_OF_MONTH, 31);
this.calendar.set(Calendar.YEAR, 2010);
Date localDate = this.calendar.getTime();
this.calendar.set(Calendar.DAY_OF_MONTH, 1);
this.calendar.set(Calendar.HOUR_OF_DAY, 0);
this.calendar.set(Calendar.MINUTE, 0);
this.calendar.set(Calendar.SECOND, 0);
this.calendar.set(Calendar.MONTH, 0);
this.calendar.set(Calendar.YEAR, 2011);
TriggerContext context1 = getTriggerContext(localDate);
Object actual = localDate = trigger.nextExecutionTime(context1);
assertThat(actual).isEqualTo(this.calendar.getTime());
this.calendar.set(Calendar.MONTH, 1);
TriggerContext context2 = getTriggerContext(localDate);
assertThat(trigger.nextExecutionTime(context2)).isEqualTo(this.calendar.getTime());
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method incrementDayOfMonthAndRollover.
@ParameterizedCronTriggerTest
void incrementDayOfMonthAndRollover(Date localDateTime, TimeZone timeZone) {
setup(localDateTime, timeZone);
CronTrigger trigger = new CronTrigger("* * * 10 * *", timeZone);
this.calendar.set(Calendar.DAY_OF_MONTH, 11);
Date localDate = this.calendar.getTime();
this.calendar.add(Calendar.MONTH, 1);
this.calendar.set(Calendar.DAY_OF_MONTH, 10);
this.calendar.set(Calendar.HOUR_OF_DAY, 0);
this.calendar.set(Calendar.MINUTE, 0);
this.calendar.set(Calendar.SECOND, 0);
TriggerContext context = getTriggerContext(localDate);
assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime());
}
Aggregations