Batch Boot Runner only supports one job.
Needed to update TaskJobLauncher to support only one job. Updated tests accordingly Re-added Added tests removed from M3 release
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020-2020 the original author or authors.
|
||||
* Copyright 2020-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,7 +44,7 @@ public class TaskJobLauncherApplicationRunnerFactoryBean
|
||||
|
||||
private List<Job> jobs;
|
||||
|
||||
private String jobNames;
|
||||
private String jobName;
|
||||
|
||||
private JobRegistry jobRegistry;
|
||||
|
||||
@@ -65,14 +65,14 @@ public class TaskJobLauncherApplicationRunnerFactoryBean
|
||||
this.jobLauncher = jobLauncher;
|
||||
this.jobExplorer = jobExplorer;
|
||||
this.jobs = jobs;
|
||||
this.jobNames = taskBatchProperties.getJobNames();
|
||||
this.jobName = taskBatchProperties.getJobNames();
|
||||
this.jobRegistry = jobRegistry;
|
||||
this.taskBatchProperties = taskBatchProperties;
|
||||
if (StringUtils.hasText(batchProperties.getJob().getNames())) {
|
||||
this.jobNames = batchProperties.getJob().getNames();
|
||||
if (StringUtils.hasText(batchProperties.getJob().getName())) {
|
||||
this.jobName = batchProperties.getJob().getName();
|
||||
}
|
||||
else {
|
||||
this.jobNames = taskBatchProperties.getJobNames();
|
||||
this.jobName = taskBatchProperties.getJobNames();
|
||||
}
|
||||
this.order = taskBatchProperties.getCommandLineRunnerOrder();
|
||||
this.jobRepository = jobRepository;
|
||||
@@ -88,8 +88,8 @@ public class TaskJobLauncherApplicationRunnerFactoryBean
|
||||
this.jobLauncher, this.jobExplorer, this.jobRepository,
|
||||
this.taskBatchProperties);
|
||||
taskJobLauncherApplicationRunner.setJobs(this.jobs);
|
||||
if (StringUtils.hasText(this.jobNames)) {
|
||||
taskJobLauncherApplicationRunner.setJobNames(this.jobNames);
|
||||
if (StringUtils.hasText(this.jobName)) {
|
||||
taskJobLauncherApplicationRunner.setJobName(this.jobName);
|
||||
}
|
||||
taskJobLauncherApplicationRunner.setJobRegistry(this.jobRegistry);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2018-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,10 +70,10 @@ public class TaskJobLauncherAutoConfigurationTests {
|
||||
public void testAutoBuiltDataSourceWithBatchJobNames() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.cloud.task.batch.fail-on-job-failure=true",
|
||||
"spring.batch.job.names=job1,job2",
|
||||
"spring.cloud.task.batch.jobNames=foobar")
|
||||
"spring.batch.job.name=job1",
|
||||
"spring.cloud.task.batch.jobName=foobar")
|
||||
.run(context -> {
|
||||
validateJobNames(context, "job1,job2");
|
||||
validateJobNames(context, "job1");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class TaskJobLauncherAutoConfigurationTests {
|
||||
.getBean(TaskJobLauncherApplicationRunner.class);
|
||||
|
||||
Object names = ReflectionTestUtils.getField(jobLauncherApplicationRunner,
|
||||
"jobNames");
|
||||
"jobName");
|
||||
assertThat(names).isEqualTo(jobNames);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 the original author or authors.
|
||||
* Copyright 2016-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -217,7 +217,7 @@ public class TaskBatchExecutionListenerTests {
|
||||
@Test
|
||||
public void testMultipleJobs() {
|
||||
this.applicationContext = SpringApplication.run(MultipleJobConfiguration.class,
|
||||
ARGS);
|
||||
"--spring.batch.job.name=job1");
|
||||
|
||||
TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class);
|
||||
|
||||
@@ -227,14 +227,12 @@ public class TaskBatchExecutionListenerTests {
|
||||
Set<Long> jobExecutionIds = taskExplorer.getJobExecutionIdsByTaskExecutionId(
|
||||
page.iterator().next().getExecutionId());
|
||||
|
||||
assertThat(jobExecutionIds.size()).isEqualTo(2);
|
||||
assertThat(jobExecutionIds.size()).isEqualTo(1);
|
||||
Iterator<Long> jobExecutionIdsIterator = jobExecutionIds.iterator();
|
||||
assertThat((long) taskExplorer
|
||||
.getTaskExecutionIdByJobExecutionId(jobExecutionIdsIterator.next()))
|
||||
.isEqualTo(1);
|
||||
assertThat((long) taskExplorer
|
||||
.getTaskExecutionIdByJobExecutionId(jobExecutionIdsIterator.next()))
|
||||
.isEqualTo(1);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user