IN PROGRESS - issue BATCH-456: JobListener.afterJob() should be called regardless of success or failure

http://jira.springframework.org/browse/BATCH-456

added JobListener#onError(JobExecution, Throwable) called when job failed (not when interrupted)
This commit is contained in:
robokaso
2008-03-14 09:26:18 +00:00
parent 9b1bd77e8a
commit 8c281d1021
5 changed files with 40 additions and 8 deletions

View File

@@ -250,6 +250,25 @@ public class SimpleJobTests extends TestCase {
assertEquals(0, list.size());
checkRepository(BatchStatus.FAILED, ExitStatus.FAILED);
}
public void testFailedWithListener() throws Exception {
job.setJobListeners(new JobListenerSupport[] { new JobListenerSupport() {
public void onError(JobExecution jobExecution, Throwable t) {
list.add(t);
}
} });
final RuntimeException exception = new RuntimeException("Foo!");
stepConfiguration1.setProcessException(exception);
try {
job.execute(jobExecution);
} catch (RuntimeException e) {
assertEquals(exception, e);
}
assertEquals(1, list.size());
assertSame(exception, list.get(0));
checkRepository(BatchStatus.FAILED, ExitStatus.FAILED);
}
public void testFailedWithError() throws Exception {
stepConfiguration1.setStartLimit(5);