Set the StepExecution ExitStatus in the JobStep doExecute
This commit is contained in:
committed by
Michael Minella
parent
fa286dc1e9
commit
509be945fc
@@ -21,6 +21,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
@@ -203,4 +204,19 @@ public class JobStepTests {
|
||||
|
||||
assertEquals(BatchStatus.STOPPED, stepExecution.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStepExecutionExitStatus() throws Exception {
|
||||
step.setJob(new JobSupport("child") {
|
||||
@Override
|
||||
public void execute(JobExecution execution) throws UnexpectedJobExecutionException {
|
||||
execution.setStatus(BatchStatus.COMPLETED);
|
||||
execution.setExitStatus(new ExitStatus("CUSTOM"));
|
||||
execution.setEndTime(new Date());
|
||||
}
|
||||
});
|
||||
step.afterPropertiesSet();
|
||||
step.execute(stepExecution);
|
||||
assertEquals("CUSTOM", stepExecution.getExitStatus().getExitCode());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user