RESOLVED - issue BATCH-1210: AbstractStep overwrites custom exit status for STOPPED steps

This commit is contained in:
dsyer
2009-04-16 11:12:49 +00:00
parent 02290b366d
commit 50cda6b170
2 changed files with 26 additions and 6 deletions

View File

@@ -24,7 +24,7 @@ import org.springframework.util.Assert;
/**
* Tests for {@link AbstractStep}.
*/
public class AbstractStepTests {
public class NonAbstractStepTests {
AbstractStep tested = new EventTrackingStep();
@@ -188,9 +188,6 @@ public class AbstractStepTests {
.containsKey("afterStep"));
}
/**
* Exception during business processing.
*/
@Test
public void testFailure() throws Exception {
tested = new EventTrackingStep() {
@@ -225,7 +222,6 @@ public class AbstractStepTests {
assertTrue("Execution context modifications made by listener should be persisted", repository.saved
.containsKey("afterStep"));
}
/**
* Exception during business processing.
*/
@@ -262,6 +258,30 @@ public class AbstractStepTests {
.containsKey("afterStep"));
}
@Test
public void testStoppedStepWithCustomStatus() throws Exception {
tested = new EventTrackingStep() {
@Override
protected void doExecute(StepExecution context) throws Exception {
super.doExecute(context);
context.setTerminateOnly();
context.setExitStatus(new ExitStatus("FUNNY"));
}
};
tested.setJobRepository(repository);
tested.setStepExecutionListeners(new StepExecutionListener[] { listener1, listener2 });
tested.execute(execution);
assertEquals(BatchStatus.STOPPED, execution.getStatus());
Throwable expected = execution.getFailureExceptions().get(0);
assertEquals("JobExecution interrupted.", expected.getMessage());
assertEquals("FUNNY", execution.getExitStatus().getExitCode());
assertTrue("Execution context modifications made by listener should be persisted", repository.saved
.containsKey("afterStep"));
}
/**
* Exception during business processing.
*/