|
|
@ -16,6 +16,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.batch;
|
|
|
|
package org.springframework.boot.autoconfigure.batch;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.springframework.batch.core.Job;
|
|
|
|
import org.springframework.batch.core.Job;
|
|
|
@ -43,8 +45,6 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.core.task.SyncTaskExecutor;
|
|
|
|
import org.springframework.core.task.SyncTaskExecutor;
|
|
|
|
import org.springframework.transaction.PlatformTransactionManager;
|
|
|
|
import org.springframework.transaction.PlatformTransactionManager;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Tests for {@link JobLauncherCommandLineRunner}.
|
|
|
|
* Tests for {@link JobLauncherCommandLineRunner}.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -124,6 +124,24 @@ public class JobLauncherCommandLineRunnerTests {
|
|
|
|
assertEquals(1, this.jobExplorer.getJobInstances("job", 0, 100).size());
|
|
|
|
assertEquals(1, this.jobExplorer.getJobInstances("job", 0, 100).size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
assertEquals(2, this.jobExplorer.getJobInstances("job", 0, 100).size());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void retryFailedExecutionWithNonIdentifyingParameters() throws Exception {
|
|
|
|
public void retryFailedExecutionWithNonIdentifyingParameters() throws Exception {
|
|
|
|
this.job = this.jobs.get("job")
|
|
|
|
this.job = this.jobs.get("job")
|
|
|
|