42
42
import org .springframework .lang .Nullable ;
43
43
44
44
/**
45
- * Utility class for executing steps outside of a {@link Job}. This is useful in end to
46
- * end testing in order to allow for the testing of a step individually without running
47
- * every Step in a job.
45
+ * Utility class for executing steps. This is useful in end to end testing in order to
46
+ * allow for the testing of a step individually without running every Step in a job.
48
47
*
49
48
* <ul>
50
49
* <li><b>launchStep(Step step)</b>: Launch the step with new parameters each time. (The
67
66
*/
68
67
public class StepRunner {
69
68
69
+ /**
70
+ * Name of the single-step job surrounding steps when tested individually
71
+ */
72
+ public static final String JOB_NAME = "TestJob" ;
73
+
70
74
/** Logger */
71
75
protected final Log logger = LogFactory .getLog (getClass ());
72
76
@@ -80,9 +84,10 @@ public StepRunner(JobLauncher launcher, JobRepository jobRepository) {
80
84
}
81
85
82
86
/**
83
- * Launch just the specified step as its own job. A unique set of JobParameters will
84
- * automatically be generated. An IllegalStateException is thrown if there is no Step
85
- * with the given name.
87
+ * Launch just the specified step in a surrounding single-step job of type
88
+ * {@link SimpleJob} named {@link StepRunner#JOB_NAME}. A unique set of JobParameters
89
+ * will automatically be generated. An IllegalStateException is thrown if there is no
90
+ * Step with the given name.
86
91
* @param step The step to launch
87
92
* @return JobExecution
88
93
*/
@@ -91,9 +96,10 @@ public JobExecution launchStep(Step step) {
91
96
}
92
97
93
98
/**
94
- * Launch just the specified step as its own job. A unique set of JobParameters will
95
- * automatically be generated. An IllegalStateException is thrown if there is no Step
96
- * with the given name.
99
+ * Launch just the specified step in a surrounding single-step job of type
100
+ * {@link SimpleJob} named {@link StepRunner#JOB_NAME}. A unique set of JobParameters
101
+ * will automatically be generated. An IllegalStateException is thrown if there is no
102
+ * Step with the given name.
97
103
* @param step The step to launch
98
104
* @param jobExecutionContext An ExecutionContext whose values will be loaded into the
99
105
* Job ExecutionContext prior to launching the step.
@@ -104,8 +110,9 @@ public JobExecution launchStep(Step step, @Nullable ExecutionContext jobExecutio
104
110
}
105
111
106
112
/**
107
- * Launch just the specified step as its own job. An IllegalStateException is thrown
108
- * if there is no Step with the given name.
113
+ * Launch just the specified step in a surrounding single-step job of type
114
+ * {@link SimpleJob} named {@link StepRunner#JOB_NAME}. An IllegalStateException is
115
+ * thrown if there is no Step with the given name.
109
116
* @param step The step to launch
110
117
* @param jobParameters The JobParameters to use during the launch
111
118
* @return JobExecution
@@ -115,8 +122,9 @@ public JobExecution launchStep(Step step, JobParameters jobParameters) {
115
122
}
116
123
117
124
/**
118
- * Launch just the specified step as its own job. An IllegalStateException is thrown
119
- * if there is no Step with the given name.
125
+ * Launch just the specified step in a surrounding single-step job of type
126
+ * {@link SimpleJob} named {@link StepRunner#JOB_NAME}. An IllegalStateException is
127
+ * thrown if there is no Step with the given name.
120
128
* @param step The step to launch
121
129
* @param jobParameters The JobParameters to use during the launch
122
130
* @param jobExecutionContext An ExecutionContext whose values will be loaded into the
@@ -129,7 +137,7 @@ public JobExecution launchStep(Step step, JobParameters jobParameters,
129
137
// Create a fake job
130
138
//
131
139
SimpleJob job = new SimpleJob ();
132
- job .setName ("TestJob" );
140
+ job .setName (JOB_NAME );
133
141
job .setJobRepository (this .jobRepository );
134
142
135
143
List <Step > stepsToExecute = new ArrayList <>();
0 commit comments