Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1807653

Browse filesBrowse files
author
dsyer
committed
BATCH-1534: changed AbstractJob to Job
1 parent a390ff1 commit 1807653
Copy full SHA for 1807653

File tree

Expand file treeCollapse file tree

1 file changed

+12
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-6
lines changed
Open diff view settings
Collapse file

‎spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java‎

Copy file name to clipboardExpand all lines: spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java
+12-6Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.batch.core.job.flow.FlowJob;
3333
import org.springframework.batch.core.launch.JobLauncher;
3434
import org.springframework.batch.core.repository.JobRepository;
35+
import org.springframework.batch.core.step.StepLocator;
3536
import org.springframework.batch.item.ExecutionContext;
3637
import org.springframework.beans.factory.annotation.Autowired;
3738
import org.springframework.context.ApplicationContext;
@@ -71,7 +72,7 @@ public class JobLauncherTestUtils {
7172

7273
private JobLauncher jobLauncher;
7374

74-
private AbstractJob job;
75+
private Job job;
7576

7677
private JobRepository jobRepository;
7778

@@ -83,7 +84,7 @@ public class JobLauncherTestUtils {
8384
* @param job the {@link AbstractJob} to use
8485
*/
8586
@Autowired
86-
public void setJob(AbstractJob job) {
87+
public void setJob(Job job) {
8788
this.job = job;
8889
}
8990

@@ -108,10 +109,10 @@ public JobRepository getJobRepository() {
108109
/**
109110
* @return the job
110111
*/
111-
public AbstractJob getJob() {
112+
public Job getJob() {
112113
return job;
113114
}
114-
115+
115116
/**
116117
* A {@link JobLauncher} instance that can be used to launch jobs.
117118
*
@@ -222,9 +223,14 @@ public JobExecution launchStep(String stepName, JobParameters jobParameters) {
222223
* @return JobExecution
223224
*/
224225
public JobExecution launchStep(String stepName, JobParameters jobParameters, ExecutionContext jobExecutionContext) {
225-
Step step = this.job.getStep(stepName);
226+
if (!(job instanceof StepLocator)) {
227+
throw new UnsupportedOperationException("Cannot locate step from a Job that is not a StepLocator: job="
228+
+ job.getName() + " does not implement StepLocator");
229+
}
230+
StepLocator locator = (StepLocator) this.job;
231+
Step step = locator.getStep(stepName);
226232
if (step == null) {
227-
step = this.job.getStep(this.job.getName() + "." + stepName);
233+
step = locator.getStep(this.job.getName() + "." + stepName);
228234
}
229235
if (step == null) {
230236
throw new IllegalStateException("No Step found with name: [" + stepName + "]");

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.