Class StepRunner

java.lang.Object
org.springframework.batch.test.StepRunner

@NullUnmarked @Deprecated(since="6.0", forRemoval=true) public class StepRunner extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
since 6.0 in favor of JobOperatorTestUtils.startStep(String, JobParameters, ExecutionContext). Scheduled for removal in 6.2 or later
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.
It should be noted that any checked exceptions encountered while running the Step will wrapped with RuntimeException. Any checked exception thrown will be due to a framework error, not the logic of the step, and thus requiring a throws declaration in clients of this class is unnecessary.
Since:
2.0
Author:
Dan Garrette, Lucas Ward, Mahmoud Ben Hassine
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Deprecated, for removal: This API element is subject to removal in a future version.
    Name of the single-step job surrounding steps when tested individually
    protected final org.apache.commons.logging.Log
    Deprecated, for removal: This API element is subject to removal in a future version.
    Logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    StepRunner(JobLauncher launcher, JobRepository jobRepository)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Launch just the specified step in a surrounding single-step job of type SimpleJob named JOB_NAME.
    launchStep(Step step, JobParameters jobParameters)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Launch just the specified step in a surrounding single-step job of type SimpleJob named JOB_NAME.
    launchStep(Step step, JobParameters jobParameters, ExecutionContext jobExecutionContext)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Launch just the specified step in a surrounding single-step job of type SimpleJob named JOB_NAME.
    launchStep(Step step, ExecutionContext jobExecutionContext)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Launch just the specified step in a surrounding single-step job of type SimpleJob named JOB_NAME.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • JOB_NAME

      public static final String JOB_NAME
      Deprecated, for removal: This API element is subject to removal in a future version.
      Name of the single-step job surrounding steps when tested individually
      See Also:
    • logger

      protected final org.apache.commons.logging.Log logger
      Deprecated, for removal: This API element is subject to removal in a future version.
      Logger
  • Constructor Details

    • StepRunner

      public StepRunner(JobLauncher launcher, JobRepository jobRepository)
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • launchStep

      public JobExecution launchStep(Step step)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Launch just the specified step in a surrounding single-step job of type SimpleJob named JOB_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 JobExecution launchStep(Step step, @Nullable ExecutionContext jobExecutionContext)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Launch just the specified step in a surrounding single-step job of type SimpleJob named JOB_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
      jobExecutionContext - An ExecutionContext whose values will be loaded into the Job ExecutionContext prior to launching the step.
      Returns:
      JobExecution
    • launchStep

      public JobExecution launchStep(Step step, JobParameters jobParameters)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Launch just the specified step in a surrounding single-step job of type SimpleJob named JOB_NAME. An IllegalStateException is thrown if there is no Step with the given name.
      Parameters:
      step - The step to launch
      jobParameters - The JobParameters to use during the launch
      Returns:
      JobExecution
    • launchStep

      public JobExecution launchStep(Step step, JobParameters jobParameters, @Nullable ExecutionContext jobExecutionContext)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Launch just the specified step in a surrounding single-step job of type SimpleJob named JOB_NAME. An IllegalStateException is thrown if there is no Step with the given name.
      Parameters:
      step - The step to launch
      jobParameters - The JobParameters to use during the launch
      jobExecutionContext - An ExecutionContext whose values will be loaded into the Job ExecutionContext prior to launching the step.
      Returns:
      JobExecution