Set the StepExecution ExitStatus in the JobStep doExecute

This commit is contained in:
Eduardo Jolo
2017-04-28 15:23:17 -03:00
committed by Michael Minella
parent fa286dc1e9
commit 509be945fc
2 changed files with 34 additions and 1 deletions

View File

@@ -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());
}
}