This commit is contained in:
dsyer
2009-11-26 18:06:16 +00:00
parent f5e515242a
commit 4b2f90158d
3 changed files with 44 additions and 12 deletions

View File

@@ -363,6 +363,39 @@ public class FaultTolerantStepFactoryBeanTests {
.getName()));
}
/**
* Check items causing errors are skipped as expected.
*/
@Test
public void testSkipOverLimitOnReadWithListener() throws Exception {
reader.setFailures("1", "3", "5");
writer.setFailures();
final List<Throwable> listenerCalls = new ArrayList<Throwable>();
factory.setListeners(new StepListener[] { new SkipListenerSupport<String, String>() {
@Override
public void onSkipInRead(Throwable t) {
listenerCalls.add(t);
}
} });
factory.setCommitInterval(2);
factory.setSkipLimit(2);
Step step = (Step) factory.getObject();
step.execute(stepExecution);
// 1,3 skipped inside a committed chunk. 5 tripped the skip
// limit but it was skipped in a chunk that rolled back, so
// it will re-appear on a restart and the listener is not called.
assertEquals(2, listenerCalls.size());
assertEquals(2, stepExecution.getReadSkipCount());
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
}
/**
* Check items causing errors are skipped as expected.
*/
@@ -767,8 +800,6 @@ public class FaultTolerantStepFactoryBeanTests {
private static class ItemProcessListenerStub<T, S> implements ItemProcessListener<T, S> {
private boolean errorEncountered = false;
private boolean filterEncountered = false;
public void afterProcess(T item, S result) {
@@ -782,11 +813,6 @@ public class FaultTolerantStepFactoryBeanTests {
}
public void onProcessError(T item, Exception e) {
errorEncountered = true;
}
public boolean isErrorEncountered() {
return errorEncountered;
}
public boolean isFilterEncountered() {