JobLauncherTestUtils
instead@Deprecated
public abstract class AbstractJobTests
extends java.lang.Object
implements org.springframework.context.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 Step
s from a
FlowJob
or SimpleJob
individually. By launching Step
s
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.
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger
Deprecated.
Logger
|
Constructor and Description |
---|
AbstractJobTests()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected org.springframework.context.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(java.lang.String stepName)
Deprecated.
Launch just the specified step in the job.
|
JobExecution |
launchStep(java.lang.String stepName,
ExecutionContext jobExecutionContext)
Deprecated.
Launch just the specified step in the job.
|
JobExecution |
launchStep(java.lang.String stepName,
JobParameters jobParameters)
Deprecated.
Launch just the specified step in the job.
|
JobExecution |
launchStep(java.lang.String stepName,
JobParameters jobParameters,
ExecutionContext jobExecutionContext)
Deprecated.
Launch just the specified step in the job.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Deprecated.
|
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
protected org.springframework.context.ApplicationContext getApplicationContext()
public JobRepository getJobRepository()
public AbstractJob getJob()
protected JobLauncher getJobLauncher()
protected JobExecution launchJob() throws java.lang.Exception
java.lang.Exception
- is thrown if error occurs.protected JobExecution launchJob(JobParameters jobParameters) throws java.lang.Exception
jobParameters
- parameters for the jobjava.lang.Exception
- is thrown if error occurs.protected JobParameters getUniqueJobParameters()
protected StepRunner getStepRunner()
StepRunner
for running
steps by name.StepRunner
public JobExecution launchStep(java.lang.String stepName)
stepName
- The name of the step to launchpublic JobExecution launchStep(java.lang.String stepName, ExecutionContext jobExecutionContext)
stepName
- The name of the step to launchjobExecutionContext
- An ExecutionContext whose values will be
loaded into the Job ExecutionContext prior to launching the step.public JobExecution launchStep(java.lang.String stepName, JobParameters jobParameters)
stepName
- The name of the step to launchjobParameters
- The JobParameters to use during the launchpublic JobExecution launchStep(java.lang.String stepName, JobParameters jobParameters, ExecutionContext jobExecutionContext)
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.