Polish "Start building against Spring Batch 6.0.0-RC1 snapshots"

See gh-47477
This commit is contained in:
Stéphane Nicoll
2025-10-10 18:20:22 +02:00
parent 491019d4fe
commit 8cd7c2277f
2 changed files with 14 additions and 15 deletions
@@ -179,9 +179,8 @@ public class JobLauncherApplicationRunner
if (this.jobRegistry != null && StringUtils.hasText(this.jobName)) {
if (!isLocalJob(this.jobName)) {
Job job = this.jobRegistry.getJob(this.jobName);
if (job != null) {
execute(job, jobParameters);
}
Assert.notNull(job, () -> "No job found with name '" + this.jobName + "'");
execute(job, jobParameters);
}
}
}
@@ -29,7 +29,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link JobExecutionExitCodeGenerator}.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
*/
class JobExecutionExitCodeGeneratorTests {
@@ -37,28 +36,29 @@ class JobExecutionExitCodeGeneratorTests {
@Test
void testExitCodeForRunning() {
JobInstance jobInstance = new JobInstance(1L, "job");
JobExecution jobExecution = new JobExecution(1L, jobInstance, new JobParameters());
this.generator.onApplicationEvent(new JobExecutionEvent(jobExecution));
this.generator.onApplicationEvent(new JobExecutionEvent(testJobExecution()));
assertThat(this.generator.getExitCode()).isOne();
}
@Test
void testExitCodeForCompleted() {
JobInstance jobInstance = new JobInstance(1L, "job");
JobExecution jobExecution = new JobExecution(1L, jobInstance, new JobParameters());
jobExecution.setStatus(BatchStatus.COMPLETED);
this.generator.onApplicationEvent(new JobExecutionEvent(jobExecution));
JobExecution execution = testJobExecution();
execution.setStatus(BatchStatus.COMPLETED);
this.generator.onApplicationEvent(new JobExecutionEvent(execution));
assertThat(this.generator.getExitCode()).isZero();
}
@Test
void testExitCodeForFailed() {
JobInstance jobInstance = new JobInstance(1L, "job");
JobExecution jobExecution = new JobExecution(1L, jobInstance, new JobParameters());
jobExecution.setStatus(BatchStatus.FAILED);
this.generator.onApplicationEvent(new JobExecutionEvent(jobExecution));
JobExecution execution = testJobExecution();
execution.setStatus(BatchStatus.FAILED);
this.generator.onApplicationEvent(new JobExecutionEvent(execution));
assertThat(this.generator.getExitCode()).isEqualTo(5);
}
private static JobExecution testJobExecution() {
JobInstance jobInstance = new JobInstance(1L, "job");
return new JobExecution(0L, jobInstance, new JobParameters());
}
}