org.springframework.batch.test
Class AbstractJobTests

java.lang.Object
  extended by org.springframework.batch.test.AbstractJobTests
All Implemented Interfaces:
ApplicationContextAware

Deprecated. (from 2.1) use JobLauncherTestUtils instead

public abstract class AbstractJobTests
extends Object
implements ApplicationContextAware

Base class for testing batch jobs. It provides methods for launching an entire AbstractJob, allowing for end to end testing of individual steps, without having to run every step in the job. Any test classes inheriting from this class should make sure they are part of an ApplicationContext, which is generally expected to be done as part of the Spring test framework. Furthermore, the ApplicationContext in which it is a part of is expected to have one JobLauncher, JobRepository, and a single AbstractJob implementation.

This class also provides the ability to run Steps from a FlowJob or SimpleJob individually. By launching Steps within a Job on their own, end to end testing of individual steps can be performed without having to run every step in the job.

It should be noted that using any of the methods that don't contain JobParameters in their signature, will result in one being created with the current system time as a parameter. This will ensure restartability when no parameters are provided.

Since:
2.0
Author:
Lucas Ward, Dan Garrette

Field Summary
protected  Log logger
          Deprecated. Logger
 
Constructor Summary
AbstractJobTests()
          Deprecated.  
 
Method Summary
protected  ApplicationContext getApplicationContext()
          Deprecated.  
 AbstractJob getJob()
          Deprecated.  
protected  JobLauncher getJobLauncher()
          Deprecated.  
 JobRepository getJobRepository()
          Deprecated.  
protected  StepRunner getStepRunner()
          Deprecated. Convenient method for subclasses to grab a StepRunner for running steps by name.
protected  JobParameters getUniqueJobParameters()
          Deprecated.  
protected  JobExecution launchJob()
          Deprecated. Launch the entire job, including all steps.
protected  JobExecution launchJob(JobParameters jobParameters)
          Deprecated. Launch the entire job, including all steps
 JobExecution launchStep(String stepName)
          Deprecated. Launch just the specified step in the job.
 JobExecution launchStep(String stepName, ExecutionContext jobExecutionContext)
          Deprecated. Launch just the specified step in the job.
 JobExecution launchStep(String stepName, JobParameters jobParameters)
          Deprecated. Launch just the specified step in the job.
 JobExecution launchStep(String stepName, JobParameters jobParameters, ExecutionContext jobExecutionContext)
          Deprecated. Launch just the specified step in the job.
 void setApplicationContext(ApplicationContext applicationContext)
          Deprecated. 
 
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
Deprecated. 
Logger

Constructor Detail

AbstractJobTests

public AbstractJobTests()
Deprecated. 
Method Detail

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException
Deprecated. 

Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException

getApplicationContext

protected ApplicationContext getApplicationContext()
Deprecated. 
Returns:
the applicationContext

getJobRepository

public JobRepository getJobRepository()
Deprecated. 
Returns:
the job repository which is autowired by type

getJob

public AbstractJob getJob()
Deprecated. 
Returns:
the job which is autowired by type

getJobLauncher

protected JobLauncher getJobLauncher()
Deprecated. 
Returns:
the launcher

launchJob

protected JobExecution launchJob()
                          throws Exception
Deprecated. 
Launch the entire job, including all steps.

Returns:
JobExecution, so that the test can validate the exit status
Throws:
Exception

launchJob

protected JobExecution launchJob(JobParameters jobParameters)
                          throws Exception
Deprecated. 
Launch the entire job, including all steps

Parameters:
jobParameters -
Returns:
JobExecution, so that the test can validate the exit status
Throws:
Exception

getUniqueJobParameters

protected JobParameters getUniqueJobParameters()
Deprecated. 
Returns:
a new JobParameters object containing only a parameter for the current timestamp, to ensure that the job instance will be unique.

getStepRunner

protected StepRunner getStepRunner()
Deprecated. 
Convenient method for subclasses to grab a StepRunner for running steps by name.

Returns:
a StepRunner

launchStep

public JobExecution launchStep(String stepName)
Deprecated. 
Launch just the specified step in the 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(String stepName,
                               ExecutionContext jobExecutionContext)
Deprecated. 
Launch just the specified step in the 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(String stepName,
                               JobParameters jobParameters)
Deprecated. 
Launch just the specified step in the 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(String stepName,
                               JobParameters jobParameters,
                               ExecutionContext jobExecutionContext)
Deprecated. 
Launch just the specified step in the 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 © 2013 SpringSource. All Rights Reserved.