类 JobLauncherTestUtils
- java.lang.Object
- org.springframework.batch.test.JobLauncherTestUtils
 
- public class JobLauncherTestUtils extends java.lang.Object - Utility 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 using this utility can set up an instance in the- ApplicationContextas part of the Spring test framework.- This class also provides the ability to run - Steps from a- FlowJobor- SimpleJobindividually. By launching- Steps within a- Jobon 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.- 从以下版本开始:
- 2.1
- 作者:
- Lucas Ward, Dan Garrette, Dave Syer, Mahmoud Ben Hassine
 
- 字段概要- 字段 - 修饰符和类型 - 字段 - 说明 - protected org.apache.commons.logging.Log- loggerLogger
 - 构造器概要- 构造器 - 构造器 - 说明 - JobLauncherTestUtils()
 - 方法概要- 所有方法 实例方法 具体方法 - 修饰符和类型 - 方法 - 说明 - Job- getJob()- JobLauncher- getJobLauncher()- JobRepository- getJobRepository()- protected StepRunner- getStepRunner()Convenient method for subclasses to grab a- StepRunnerfor running steps by name.- JobParameters- getUniqueJobParameters()- JobExecution- launchJob()Launch the entire job, including all steps.- JobExecution- launchJob(JobParameters jobParameters)Launch the entire job, including all steps- JobExecution- launchStep(java.lang.String stepName)Launch just the specified step in the job.- JobExecution- launchStep(java.lang.String stepName, JobParameters jobParameters)Launch just the specified step in the job.- JobExecution- launchStep(java.lang.String stepName, JobParameters jobParameters, ExecutionContext jobExecutionContext)Launch just the specified step in the job.- JobExecution- launchStep(java.lang.String stepName, ExecutionContext jobExecutionContext)Launch just the specified step in the job.- void- setJob(Job job)The Job instance that can be manipulated (e.g. launched) in this utility.- void- setJobLauncher(JobLauncher jobLauncher)A- JobLauncherinstance that can be used to launch jobs.- void- setJobRepository(JobRepository jobRepository)The- JobRepositoryto use for creating new- JobExecutioninstances.
 
- 字段详细资料- logger- protected final org.apache.commons.logging.Log logger Logger
 
 - 构造器详细资料- JobLauncherTestUtils- public JobLauncherTestUtils() 
 
 - 方法详细资料- setJob- @Autowired public void setJob(Job job) The Job instance that can be manipulated (e.g. launched) in this utility.- 参数:
- job- the- AbstractJobto use
 
 - setJobRepository- @Autowired public void setJobRepository(JobRepository jobRepository) The- JobRepositoryto use for creating new- JobExecutioninstances.- 参数:
- jobRepository- a- JobRepository
 
 - getJobRepository- public JobRepository getJobRepository() - 返回:
- the job repository
 
 - setJobLauncher- @Autowired public void setJobLauncher(JobLauncher jobLauncher) A- JobLauncherinstance that can be used to launch jobs.- 参数:
- jobLauncher- a job launcher
 
 - getJobLauncher- public JobLauncher getJobLauncher() - 返回:
- the job launcher
 
 - launchJob- public JobExecution launchJob() throws java.lang.Exception Launch the entire job, including all steps.- 返回:
- JobExecution, so that the test can validate the exit status
- 抛出:
- java.lang.Exception- thrown if error occurs launching the job.
 
 - launchJob- public JobExecution launchJob(JobParameters jobParameters) throws java.lang.Exception Launch the entire job, including all steps- 参数:
- jobParameters- instance of- JobParameters.
- 返回:
- JobExecution, so that the test can validate the exit status
- 抛出:
- java.lang.Exception- thrown if error occurs launching the job.
 
 - getUniqueJobParameters- public JobParameters getUniqueJobParameters() - 返回:
- 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() Convenient method for subclasses to grab a- StepRunnerfor running steps by name.- 返回:
- a StepRunner
 
 - launchStep- public JobExecution launchStep(java.lang.String stepName) 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.- 参数:
- stepName- The name of the step to launch
- 返回:
- JobExecution
 
 - launchStep- public JobExecution launchStep(java.lang.String stepName, ExecutionContext jobExecutionContext) 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.- 参数:
- 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.
- 返回:
- JobExecution
 
 - launchStep- public JobExecution launchStep(java.lang.String stepName, JobParameters jobParameters) Launch just the specified step in the job. An IllegalStateException is thrown if there is no Step with the given name.- 参数:
- stepName- The name of the step to launch
- jobParameters- The JobParameters to use during the launch
- 返回:
- JobExecution
 
 - launchStep- public JobExecution launchStep(java.lang.String stepName, JobParameters jobParameters, @Nullable ExecutionContext jobExecutionContext) Launch just the specified step in the job. An IllegalStateException is thrown if there is no Step with the given name.- 参数:
- 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.
- 返回:
- JobExecution