Class JsrTestUtils


  • public class JsrTestUtils
    extends java.lang.Object
    Provides testing utilities to execute JSR-352 jobs and block until they are complete (since all JSR-352 based jobs are executed asynchronously).
    Since:
    3.0
    Author:
    Michael Minella, Mahmoud Ben Hassine
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static javax.batch.runtime.MetricgetMetric​(javax.batch.runtime.StepExecution stepExecution, javax.batch.runtime.Metric.MetricType type) 
      static javax.batch.runtime.JobExecutionrestartJob​(long executionId, java.util.Properties properties, long timeout)
      Restarts a job and waits for it's status to be any of BatchStatus.STOPPED, BatchStatus.COMPLETED, or BatchStatus.FAILED.
      static javax.batch.runtime.JobExecutionrunJob​(java.lang.String jobName, java.util.Properties properties, long timeout)
      Executes a job and waits for it's status to be any of BatchStatus.STOPPED, BatchStatus.COMPLETED, or BatchStatus.FAILED.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • runJob

        public static javax.batch.runtime.JobExecution runJob​(java.lang.String jobName,
                                                              java.util.Properties properties,
                                                              long timeout)
                                                       throws java.util.concurrent.TimeoutException
        Executes a job and waits for it's status to be any of BatchStatus.STOPPED, BatchStatus.COMPLETED, or BatchStatus.FAILED. If the job does not reach one of those statuses within the given timeout, a TimeoutException is thrown.
        Parameters:
        jobName - the name of the job.
        properties - job parameters to be associated with the job.
        timeout - maximum amount of time to wait in milliseconds.
        Returns:
        the JobExecution for the final state of the job
        Throws:
        java.util.concurrent.TimeoutException - if the timeout occurs
      • restartJob

        public static javax.batch.runtime.JobExecution restartJob​(long executionId,
                                                                  java.util.Properties properties,
                                                                  long timeout)
                                                           throws java.util.concurrent.TimeoutException
        Restarts a job and waits for it's status to be any of BatchStatus.STOPPED, BatchStatus.COMPLETED, or BatchStatus.FAILED. If the job does not reach one of those statuses within the given timeout, a TimeoutException is thrown.
        Parameters:
        executionId - the id of the job execution to restart.
        properties - job parameters to be associated with the job.
        timeout - maximum amount of time to wait in milliseconds.
        Returns:
        the JobExecution for the final state of the job
        Throws:
        java.util.concurrent.TimeoutException - if the timeout occurs
      • getMetric

        @Nullable
        public static javax.batch.runtime.Metric getMetric​(javax.batch.runtime.StepExecution stepExecution,
                                                           javax.batch.runtime.Metric.MetricType type)