CronSequenceGenerator prevents stack overflow in case of inverted range

Issue: SPR-14462
(cherry picked from commit e431624)
This commit is contained in:
Juergen Hoeller
2016-07-14 21:11:28 +02:00
parent 0065a160cc
commit da59b4da9b
2 changed files with 26 additions and 0 deletions

View File

@@ -56,6 +56,26 @@ public class CronSequenceGeneratorTests {
new CronSequenceGenerator("*/-1 * * * * *").next(new Date(2012, 6, 1, 9, 0));
}
@Test(expected = IllegalArgumentException.class)
public void withInvertedMinuteRange() {
new CronSequenceGenerator("* 6-5 * * * *").next(new Date(2012, 6, 1, 9, 0));
}
@Test(expected = IllegalArgumentException.class)
public void withInvertedHourRange() {
new CronSequenceGenerator("* * 6-5 * * *").next(new Date(2012, 6, 1, 9, 0));
}
@Test
public void withSameMinuteRange() {
new CronSequenceGenerator("* 6-6 * * * *").next(new Date(2012, 6, 1, 9, 0));
}
@Test
public void withSameHourRange() {
new CronSequenceGenerator("* * 6-6 * * *").next(new Date(2012, 6, 1, 9, 0));
}
@Test
public void validExpression() {
assertTrue(CronSequenceGenerator.isValidExpression("0 */2 1-4 * * *"));