JobSchedulerConfiguration extends AbstractConfiguration { void validateCron() { if (this.cronExpression == null) { this.throwExceptionAndLogError("cronExpression must not be null for CRON Scheduler"); } else if (!CronExpression.isValidExpression(this.cronExpression)) { this.throwExceptionAndLogError("cronExpression : " + this.cronExpression + " is not valid"); } if (this.initialDelay != null) { this.throwExceptionAndLogError("initialDelay must not be set for CRON Scheduler"); } if (this.fixedDelay != null) { this.throwExceptionAndLogError("fixedDelay must not be set for CRON Scheduler"); } }    }
@Test public void validateCronTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setCronExpression("0 0 12 * * ?"); try { jobSchedulerConfiguration.validateCron(); } catch (final SpringBatchLightminApplicationException e) { fail(e.getMessage()); } }
@Test(expected = SpringBatchLightminApplicationException.class) public void validateCronExpressionNullTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setCronExpression(null); jobSchedulerConfiguration.validateCron(); }
@Test(expected = SpringBatchLightminApplicationException.class) public void validateCronExpressionNotValidTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setCronExpression("invalid"); jobSchedulerConfiguration.validateCron(); }
@Test(expected = SpringBatchLightminApplicationException.class) public void validateCronExpressionFixedDelaySetTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setCronExpression("0 0 12 * * ?"); jobSchedulerConfiguration.setFixedDelay(1000L); jobSchedulerConfiguration.validateCron(); }
@Test(expected = SpringBatchLightminApplicationException.class) public void validateCronExpressionInitialDelaySetTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setCronExpression("0 0 12 * * ?"); jobSchedulerConfiguration.setInitialDelay(1000L); jobSchedulerConfiguration.validateCron(); }
@Test(expected = SpringBatchLightminApplicationException.class) public void validatePeriodFixedDelayNullTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.validateCron(); }
@Test(expected = SpringBatchLightminApplicationException.class) public void validatePeriodFixedDelayNegativTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setFixedDelay(-1000L); jobSchedulerConfiguration.validateCron(); }
@Test(expected = SpringBatchLightminApplicationException.class) public void validatePeriodInitialDelayNegativTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setFixedDelay(-1000L); jobSchedulerConfiguration.setInitialDelay(-1000L); jobSchedulerConfiguration.validateCron(); }
@Test(expected = SpringBatchLightminApplicationException.class) public void validatePeriodCronExpressionSetTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setFixedDelay(1000L); jobSchedulerConfiguration.setInitialDelay(1000L); jobSchedulerConfiguration.setCronExpression("0 0 12 * * ?"); jobSchedulerConfiguration.validateCron(); }