Package org.springframework.batch.test
Class JobRepositoryTestUtils
java.lang.Object
org.springframework.batch.test.JobRepositoryTestUtils
Convenience class for creating and removing
JobExecution instances from a
database. Typical usage in test case would be to create instances before a transaction,
save the result, and then use it to remove them after the transaction.- Author:
- Dave Syer, Mahmoud Ben Hassine
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.JobRepositoryTestUtils(JobRepository jobRepository) Create aJobRepositoryTestUtilswith all its mandatory properties. -
Method Summary
Modifier and TypeMethodDescriptioncreateJobExecutions(int count) Use theJobRepositoryto create someJobExecutioninstances each with a single step execution.createJobExecutions(String jobName, String[] stepNames, int count) Use theJobRepositoryto create someJobExecutioninstances each with the given job name and each having step executions with the given step names.voidremoveJobExecution(JobExecution jobExecution) Remove theJobExecutionand its associatedStepExecutioninstances from the standard locations used by Spring Batch.voidRemove all theJobExecutioninstances, and all associatedJobInstanceandStepExecutioninstances from the standard locations used by Spring Batch.voidremoveJobExecutions(Collection<JobExecution> jobExecutions) Remove theJobExecutioninstances, and all associatedJobInstanceandStepExecutioninstances from the standard locations used by Spring Batch.voidsetJobParametersIncrementer(JobParametersIncrementer jobParametersIncrementer) voidsetJobRepository(JobRepository jobRepository)
-
Constructor Details
-
JobRepositoryTestUtils
public JobRepositoryTestUtils()Default constructor. -
JobRepositoryTestUtils
Create aJobRepositoryTestUtilswith all its mandatory properties.- Parameters:
jobRepository- aJobRepository.
-
-
Method Details
-
setJobParametersIncrementer
- Parameters:
jobParametersIncrementer- the jobParametersIncrementer to set
-
setJobRepository
- Parameters:
jobRepository- the jobRepository to set
-
createJobExecutions
public List<JobExecution> createJobExecutions(String jobName, String[] stepNames, int count) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException Use theJobRepositoryto create someJobExecutioninstances each with the given job name and each having step executions with the given step names.- Parameters:
jobName- the name of the jobstepNames- the names of the step executionscount- the required number of instances ofJobExecutionto create- Returns:
- a collection of
JobExecution - Throws:
JobExecutionAlreadyRunningException- thrown if Job is already running.JobRestartException- thrown if Job is not restartable.JobInstanceAlreadyCompleteException- thrown if Job Instance is already complete.
-
createJobExecutions
public List<JobExecution> createJobExecutions(int count) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException Use theJobRepositoryto create someJobExecutioninstances each with a single step execution.- Parameters:
count- the required number of instances ofJobExecutionto create- Returns:
- a collection of
JobExecution - Throws:
JobExecutionAlreadyRunningException- thrown if Job is already running.JobRestartException- thrown if Job is not restartable.JobInstanceAlreadyCompleteException- thrown if Job Instance is already complete.
-
removeJobExecutions
Remove theJobExecutioninstances, and all associatedJobInstanceandStepExecutioninstances from the standard locations used by Spring Batch.- Parameters:
jobExecutions- a collection ofJobExecution
-
removeJobExecution
Remove theJobExecutionand its associatedStepExecutioninstances from the standard locations used by Spring Batch.- Parameters:
jobExecution- theJobExecutionto delete
-
removeJobExecutions
public void removeJobExecutions()Remove all theJobExecutioninstances, and all associatedJobInstanceandStepExecutioninstances from the standard locations used by Spring Batch.
-