Package org.springframework.batch.test
Class JsrTestUtils
- java.lang.Object
- org.springframework.batch.test.JsrTestUtils
public class JsrTestUtils extends java.lang.ObjectProvides 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 Type Method Description 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 ofBatchStatus.STOPPED,BatchStatus.COMPLETED, orBatchStatus.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 ofBatchStatus.STOPPED,BatchStatus.COMPLETED, orBatchStatus.FAILED.
Method Detail
runJob
public static javax.batch.runtime.JobExecution runJob(java.lang.String jobName, java.util.Properties properties, long timeout) throws java.util.concurrent.TimeoutExceptionExecutes a job and waits for it's status to be any ofBatchStatus.STOPPED,BatchStatus.COMPLETED, orBatchStatus.FAILED. If the job does not reach one of those statuses within the given timeout, aTimeoutExceptionis 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
JobExecutionfor 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.TimeoutExceptionRestarts a job and waits for it's status to be any ofBatchStatus.STOPPED,BatchStatus.COMPLETED, orBatchStatus.FAILED. If the job does not reach one of those statuses within the given timeout, aTimeoutExceptionis 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
JobExecutionfor 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)