Skip to content
Browse files
BATCHEE-33 adding JavaDocs and test
txs to Reinhard Sandtner for the test. Applied.
I did not apply the method name change as getIterator is too technical
and does not tell the user what it should iterate over.
We also kept the Iterator after discussions on the list.
  • Loading branch information
struberg committed Apr 28, 2014
1 parent 9bf9764 commit 8cbed5e92629a7bddd51b7ad4c50f05129189155
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
@@ -38,7 +38,13 @@

private Iterator<R> valuesIt = null;

public abstract Iterator<R> readAllItems();
* This methods need to return all the items to be read.
* We will 'cache' them and iterate through them until all the
* items got consumed.
* @return all the items to be read
protected abstract Iterator<R> readAllItems();

@@ -46,6 +46,16 @@ public void testBufferedRead() throws Exception {
Assert.assertEquals(DummyWriter.getItems().get(2), "C");

public void testBufferedRead_iterableNull() throws Exception {

JobOperator jobOperator = BatchRuntime.getJobOperator();
Batches.waitForEnd(jobOperator, jobOperator.start("buffered-read-null", new Properties()));

Assert.assertTrue(DummyWriter.getItems().isEmpty(), "items must be empty");

public static class MyBufferedItemReader extends BufferedItemReader<String> {
@@ -54,6 +64,14 @@ public Iterator<String> readAllItems() {

public static class MyNullBufferedItemReader extends BufferedItemReader<Number> {

public Iterator<Number> readAllItems() {
return null;

public static class DummyWriter extends AbstractItemWriter {
private static List<Object> items = new ArrayList<Object>();

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
See the NOTICE file distributed with this work for additional information
regarding copyright ownership. Licensed under the Apache License,
Version 2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
<job id="buffered-read-null" xmlns="" version="1.0">
<step id="step">
<reader ref="org.apache.batchee.extras.BufferedItemReaderTest$MyNullBufferedItemReader" />
<writer ref="org.apache.batchee.extras.BufferedItemReaderTest$DummyWriter" />

0 comments on commit 8cbed5e

Please sign in to comment.