CronSequenceGenerator.isValidExpression actually validates cron fields

Issue: SPR-15604
This commit is contained in:
Juergen Hoeller
2017-06-30 01:54:32 +02:00
parent cc74a2891a
commit 5f4d1a4628
2 changed files with 44 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import static org.junit.Assert.*;
/**
* @author Juergen Hoeller
* @author Ruslan Sibgatullin
*/
@SuppressWarnings("deprecation")
public class CronSequenceGeneratorTests {
@@ -82,10 +83,20 @@ public class CronSequenceGeneratorTests {
}
@Test
public void invalidExpression() {
public void invalidExpressionWithLength() {
assertFalse(CronSequenceGenerator.isValidExpression("0 */2 1-4 * * * *"));
}
@Test
public void invalidExpressionWithSeconds() {
assertFalse(CronSequenceGenerator.isValidExpression("100 */2 1-4 * * *"));
}
@Test
public void invalidExpressionWithMonths() {
assertFalse(CronSequenceGenerator.isValidExpression("0 */2 1-4 * INVALID *"));
}
@Test
public void nullExpression() {
assertFalse(CronSequenceGenerator.isValidExpression(null));