Added cron expression validation method for CronSequenceGenerator
It's handy to know in advance whether or not expression that is passed to CronSequenceGenerator or CronTrigger constructor would not results in IllegalArgumentException. The only way to do it now is to try\catch an instance creation but it's kinda ugly.
This commit is contained in:
@@ -56,4 +56,18 @@ public class CronSequenceGeneratorTests {
|
||||
new CronSequenceGenerator("*/-1 * * * * *").next(new Date(2012, 6, 1, 9, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidExpression() {
|
||||
assertTrue(CronSequenceGenerator.isValidExpression("0 */2 1-4 * * *"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotValidExpression() {
|
||||
assertFalse(CronSequenceGenerator.isValidExpression("0 */2 1-4 * * * *"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullExpression() {
|
||||
assertFalse(CronSequenceGenerator.isValidExpression(null));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user