@Test
public void testStageFailOnChainFailure() throws Exception {
// allow time to grow pool
Stage stage = new Stage();
BaseChain task1 = new SuccessTask();
BaseChain task2 = new FailTask();
BaseChain task1a = new SuccessTask();
BaseChain task2a = new SuccessTask();
task1.chain(task1a);
task2.chain(task2a);
stage.stage(task1);
stage.stage(task2);
manager.blockingSubmit(stage);
assertEquals("Stage failed",TaskStatus.FAILED,stage.getStatus());
assertEquals("Task 2 failed",TaskStatus.FAILED,task2.getStatus());
assertEquals("Task 2a canceled",TaskStatus.CANCELED,task2a.getStatus());
assertEquals("Task 1 success",TaskStatus.SUCCESS,task1.getStatus());
assertEquals("Task 1a success",TaskStatus.SUCCESS,task1a.getStatus());
stage = new Stage();
task1 = new SuccessTask();
task2 = new SuccessTask();
task1a = new SuccessTask();
task2a = new FailTask();
task1.chain(task1a);
task2.chain(task2a);
stage.stage(task1);
stage.stage(task2);
manager.blockingSubmit(stage);
assertEquals("Stage failed",TaskStatus.FAILED,stage.getStatus());
assertEquals("Task 2 failed",TaskStatus.SUCCESS,task2.getStatus());
assertEquals("Task 2a canceled",TaskStatus.FAILED,task2a.getStatus());
assertEquals("Task 1 success",TaskStatus.SUCCESS,task1.getStatus());
assertEquals("Task 1a success",TaskStatus.SUCCESS,task1a.getStatus());
}