use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method incrementHour.
@ParameterizedCronTriggerTest
void incrementHour(Date localDateTime, TimeZone timeZone) {
setup(localDateTime, timeZone);
CronTrigger trigger = new CronTrigger("0 0 * * * *", timeZone);
this.calendar.set(Calendar.MONTH, 9);
this.calendar.set(Calendar.DAY_OF_MONTH, 30);
this.calendar.set(Calendar.HOUR_OF_DAY, 11);
this.calendar.set(Calendar.MINUTE, 1);
this.calendar.set(Calendar.SECOND, 0);
Date localDate = this.calendar.getTime();
this.calendar.set(Calendar.MINUTE, 0);
this.calendar.set(Calendar.HOUR_OF_DAY, 12);
TriggerContext context1 = getTriggerContext(localDate);
Object actual = localDate = trigger.nextExecutionTime(context1);
assertThat(actual).isEqualTo(this.calendar.getTime());
this.calendar.set(Calendar.HOUR_OF_DAY, 13);
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 specificDate.
@ParameterizedCronTriggerTest
void specificDate(Date localDateTime, TimeZone timeZone) {
setup(localDateTime, timeZone);
CronTrigger trigger = new CronTrigger("* * * 3 11 *", timeZone);
this.calendar.set(Calendar.DAY_OF_MONTH, 2);
this.calendar.set(Calendar.MONTH, 9);
Date localDate = this.calendar.getTime();
TriggerContext context1 = getTriggerContext(localDate);
this.calendar.add(Calendar.DAY_OF_MONTH, 1);
this.calendar.set(Calendar.HOUR_OF_DAY, 0);
// 10=November
this.calendar.set(Calendar.MONTH, 10);
this.calendar.set(Calendar.MINUTE, 0);
this.calendar.set(Calendar.SECOND, 0);
Object actual1 = localDate = trigger.nextExecutionTime(context1);
assertThat(actual1).isEqualTo(this.calendar.getTime());
this.calendar.add(Calendar.SECOND, 1);
TriggerContext context2 = getTriggerContext(localDate);
Object actual = trigger.nextExecutionTime(context2);
assertThat(actual).isEqualTo(this.calendar.getTime());
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method incrementDayOfWeekAndRollover.
@ParameterizedCronTriggerTest
void incrementDayOfWeekAndRollover(Date localDateTime, TimeZone timeZone) {
setup(localDateTime, timeZone);
CronTrigger trigger = new CronTrigger("* * * * * 2", timeZone);
this.calendar.set(Calendar.DAY_OF_WEEK, 4);
Date localDate = this.calendar.getTime();
this.calendar.add(Calendar.DAY_OF_MONTH, 6);
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());
assertThat(this.calendar.get(Calendar.DAY_OF_WEEK)).isEqualTo(Calendar.TUESDAY);
}
use of org.springframework.scheduling.TriggerContext in project spring-framework by spring-projects.
the class CronTriggerTests method incrementSecondAndRollover.
@ParameterizedCronTriggerTest
void incrementSecondAndRollover(Date localDateTime, TimeZone timeZone) {
setup(localDateTime, timeZone);
CronTrigger trigger = new CronTrigger("10 * * * * *", timeZone);
this.calendar.set(Calendar.SECOND, 11);
Date localDate = this.calendar.getTime();
this.calendar.add(Calendar.SECOND, 59);
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 monthlyTriggerInLongMonth.
@ParameterizedCronTriggerTest
void monthlyTriggerInLongMonth(Date localDateTime, TimeZone timeZone) {
setup(localDateTime, timeZone);
CronTrigger trigger = new CronTrigger("0 0 0 31 * *", timeZone);
this.calendar.set(Calendar.MONTH, 9);
this.calendar.set(Calendar.DAY_OF_MONTH, 30);
Date localDate = this.calendar.getTime();
this.calendar.set(Calendar.DAY_OF_MONTH, 31);
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