@Test public void testProvide() throws Exception { provider = new FaultTolerantChunkProvider<>(new ListItemReader<>(Arrays.asList("foo", "bar")), new RepeatTemplate()); Chunk<String> chunk = provider.provide(contribution); assertNotNull(chunk); assertEquals(2, chunk.getItems().size()); }
@Test public void testProvideWithOverflow() throws Exception { provider = new FaultTolerantChunkProvider<>(new ItemReader<String>() { @Override public String read() throws Exception, UnexpectedInputException, ParseException { throw new RuntimeException("Planned"); } }, new RepeatTemplate()); provider.setSkipPolicy(new LimitCheckingItemSkipPolicy(Integer.MAX_VALUE, Collections.<Class<? extends Throwable>,Boolean>singletonMap(Exception.class, Boolean.TRUE))); provider.setMaxSkipsOnRead(10); Chunk<String> chunk = null; chunk = provider.provide(contribution); assertNotNull(chunk); assertEquals(0, chunk.getItems().size()); assertEquals(10, chunk.getErrors().size()); } }