// The after is not executed, if there is an error...
assertEquals("[2]", calls.toString());
}
public void testAsynchronousOnErrorInterceptorsPrecedence() throws Exception {
TaskExecutorRepeatTemplate template = new TaskExecutorRepeatTemplate();
template.setTaskExecutor(new SimpleAsyncTaskExecutor());
final List<Object> calls = new ArrayList<Object>();
final List<Object> fails = new ArrayList<Object>();
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
@Override
public void after(RepeatContext context, RepeatStatus result) {
calls.add("1");
}
}, new RepeatListenerSupport() {
@Override
public void onError(RepeatContext context, Throwable t) {
calls.add("2");
fails.add("2");
}
} });
try {
template.iterate(new RepeatCallback() {
@Override
public RepeatStatus doInIteration(RepeatContext context) throws Exception {
throw new IllegalStateException("Bogus");
}
});