Package org.springframework.batch.test
Class JsrTestUtils
- java.lang.Object
- org.springframework.batch.test.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 Type Method Description static javax.batch.runtime.Metric
getMetric(javax.batch.runtime.StepExecution stepExecution, javax.batch.runtime.Metric.MetricType type)
static javax.batch.runtime.JobExecution
restartJob(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.JobExecution
runJob(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.TimeoutException
Executes 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, aTimeoutException
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 ofBatchStatus.STOPPED
,BatchStatus.COMPLETED
, orBatchStatus.FAILED
. If the job does not reach one of those statuses within the given timeout, aTimeoutException
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)