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, Yanming Zhou
-
Constructor Summary
ConstructorsConstructorDescriptionJobRepositoryTestUtils(org.springframework.batch.core.repository.JobRepository jobRepository) Create aJobRepositoryTestUtilswith all its mandatory properties. -
Method Summary
Modifier and TypeMethodDescriptionList<org.springframework.batch.core.job.JobExecution> createJobExecutions(int count) Use theJobRepositoryto create someJobExecutioninstances each with a single step execution.List<org.springframework.batch.core.job.JobExecution> 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(org.springframework.batch.core.job.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<org.springframework.batch.core.job.JobExecution> jobExecutions) Remove theJobExecutioninstances, and all associatedJobInstanceandStepExecutioninstances from the standard locations used by Spring Batch.voidsetJobParametersIncrementer(org.springframework.batch.core.job.parameters.JobParametersIncrementer jobParametersIncrementer) voidsetJobRepository(org.springframework.batch.core.repository.JobRepository jobRepository)
-
Constructor Details
-
JobRepositoryTestUtils
public JobRepositoryTestUtils(org.springframework.batch.core.repository.JobRepository jobRepository) Create aJobRepositoryTestUtilswith all its mandatory properties.- Parameters:
jobRepository- aJobRepository.
-
-
Method Details
-
setJobParametersIncrementer
public void setJobParametersIncrementer(org.springframework.batch.core.job.parameters.JobParametersIncrementer jobParametersIncrementer) - Parameters:
jobParametersIncrementer- the jobParametersIncrementer to set
-
setJobRepository
public void setJobRepository(org.springframework.batch.core.repository.JobRepository jobRepository) - Parameters:
jobRepository- the jobRepository to set
-
createJobExecutions
public List<org.springframework.batch.core.job.JobExecution> createJobExecutions(String jobName, String[] stepNames, int count) throws org.springframework.batch.core.launch.JobExecutionAlreadyRunningException, org.springframework.batch.core.launch.JobRestartException, org.springframework.batch.core.launch.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:
org.springframework.batch.core.launch.JobExecutionAlreadyRunningException- thrown if Job is already running.org.springframework.batch.core.launch.JobRestartException- thrown if Job is not restartable.org.springframework.batch.core.launch.JobInstanceAlreadyCompleteException- thrown if Job Instance is already complete.
-
createJobExecutions
public List<org.springframework.batch.core.job.JobExecution> createJobExecutions(int count) throws org.springframework.batch.core.launch.JobExecutionAlreadyRunningException, org.springframework.batch.core.launch.JobRestartException, org.springframework.batch.core.launch.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:
org.springframework.batch.core.launch.JobExecutionAlreadyRunningException- thrown if Job is already running.org.springframework.batch.core.launch.JobRestartException- thrown if Job is not restartable.org.springframework.batch.core.launch.JobInstanceAlreadyCompleteException- thrown if Job Instance is already complete.
-
removeJobExecutions
public void removeJobExecutions(Collection<org.springframework.batch.core.job.JobExecution> jobExecutions) Remove theJobExecutioninstances, and all associatedJobInstanceandStepExecutioninstances from the standard locations used by Spring Batch.- Parameters:
jobExecutions- a collection ofJobExecution
-
removeJobExecution
public void removeJobExecution(org.springframework.batch.core.job.JobExecution jobExecution) 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.
-