Skip to content

Commit dbec16d

Browse files
committed
Add test for Friday 13th crontab failure
Added test for Friday 13th trigger, i.e. an uncommon crontab expression. With the new CronExpression in place, this failure does not occur anymore. Closes gh-21574
1 parent 72895f0 commit dbec16d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spring-context/src/test/java/org/springframework/scheduling/support/CronExpressionTests.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import org.junit.jupiter.api.Test;
2727

28+
import static java.time.DayOfWeek.FRIDAY;
2829
import static java.time.DayOfWeek.MONDAY;
2930
import static java.time.DayOfWeek.TUESDAY;
3031
import static java.time.DayOfWeek.WEDNESDAY;
@@ -444,4 +445,21 @@ public void fixedDays() {
444445
assertThat(actual.getDayOfWeek()).isEqualTo(WEDNESDAY);
445446
}
446447

448+
@Test
449+
void friday13th() {
450+
CronExpression expression = CronExpression.parse("0 0 0 13 * FRI");
451+
452+
LocalDateTime last = LocalDateTime.of(2018, 7, 31, 11, 47, 14);
453+
LocalDateTime actual = expression.next(last);
454+
assertThat(actual).isNotNull();
455+
assertThat(actual.getDayOfWeek()).isEqualTo(FRIDAY);
456+
assertThat(actual.getDayOfMonth()).isEqualTo(13);
457+
458+
last = actual;
459+
actual = expression.next(last);
460+
assertThat(actual).isNotNull();
461+
assertThat(actual.getDayOfWeek()).isEqualTo(FRIDAY);
462+
assertThat(actual.getDayOfMonth()).isEqualTo(13);
463+
}
464+
447465
}

0 commit comments

Comments
 (0)