You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@batchee.apache.org by st...@apache.org on 2014/04/28 14:21:50 UTC

git commit: BATCHEE-33 adding JavaDocs and test

Repository: incubator-batchee
Updated Branches:
  refs/heads/master 9bf9764af -> 8cbed5e92


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.


Project: http://git-wip-us.apache.org/repos/asf/incubator-batchee/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-batchee/commit/8cbed5e9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-batchee/tree/8cbed5e9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-batchee/diff/8cbed5e9

Branch: refs/heads/master
Commit: 8cbed5e92629a7bddd51b7ad4c50f05129189155
Parents: 9bf9764
Author: Mark Struberg <st...@apache.org>
Authored: Mon Apr 28 14:20:20 2014 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Mon Apr 28 14:20:20 2014 +0200

----------------------------------------------------------------------
 .../extras/buffered/BufferedItemReader.java     |  8 ++++++-
 .../batchee/extras/BufferedItemReaderTest.java  | 18 +++++++++++++++
 .../META-INF/batch-jobs/buffered-read-null.xml  | 23 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/8cbed5e9/extensions/extras/src/main/java/org/apache/batchee/extras/buffered/BufferedItemReader.java
----------------------------------------------------------------------
diff --git a/extensions/extras/src/main/java/org/apache/batchee/extras/buffered/BufferedItemReader.java b/extensions/extras/src/main/java/org/apache/batchee/extras/buffered/BufferedItemReader.java
index f9ea4be..2eb1a00 100644
--- a/extensions/extras/src/main/java/org/apache/batchee/extras/buffered/BufferedItemReader.java
+++ b/extensions/extras/src/main/java/org/apache/batchee/extras/buffered/BufferedItemReader.java
@@ -38,7 +38,13 @@ public abstract class BufferedItemReader<R> extends NoStateTypedItemReader<R> {
 
     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();
 
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/8cbed5e9/extensions/extras/src/test/java/org/apache/batchee/extras/BufferedItemReaderTest.java
----------------------------------------------------------------------
diff --git a/extensions/extras/src/test/java/org/apache/batchee/extras/BufferedItemReaderTest.java b/extensions/extras/src/test/java/org/apache/batchee/extras/BufferedItemReaderTest.java
index 583dfb9..101a96e 100644
--- a/extensions/extras/src/test/java/org/apache/batchee/extras/BufferedItemReaderTest.java
+++ b/extensions/extras/src/test/java/org/apache/batchee/extras/BufferedItemReaderTest.java
@@ -46,6 +46,16 @@ public class BufferedItemReaderTest {
         Assert.assertEquals(DummyWriter.getItems().get(2), "C");
     }
 
+    @Test
+    public void testBufferedRead_iterableNull() throws Exception {
+        DummyWriter.getItems().clear();
+
+        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> {
         @Override
@@ -54,6 +64,14 @@ public class BufferedItemReaderTest {
         }
     }
 
+    public static class MyNullBufferedItemReader extends BufferedItemReader<Number> {
+
+        @Override
+        public Iterator<Number> readAllItems() {
+            return null;
+        }
+    }
+
     public static class DummyWriter extends AbstractItemWriter {
         private static List<Object> items = new ArrayList<Object>();
 

http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/8cbed5e9/extensions/extras/src/test/resources/META-INF/batch-jobs/buffered-read-null.xml
----------------------------------------------------------------------
diff --git a/extensions/extras/src/test/resources/META-INF/batch-jobs/buffered-read-null.xml b/extensions/extras/src/test/resources/META-INF/batch-jobs/buffered-read-null.xml
new file mode 100644
index 0000000..b0d6e4c
--- /dev/null
+++ b/extensions/extras/src/test/resources/META-INF/batch-jobs/buffered-read-null.xml
@@ -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
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<job id="buffered-read-null" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
+    <step id="step">
+        <chunk>
+            <reader ref="org.apache.batchee.extras.BufferedItemReaderTest$MyNullBufferedItemReader" />
+            <writer ref="org.apache.batchee.extras.BufferedItemReaderTest$DummyWriter" />
+        </chunk>
+    </step>
+</job>