use of org.springframework.batch.core.JobParameters in project spring-boot by spring-projects.
the class BatchAutoConfigurationTests method testDefinesAndLaunchesJob.
@Test
public void testDefinesAndLaunchesJob() throws Exception {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JobConfiguration.class, EmbeddedDataSourceConfiguration.class, BatchAutoConfiguration.class, TransactionAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
this.context.getBean(JobLauncherCommandLineRunner.class).run();
assertThat(this.context.getBean(JobRepository.class).getLastJobExecution("job", new JobParameters())).isNotNull();
}
use of org.springframework.batch.core.JobParameters in project spring-boot by spring-projects.
the class JobLauncherCommandLineRunnerTests method retryFailedExecutionOnNonRestartableJob.
@Test
public void retryFailedExecutionOnNonRestartableJob() throws Exception {
this.job = this.jobs.get("job").preventRestart().start(this.steps.get("step").tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
throw new RuntimeException("Planned");
}
}).build()).incrementer(new RunIdIncrementer()).build();
this.runner.execute(this.job, new JobParameters());
this.runner.execute(this.job, new JobParameters());
// A failed job that is not restartable does not re-use the job params of
// the last execution, but creates a new job instance when running it again.
assertThat(this.jobExplorer.getJobInstances("job", 0, 100)).hasSize(2);
}
use of org.springframework.batch.core.JobParameters in project spring-boot by spring-projects.
the class JobLauncherCommandLineRunner method launchJobFromProperties.
protected void launchJobFromProperties(Properties properties) throws JobExecutionException {
JobParameters jobParameters = this.converter.getJobParameters(properties);
executeLocalJobs(jobParameters);
executeRegisteredJobs(jobParameters);
}
use of org.springframework.batch.core.JobParameters in project camel by apache.
the class SpringBatchEndpointTest method shouldConvertDateHeadersToJobParams.
@Test
public void shouldConvertDateHeadersToJobParams() throws Exception {
// Given
String headerKey = "headerKey";
Date headerValue = new Date();
// When
template.sendBodyAndHeader("direct:start", "Start the job, please.", headerKey, headerValue);
// Then
ArgumentCaptor<JobParameters> jobParameters = ArgumentCaptor.forClass(JobParameters.class);
verify(jobLauncher).run(any(Job.class), jobParameters.capture());
Date parameter = jobParameters.getValue().getDate(headerKey);
assertEquals(parameter, headerValue);
}
use of org.springframework.batch.core.JobParameters in project camel by apache.
the class SpringBatchEndpointTest method setNullValueToJobParams.
@Test
public void setNullValueToJobParams() throws Exception {
// Given
String headerKey = "headerKey";
Date headerValue = null;
// When
template.sendBodyAndHeader("direct:start", "Start the job, please.", headerKey, headerValue);
// Then
ArgumentCaptor<JobParameters> jobParameters = ArgumentCaptor.forClass(JobParameters.class);
verify(jobLauncher).run(any(Job.class), jobParameters.capture());
Date parameter = jobParameters.getValue().getDate(headerKey);
assertEquals(parameter, headerValue);
}
Aggregations