I am trying to code a batch job using Spring Batch Java configuration and Quartz as the scheduler.
Relevant code snippet for java configuration :-
@Configuration
@EnableBatchProcessing
@EnableScheduling
public class BatchProcessingConfig {
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private EntityManagerFactory entityManagerFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Bean
@Qualifier("theJob")
public Job job() {
return jobBuilderFactory.get("theJobName")
.start(jobStep()).build();
}
@Bean
public Step jobStep() {
StepBuilder stepBuilder = stepBuilderFactory.get("stepName");
SimpleStepBuilder<Person, Person> chunk = stepBuilder
.<Person, Person> chunk(10);
return chunk.reader(personeReader())
.processor(jobProcessor()).build();
}
@Bean
public JobProcessor<Person, Person> invoiceRejobProcessorminderProcessor() {
return new JobProcessor();
}
The job has been wired the ItemReader and ItemProcessor.
I am able to successfully Junit Test the Job/Step using JobLauncherTestUtils class.
Problem :-
How can I configure Quartz scheduler to run the above configured Job.
All the samples & examples I could explore have created their own Job class by extending QuartzJobBean but I want my above configured Job to be scheduled for running.
How do I unit test the scheduler functionality.