List of usage examples for org.springframework.batch.core.step.skip SkipPolicy SkipPolicy
SkipPolicy
From source file:org.springframework.batch.core.step.item.FaultTolerantStepFactoryBeanTests.java
/** * Check items causing errors are skipped as expected. *//*from ww w .ja v a2 s. c o m*/ @Test public void testReadSkipWithPolicyExceptionInReader() throws Exception { // Should be ignored factory.setSkipLimit(0); factory.setSkipPolicy(new SkipPolicy() { @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { throw new RuntimeException("Planned exception in SkipPolicy"); } }); reader.setFailures("2"); Step step = factory.getObject(); step.execute(stepExecution); assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); assertEquals(0, stepExecution.getReadSkipCount()); assertEquals(1, stepExecution.getReadCount()); }
From source file:org.springframework.batch.core.step.item.FaultTolerantStepFactoryBeanTests.java
/** * Check items causing errors are skipped as expected. *///from w w w .j av a 2 s . co m @Test public void testReadSkipWithPolicyExceptionInWriter() throws Exception { // Should be ignored factory.setSkipLimit(0); factory.setSkipPolicy(new SkipPolicy() { @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { throw new RuntimeException("Planned exception in SkipPolicy"); } }); writer.setFailures("2"); Step step = factory.getObject(); step.execute(stepExecution); assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); assertEquals(0, stepExecution.getWriteSkipCount()); assertEquals(2, stepExecution.getReadCount()); }