BATCH-1360: Throw helpful error from if Tasklet.execute() returns null

This commit is contained in:
dhgarrette
2009-08-06 05:20:02 +00:00
parent 9d694b7d6c
commit 2d6a9de873
2 changed files with 19 additions and 0 deletions

View File

@@ -843,6 +843,24 @@ public class TaskletStepTests {
}
@Test
public void testTaskletExecuteReturnNull() throws Exception {
step.setTasklet(new Tasklet() {
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
return null;
}
});
JobExecution jobExecutionContext = new JobExecution(jobInstance);
StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext);
step.execute(stepExecution);
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
List<Throwable> exceptions = stepExecution.getFailureExceptions();
assertEquals(1, exceptions.size());
Throwable exception = exceptions.get(0);
assertTrue(exception instanceof IllegalStateException);
assertEquals("Tasklet execution must return a non-null RepeatStatus.", exception.getMessage());
}
private static class JobRepositoryStub extends JobRepositorySupport {
private int updateCount = 0;