4242import org .springframework .lang .Nullable ;
4343
4444/**
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.
4847 *
4948 * <ul>
5049 * <li><b>launchStep(Step step)</b>: Launch the step with new parameters each time. (The
6766 */
6867public class StepRunner {
6968
69+ /**
70+ * Name of the single-step job surrounding steps when tested individually
71+ */
72+ public static final String JOB_NAME = "TestJob" ;
73+
7074 /** Logger */
7175 protected final Log logger = LogFactory .getLog (getClass ());
7276
@@ -80,9 +84,10 @@ public StepRunner(JobLauncher launcher, JobRepository jobRepository) {
8084 }
8185
8286 /**
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.
8691 * @param step The step to launch
8792 * @return JobExecution
8893 */
@@ -91,9 +96,10 @@ public JobExecution launchStep(Step step) {
9196 }
9297
9398 /**
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.
97103 * @param step The step to launch
98104 * @param jobExecutionContext An ExecutionContext whose values will be loaded into the
99105 * Job ExecutionContext prior to launching the step.
@@ -104,8 +110,9 @@ public JobExecution launchStep(Step step, @Nullable ExecutionContext jobExecutio
104110 }
105111
106112 /**
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.
109116 * @param step The step to launch
110117 * @param jobParameters The JobParameters to use during the launch
111118 * @return JobExecution
@@ -115,8 +122,9 @@ public JobExecution launchStep(Step step, JobParameters jobParameters) {
115122 }
116123
117124 /**
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.
120128 * @param step The step to launch
121129 * @param jobParameters The JobParameters to use during the launch
122130 * @param jobExecutionContext An ExecutionContext whose values will be loaded into the
@@ -129,7 +137,7 @@ public JobExecution launchStep(Step step, JobParameters jobParameters,
129137 // Create a fake job
130138 //
131139 SimpleJob job = new SimpleJob ();
132- job .setName ("TestJob" );
140+ job .setName (JOB_NAME );
133141 job .setJobRepository (this .jobRepository );
134142
135143 List <Step > stepsToExecute = new ArrayList <>();
0 commit comments