Java Code Examples for com.cronutils.model.Cron#validate()
The following examples show how to use
com.cronutils.model.Cron#validate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Issue200Test.java From cron-utils with Apache License 2.0 | 7 votes |
@Test public void testMustMatchCronEvenIfNanoSecondsVaries() { final CronDefinition cronDefinition = CronDefinitionBuilder.instanceDefinitionFor(QUARTZ); final CronParser parser = new CronParser(cronDefinition); final Cron quartzCron = parser.parse("00 00 10 * * ?"); quartzCron.validate(); // NOTE: Off by 3 nano seconds final ZonedDateTime zdt = ZonedDateTime.of(1999, 07, 18, 10, 00, 00, 03, ZoneId.systemDefault()); // Must be true assertTrue("Nano seconds must not affect matching of Cron Expressions", ExecutionTime.forCron(quartzCron).isMatch(zdt)); }
Example 2
Source File: CronParserQuartzIntegrationTest.java From cron-utils with Apache License 2.0 | 6 votes |
/** * Issue #154: Quartz Cron Year Pattern is not fully supported - i.e. increments on years are not supported * https://github.com/jmrozanec/cron-utils/issues/154 * Duplicate of #148 */ @Test public void supportQuartzCronExpressionIncrementsOnYears() { final String[] sampleCronExpressions = { "0 0 0 1 * ? 2017/2", "0 0 0 1 * ? 2017/3", "0 0 0 1 * ? 2017/10", "0 0 0 1 * ? 2017-2047/2", }; final CronParser quartzCronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ)); for (final String cronExpression : sampleCronExpressions) { final Cron quartzCron = quartzCronParser.parse(cronExpression); quartzCron.validate(); } }
Example 3
Source File: Issue200Test.java From cron-utils with Apache License 2.0 | 5 votes |
@Test public void testMatchExact() { final CronDefinition cronDefinition = CronDefinitionBuilder.instanceDefinitionFor(QUARTZ); final CronParser parser = new CronParser(cronDefinition); final Cron quartzCron = parser.parse("00 00 10 * * ?"); quartzCron.validate(); final ZonedDateTime zdt = ZonedDateTime.of(1999, 07, 18, 10, 00, 00, 00, ZoneId.systemDefault()); assertTrue("Nano seconds must not affect matching of Cron Expressions", ExecutionTime.forCron(quartzCron).isMatch(zdt)); }
Example 4
Source File: CronDefinitionBuilderTest.java From cron-utils with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testCronDefinitionShouldNotAcceptQuestionmark() { final CronDefinition cronDefinition = CronDefinitionBuilder.instanceDefinitionFor(CronType.UNIX); final CronParser parser = new CronParser(cronDefinition); final Cron quartzCron = parser.parse("* * * * ?"); quartzCron.validate(); }