Class AbstractJobTests
- java.lang.Object
- org.springframework.batch.test.AbstractJobTests
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@Deprecated public abstract class AbstractJobTests extends java.lang.Object implements org.springframework.context.ApplicationContextAwareDeprecated.(from 2.1) useJobLauncherTestUtilsinsteadBase 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 anApplicationContext, which is generally expected to be done as part of the Spring test framework. Furthermore, theApplicationContextin which it is a part of is expected to have oneJobLauncher,JobRepository, and a singleAbstractJobimplementation.This class also provides the ability to run
Steps from aFlowJoborSimpleJobindividually. By launchingSteps within aJobon 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
JobParametersin 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
Fields Modifier and Type Field Description protected org.apache.commons.logging.LogloggerDeprecated.Logger
Constructor Summary
Constructors Constructor Description AbstractJobTests()Deprecated.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected org.springframework.context.ApplicationContextgetApplicationContext()Deprecated.AbstractJobgetJob()Deprecated.protected JobLaunchergetJobLauncher()Deprecated.JobRepositorygetJobRepository()Deprecated.protected StepRunnergetStepRunner()Deprecated.Convenient method for subclasses to grab aStepRunnerfor running steps by name.protected JobParametersgetUniqueJobParameters()Deprecated.protected JobExecutionlaunchJob()Deprecated.Launch the entire job, including all steps.protected JobExecutionlaunchJob(JobParameters jobParameters)Deprecated.Launch the entire job, including all stepsJobExecutionlaunchStep(java.lang.String stepName)Deprecated.Launch just the specified step in the job.JobExecutionlaunchStep(java.lang.String stepName, JobParameters jobParameters)Deprecated.Launch just the specified step in the job.JobExecutionlaunchStep(java.lang.String stepName, JobParameters jobParameters, ExecutionContext jobExecutionContext)Deprecated.Launch just the specified step in the job.JobExecutionlaunchStep(java.lang.String stepName, ExecutionContext jobExecutionContext)Deprecated.Launch just the specified step in the job.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)Deprecated.
Method Detail
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansExceptionDeprecated.- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
getApplicationContext
protected org.springframework.context.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 java.lang.Exception
Deprecated.Launch the entire job, including all steps.- Returns:
- JobExecution, so that the test can validate the exit status
- Throws:
java.lang.Exception- is thrown if error occurs.
launchJob
protected JobExecution launchJob(JobParameters jobParameters) throws java.lang.Exception
Deprecated.Launch the entire job, including all steps- Parameters:
jobParameters- parameters for the job- Returns:
- JobExecution, so that the test can validate the exit status
- Throws:
java.lang.Exception- is thrown if error occurs.
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 aStepRunnerfor running steps by name.- Returns:
- a
StepRunner
launchStep
public JobExecution launchStep(java.lang.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(java.lang.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 launchjobExecutionContext- An ExecutionContext whose values will be loaded into the Job ExecutionContext prior to launching the step.- Returns:
- JobExecution
launchStep
public JobExecution launchStep(java.lang.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 launchjobParameters- The JobParameters to use during the launch- Returns:
- JobExecution
launchStep
public JobExecution launchStep(java.lang.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 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