public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao implements org.springframework.beans.factory.InitializingBean
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.DEFAULT_EXIT_MESSAGE_LENGTH, DEFAULT_TABLE_PREFIX
Constructor and Description |
---|
JobRepositoryTestUtils()
Default constructor.
|
JobRepositoryTestUtils(JobRepository jobRepository,
javax.sql.DataSource dataSource)
Create a
JobRepositoryTestUtils with all its mandatory
properties. |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
java.util.List<JobExecution> |
createJobExecutions(int count)
Use the
JobRepository to create some JobExecution
instances each with a single step execution. |
java.util.List<JobExecution> |
createJobExecutions(java.lang.String jobName,
java.lang.String[] stepNames,
int count)
Use the
JobRepository to create some JobExecution
instances each with the given job name and each having step executions
with the given step names. |
void |
removeJobExecutions()
Remove all the
JobExecution instances, and all associated
JobInstance and StepExecution instances from the standard
RDBMS locations used by Spring Batch. |
void |
removeJobExecutions(java.util.Collection<JobExecution> list)
Remove the
JobExecution instances, and all associated
JobInstance and StepExecution instances from the standard
RDBMS locations used by Spring Batch. |
void |
setDataSource(javax.sql.DataSource dataSource) |
void |
setJobParametersIncrementer(JobParametersIncrementer jobParametersIncrementer) |
void |
setJobRepository(JobRepository jobRepository) |
getClobTypeToUse, getJdbcTemplate, getQuery, getTablePrefix, setClobTypeToUse, setJdbcTemplate, setTablePrefix
public JobRepositoryTestUtils()
public JobRepositoryTestUtils(JobRepository jobRepository, javax.sql.DataSource dataSource)
JobRepositoryTestUtils
with all its mandatory
properties.jobRepository
- a JobRepository
backed by a databasedataSource
- a DataSource
public void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
in class AbstractJdbcBatchMetadataDao
java.lang.Exception
InitializingBean.afterPropertiesSet()
@Autowired public final void setDataSource(javax.sql.DataSource dataSource)
public void setJobParametersIncrementer(JobParametersIncrementer jobParametersIncrementer)
jobParametersIncrementer
- the jobParametersIncrementer to set@Autowired public void setJobRepository(JobRepository jobRepository)
jobRepository
- the jobRepository to setpublic java.util.List<JobExecution> createJobExecutions(java.lang.String jobName, java.lang.String[] stepNames, int count) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException
JobRepository
to create some JobExecution
instances each with the given job name and each having step executions
with the given step names.jobName
- the name of the jobstepNames
- the names of the step executionscount
- the required number of instances of JobExecution
to
createJobExecution
JobExecutionAlreadyRunningException
- thrown if Job is already running.JobRestartException
- thrown if Job is not restartable.JobInstanceAlreadyCompleteException
- thrown if Job Instance is already complete.public java.util.List<JobExecution> createJobExecutions(int count) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException
JobRepository
to create some JobExecution
instances each with a single step execution.count
- the required number of instances of JobExecution
to
createJobExecution
JobExecutionAlreadyRunningException
- thrown if Job is already running.JobRestartException
- thrown if Job is not restartable.JobInstanceAlreadyCompleteException
- thrown if Job Instance is already complete.public void removeJobExecutions(java.util.Collection<JobExecution> list) throws org.springframework.dao.DataAccessException
JobExecution
instances, and all associated
JobInstance
and StepExecution
instances from the standard
RDBMS locations used by Spring Batch.list
- a list of JobExecution
org.springframework.dao.DataAccessException
- if there is a problempublic void removeJobExecutions() throws org.springframework.dao.DataAccessException
JobExecution
instances, and all associated
JobInstance
and StepExecution
instances from the standard
RDBMS locations used by Spring Batch.org.springframework.dao.DataAccessException
- if there is a problem