Class JobRepositoryTestUtils

java.lang.Object
org.springframework.batch.test.JobRepositoryTestUtils

public class JobRepositoryTestUtils extends Object
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

    Constructors
    Constructor
    Description
    JobRepositoryTestUtils(org.springframework.batch.core.repository.JobRepository jobRepository)
    Create a JobRepositoryTestUtils with all its mandatory properties.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<org.springframework.batch.core.job.JobExecution>
    Use the JobRepository to create some JobExecution instances each with a single step execution.
    List<org.springframework.batch.core.job.JobExecution>
    createJobExecutions(String jobName, 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
    removeJobExecution(org.springframework.batch.core.job.JobExecution jobExecution)
    Remove the JobExecution and its associated StepExecution instances from the standard locations used by Spring Batch.
    void
    Remove all the JobExecution instances, and all associated JobInstance and StepExecution instances from the standard locations used by Spring Batch.
    void
    removeJobExecutions(Collection<org.springframework.batch.core.job.JobExecution> jobExecutions)
    Remove the JobExecution instances, and all associated JobInstance and StepExecution instances from the standard locations used by Spring Batch.
    void
    setJobParametersIncrementer(org.springframework.batch.core.job.parameters.JobParametersIncrementer jobParametersIncrementer)
     
    void
    setJobRepository(org.springframework.batch.core.repository.JobRepository jobRepository)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JobRepositoryTestUtils

      public JobRepositoryTestUtils(org.springframework.batch.core.repository.JobRepository jobRepository)
      Create a JobRepositoryTestUtils with all its mandatory properties.
      Parameters:
      jobRepository - a JobRepository.
  • 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 the JobRepository to create some JobExecution instances each with the given job name and each having step executions with the given step names.
      Parameters:
      jobName - the name of the job
      stepNames - the names of the step executions
      count - the required number of instances of JobExecution to 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 the JobRepository to create some JobExecution instances each with a single step execution.
      Parameters:
      count - the required number of instances of JobExecution to 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 the JobExecution instances, and all associated JobInstance and StepExecution instances from the standard locations used by Spring Batch.
      Parameters:
      jobExecutions - a collection of JobExecution
    • removeJobExecution

      public void removeJobExecution(org.springframework.batch.core.job.JobExecution jobExecution)
      Remove the JobExecution and its associated StepExecution instances from the standard locations used by Spring Batch.
      Parameters:
      jobExecution - the JobExecution to delete
    • removeJobExecutions

      public void removeJobExecutions()
      Remove all the JobExecution instances, and all associated JobInstance and StepExecution instances from the standard locations used by Spring Batch.