Package org.springframework.batch.test
Class StepRunner
java.lang.Object
org.springframework.batch.test.StepRunner
Utility class for executing steps. This is useful in end to end testing in order to
allow for the testing of a step individually without running every Step in a job.
- launchStep(Step step): Launch the step with new parameters each time. (The current system time will be used)
- launchStep(Step step, JobParameters jobParameters): Launch the specified step with the provided JobParameters. This may be useful if your step requires a certain parameter during runtime.
- Since:
- 2.0
- Author:
- Dan Garrette, Lucas Ward, Mahmoud Ben Hassine
- See Also:
-
SimpleJob
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStepRunner(org.springframework.batch.core.launch.JobLauncher launcher, org.springframework.batch.core.repository.JobRepository jobRepository) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.batch.core.JobExecutionlaunchStep(org.springframework.batch.core.Step step) Launch just the specified step in a surrounding single-step job of typeSimpleJobnamedJOB_NAME.org.springframework.batch.core.JobExecutionlaunchStep(org.springframework.batch.core.Step step, org.springframework.batch.core.JobParameters jobParameters) Launch just the specified step in a surrounding single-step job of typeSimpleJobnamedJOB_NAME.org.springframework.batch.core.JobExecutionlaunchStep(org.springframework.batch.core.Step step, org.springframework.batch.core.JobParameters jobParameters, org.springframework.batch.item.ExecutionContext jobExecutionContext) Launch just the specified step in a surrounding single-step job of typeSimpleJobnamedJOB_NAME.org.springframework.batch.core.JobExecutionlaunchStep(org.springframework.batch.core.Step step, org.springframework.batch.item.ExecutionContext jobExecutionContext) Launch just the specified step in a surrounding single-step job of typeSimpleJobnamedJOB_NAME.
-
Field Details
-
JOB_NAME
Name of the single-step job surrounding steps when tested individually- See Also:
-
logger
protected final org.apache.commons.logging.Log loggerLogger
-
-
Constructor Details
-
StepRunner
public StepRunner(org.springframework.batch.core.launch.JobLauncher launcher, org.springframework.batch.core.repository.JobRepository jobRepository)
-
-
Method Details
-
launchStep
public org.springframework.batch.core.JobExecution launchStep(org.springframework.batch.core.Step step) Launch just the specified step in a surrounding single-step job of typeSimpleJobnamedJOB_NAME. A unique set of JobParameters will automatically be generated. An IllegalStateException is thrown if there is no Step with the given name.- Parameters:
step- The step to launch- Returns:
- JobExecution
-
launchStep
public org.springframework.batch.core.JobExecution launchStep(org.springframework.batch.core.Step step, @Nullable org.springframework.batch.item.ExecutionContext jobExecutionContext) Launch just the specified step in a surrounding single-step job of typeSimpleJobnamedJOB_NAME. A unique set of JobParameters will automatically be generated. An IllegalStateException is thrown if there is no Step with the given name.- Parameters:
step- The step to launchjobExecutionContext- An ExecutionContext whose values will be loaded into the Job ExecutionContext prior to launching the step.- Returns:
- JobExecution
-
launchStep
public org.springframework.batch.core.JobExecution launchStep(org.springframework.batch.core.Step step, org.springframework.batch.core.JobParameters jobParameters) Launch just the specified step in a surrounding single-step job of typeSimpleJobnamedJOB_NAME. An IllegalStateException is thrown if there is no Step with the given name.- Parameters:
step- The step to launchjobParameters- The JobParameters to use during the launch- Returns:
- JobExecution
-
launchStep
public org.springframework.batch.core.JobExecution launchStep(org.springframework.batch.core.Step step, org.springframework.batch.core.JobParameters jobParameters, @Nullable org.springframework.batch.item.ExecutionContext jobExecutionContext) Launch just the specified step in a surrounding single-step job of typeSimpleJobnamedJOB_NAME. An IllegalStateException is thrown if there is no Step with the given name.- Parameters:
step- The step to launchjobParameters- The JobParameters to use during the launchjobExecutionContext- An ExecutionContext whose values will be loaded into the Job ExecutionContext prior to launching the step.- Returns:
- JobExecution
-