org.springframework.batch.test
Class StepRunner

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

public class StepRunner
extends Object

Utility class for executing steps outside of a Job. 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.

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
See Also:
SimpleJob

Field Summary
protected  Log logger
          Logger
 
Constructor Summary
StepRunner(JobLauncher launcher, JobRepository jobRepository)
           
 
Method Summary
 JobExecution launchStep(Step step)
          Launch just the specified step as its own job.
 JobExecution launchStep(Step step, ExecutionContext jobExecutionContext)
          Launch just the specified step as its own job.
 JobExecution launchStep(Step step, JobParameters jobParameters)
          Launch just the specified step as its own job.
 JobExecution launchStep(Step step, JobParameters jobParameters, ExecutionContext jobExecutionContext)
          Launch just the specified step as its own job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger

Constructor Detail

StepRunner

public StepRunner(JobLauncher launcher,
                  JobRepository jobRepository)
Method Detail

launchStep

public JobExecution launchStep(Step step)
Launch just the specified step as its own job. A unique set of JobParameters will automatically be generated. An IllegalStateException is thrown if there is no Step with the given name.

Parameters:
stepName - The name of the step to launch
Returns:
JobExecution

launchStep

public JobExecution launchStep(Step step,
                               ExecutionContext jobExecutionContext)
Launch just the specified step as its own job. A unique set of JobParameters will automatically be generated. An IllegalStateException is thrown if there is no Step with the given name.

Parameters:
stepName - The name of 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)
Launch just the specified step as its own job. An IllegalStateException is thrown if there is no Step with the given name.

Parameters:
stepName - The name of the step to launch
jobParameters - The JobParameters to use during the launch
Returns:
JobExecution

launchStep

public JobExecution launchStep(Step step,
                               JobParameters jobParameters,
                               ExecutionContext jobExecutionContext)
Launch just the specified step as its own job. An IllegalStateException is thrown if there is no Step with the given name.

Parameters:
stepName - The name of 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


Copyright © 2009 SpringSource. All Rights Reserved.