JobSchedulerConfiguration extends AbstractConfiguration { void validate() { if (this.jobSchedulerType == null) { this.throwExceptionAndLogError("jobSchedulerType must not be null"); } if (this.taskExecutorType == null) { this.throwExceptionAndLogError("taskExecutorType must not be null"); } if (JobSchedulerType.CRON.equals(this.jobSchedulerType)) { this.validateCron(); } else if (JobSchedulerType.PERIOD.equals(this.jobSchedulerType)) { this.validatePeriod(); } else { this.throwExceptionAndLogError("Unknown jobSchedulerType: " + this.jobSchedulerType); } }    }
@Test public void validateForPeriodTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setFixedDelay(1000L); jobSchedulerConfiguration.setInitialDelay(1000L); jobSchedulerConfiguration.setJobSchedulerType(JobSchedulerType.PERIOD); jobSchedulerConfiguration.setTaskExecutorType(TaskExecutorType.SYNCHRONOUS); try { jobSchedulerConfiguration.validate(); } catch (final SpringBatchLightminApplicationException e) { fail(e.getMessage()); } }
@Test public void validateForCronTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setCronExpression("0 0 12 * * ?"); jobSchedulerConfiguration.setJobSchedulerType(JobSchedulerType.CRON); jobSchedulerConfiguration.setTaskExecutorType(TaskExecutorType.SYNCHRONOUS); try { jobSchedulerConfiguration.validate(); } catch (final SpringBatchLightminApplicationException e) { fail(e.getMessage()); } }
@Test(expected = SpringBatchLightminApplicationException.class) public void validateSchedulerNullTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setCronExpression("0 0 12 * * ?"); jobSchedulerConfiguration.setJobSchedulerType(null); jobSchedulerConfiguration.setTaskExecutorType(TaskExecutorType.SYNCHRONOUS); jobSchedulerConfiguration.validate(); }
@Test(expected = SpringBatchLightminApplicationException.class) public void validateTaskExecutorNullTest() { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setCronExpression("0 0 12 * * ?"); jobSchedulerConfiguration.setJobSchedulerType(JobSchedulerType.CRON); jobSchedulerConfiguration.setTaskExecutorType(null); jobSchedulerConfiguration.validate(); }