olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmarte...@apache.org
Subject git commit: [OLINGO-246] improve hasNext() and next() item iterator methods
Date Sat, 26 Apr 2014 13:51:33 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master 96b8cd96a -> 6a5fc3548


[OLINGO-246] improve hasNext() and next() item iterator methods


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/6a5fc354
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/6a5fc354
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/6a5fc354

Branch: refs/heads/master
Commit: 6a5fc354832df92c243f63698bd1a57e7ebf538e
Parents: 96b8cd9
Author: fmartelli <fabio.martelli@gmail.com>
Authored: Sat Apr 26 15:51:11 2014 +0200
Committer: fmartelli <fabio.martelli@gmail.com>
Committed: Sat Apr 26 15:51:11 2014 +0200

----------------------------------------------------------------------
 .../request/batch/ODataBatchResponseItem.java   |  7 +++++
 .../request/batch/v4/ODataBatchRequest.java     |  2 ++
 .../batch/AbstractBatchRequestFactory.java      |  4 +--
 .../batch/AbstractODataBatchResponseItem.java   | 18 ++++++++++++-
 .../batch/ODataChangesetResponseItem.java       | 27 ++++++++------------
 .../batch/ODataRetrieveResponseItem.java        | 13 ++++++----
 .../batch/v3/BatchRequestFactoryImpl.java       |  3 ++-
 .../request/batch/v3/ODataBatchRequestImpl.java |  4 +--
 .../batch/v4/BatchRequestFactoryImpl.java       |  3 ++-
 .../request/batch/v4/ODataBatchRequestImpl.java | 17 +++++++++---
 .../streamed/AbstractODataStreamedRequest.java  |  2 +-
 .../batch/ODataBatchResponseManager.java        | 17 ++++++++++--
 .../client/core/it/v4/BatchTestITCase.java      | 13 +++++-----
 13 files changed, 89 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataBatchResponseItem.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataBatchResponseItem.java
b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataBatchResponseItem.java
index 982bd8e..3882504 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataBatchResponseItem.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataBatchResponseItem.java
@@ -50,6 +50,13 @@ public interface ODataBatchResponseItem extends Iterator<ODataResponse>
{
   boolean isChangeset();
 
   /**
+   * Checks if the current item is a braking item like as error item or asynchronous response
part.
+   *
+   * @return 'TRUE' if breaking; 'FALSE' otherwise.
+   */
+  boolean isBreakingitem();
+
+  /**
    * Closes the current batch responses item including all wrapped OData responses.
    */
   void close();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/ODataBatchRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/ODataBatchRequest.java
b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/ODataBatchRequest.java
index 9498d99..8175465 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/ODataBatchRequest.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/ODataBatchRequest.java
@@ -27,4 +27,6 @@ import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
  */
 public interface ODataBatchRequest
         extends CommonODataBatchRequest, ODataStreamedRequest<ODataBatchResponse, BatchStreamManager>
{
+
+  ODataBatchRequest continueOnError();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchRequestFactory.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchRequestFactory.java
index 1be8f5c..631dbed 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchRequestFactory.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchRequestFactory.java
@@ -22,9 +22,9 @@ public abstract class AbstractBatchRequestFactory implements CommonBatchRequestF
 
   private static final long serialVersionUID = -3875283254713404483L;
 
-  protected final CommonODataClient client;
+  protected final CommonODataClient<?> client;
 
-  protected AbstractBatchRequestFactory(final CommonODataClient client) {
+  protected AbstractBatchRequestFactory(final CommonODataClient<?> client) {
     this.client = client;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchResponseItem.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchResponseItem.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchResponseItem.java
index 79b8f07..a21e0aa 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchResponseItem.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchResponseItem.java
@@ -68,12 +68,20 @@ public abstract class AbstractODataBatchResponseItem implements ODataBatchRespon
   protected boolean closed = false;
 
   /**
+   * Last cached OData response.
+   */
+  protected ODataResponse current;
+
+  protected boolean breakingitem = false;
+
+  /**
    * Constructor.
    *
    * @param isChangeset 'TRUE' if the current batch response item is a changeset.
    */
   public AbstractODataBatchResponseItem(boolean isChangeset) {
     this.changeset = isChangeset;
+    this.current = null;
   }
 
   /**
@@ -135,7 +143,15 @@ public abstract class AbstractODataBatchResponseItem implements ODataBatchRespon
       expectedItemsIterator = responses.values().iterator();
     }
 
-    return expectedItemsIterator.hasNext();
+    return !breakingitem && expectedItemsIterator.hasNext();
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public boolean isBreakingitem() {
+    return breakingitem;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetResponseItem.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetResponseItem.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetResponseItem.java
index 63e7cad..53eeb16 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetResponseItem.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetResponseItem.java
@@ -31,11 +31,6 @@ import org.apache.olingo.client.core.communication.response.batch.ODataBatchErro
  */
 public class ODataChangesetResponseItem extends AbstractODataBatchResponseItem {
 
-  /**
-   * Last cached OData response.
-   */
-  private ODataResponse current = null;
-
   private boolean unexpected = false;
 
   /**
@@ -62,7 +57,12 @@ public class ODataChangesetResponseItem extends AbstractODataBatchResponseItem
{
       throw new IllegalStateException("Invalid request - the item has been closed");
     }
 
+    if (!hasNext()) {
+      throw new NoSuchElementException("No item found");
+    }
+
     if (unexpected) {
+      breakingitem = true;
       return nextUnexpected();
     } else {
       return nextExpected();
@@ -70,12 +70,8 @@ public class ODataChangesetResponseItem extends AbstractODataBatchResponseItem
{
   }
 
   private ODataResponse nextExpected() {
-    if (hasNext()) {
-      // consume item for condition above (like a counter ...)
-      expectedItemsIterator.next();
-    } else {
-      throw new NoSuchElementException("No item found");
-    }
+    // consume item for condition above (used like a counter ...)
+    expectedItemsIterator.next();
 
     final Map<String, Collection<String>> nextItemHeaders =
             ODataBatchUtilities.nextItemHeaders(batchLineIterator, boundary);
@@ -109,10 +105,8 @@ public class ODataChangesetResponseItem extends AbstractODataBatchResponseItem
{
     current.initFromBatch(responseLine, headers, batchLineIterator, boundary);
 
     if (current.getStatusCode() >= 400) {
-      // found error .... consume expeted items
-      while (expectedItemsIterator.hasNext()) {
-        expectedItemsIterator.next();
-      }
+      // found error .... 
+      breakingitem = true;
     }
 
     return current;
@@ -127,7 +121,8 @@ public class ODataChangesetResponseItem extends AbstractODataBatchResponseItem
{
       final Map<String, Collection<String>> headers = ODataBatchUtilities.readHeaders(batchLineIterator);
       LOG.debug("Retrieved item headers {}", headers);
 
-      return new ODataBatchErrorResponse(responseLine, headers, batchLineIterator, boundary);
+      current = new ODataBatchErrorResponse(responseLine, headers, batchLineIterator, boundary);
+      return current;
     }
 
     throw new IllegalStateException("Expected item not found");

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveResponseItem.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveResponseItem.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveResponseItem.java
index 2a45bb2..8919ffe 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveResponseItem.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveResponseItem.java
@@ -48,25 +48,28 @@ public class ODataRetrieveResponseItem extends AbstractODataBatchResponseItem
{
       throw new IllegalStateException("Invalid request - the item has been closed");
     }
 
+    if (!hasNext()) {
+      throw new NoSuchElementException("No item found");
+    }
+
     final Map.Entry<Integer, String> responseLine = ODataBatchUtilities.readResponseLine(batchLineIterator);
     LOG.debug("Retrieved item response {}", responseLine);
 
     final Map<String, Collection<String>> headers = ODataBatchUtilities.readHeaders(batchLineIterator);
     LOG.debug("Retrieved item headers {}", headers);
 
-    final ODataResponse res;
-
     if (responseLine.getKey() >= 400) {
       // generate error response
-      res = new ODataBatchErrorResponse(responseLine, headers, batchLineIterator, boundary);
+      current = new ODataBatchErrorResponse(responseLine, headers, batchLineIterator, boundary);
+      breakingitem = true;
     } else {
       if (!hasNext()) {
         throw new NoSuchElementException("No item found");
       }
-      res = expectedItemsIterator.next().initFromBatch(responseLine, headers, batchLineIterator,
boundary);
+      current = expectedItemsIterator.next().initFromBatch(responseLine, headers, batchLineIterator,
boundary);
     }
 
-    return res;
+    return current;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/BatchRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/BatchRequestFactoryImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/BatchRequestFactoryImpl.java
index 2049743..d796532 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/BatchRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/BatchRequestFactoryImpl.java
@@ -34,6 +34,7 @@ public class BatchRequestFactoryImpl extends AbstractBatchRequestFactory
 
   @Override
   public ODataBatchRequest getBatchRequest(final String serviceRoot) {
-    return new ODataBatchRequestImpl(client, client.getURIBuilder(serviceRoot).appendBatchSegment().build());
+    return new ODataBatchRequestImpl(
+            (ODataClient) client, client.getURIBuilder(serviceRoot).appendBatchSegment().build());
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java
index dd3f365..c4b0bdb 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java
@@ -24,12 +24,12 @@ import java.util.Iterator;
 import java.util.concurrent.TimeUnit;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
-import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.communication.request.ODataStreamedRequest;
 import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
 import org.apache.olingo.client.api.communication.request.batch.v3.BatchStreamManager;
 import org.apache.olingo.client.api.communication.request.batch.v3.ODataBatchRequest;
 import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
+import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.client.core.communication.request.batch.AbstractBatchStreamManager;
 import org.apache.olingo.client.core.communication.request.batch.AbstractODataBatchRequest;
 import org.apache.olingo.client.core.communication.request.batch.v3.ODataBatchRequestImpl.BatchStreamManagerImpl;
@@ -44,7 +44,7 @@ public class ODataBatchRequestImpl
         extends AbstractODataBatchRequest<ODataBatchResponse, BatchStreamManager>
         implements ODataBatchRequest, ODataStreamedRequest<ODataBatchResponse, BatchStreamManager>
{
 
-  public ODataBatchRequestImpl(final CommonODataClient<?> odataClient, final URI uri)
{
+  public ODataBatchRequestImpl(final ODataClient odataClient, final URI uri) {
     super(odataClient, uri);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/BatchRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/BatchRequestFactoryImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/BatchRequestFactoryImpl.java
index a08f7f1..bb44812 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/BatchRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/BatchRequestFactoryImpl.java
@@ -34,6 +34,7 @@ public class BatchRequestFactoryImpl extends AbstractBatchRequestFactory
 
   @Override
   public ODataBatchRequest getBatchRequest(final String serviceRoot) {
-    return new ODataBatchRequestImpl(client, client.getURIBuilder(serviceRoot).appendBatchSegment().build());
+    return new ODataBatchRequestImpl(
+            (ODataClient) client, client.getURIBuilder(serviceRoot).appendBatchSegment().build());
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java
index 5251838..648cb35 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java
@@ -24,12 +24,14 @@ import java.util.Iterator;
 import java.util.concurrent.TimeUnit;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
-import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.communication.header.HeaderName;
+import org.apache.olingo.client.api.communication.header.ODataPreferences;
 import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
 import org.apache.olingo.client.api.communication.request.batch.v4.BatchStreamManager;
 import org.apache.olingo.client.api.communication.request.batch.v4.ODataBatchRequest;
 import org.apache.olingo.client.api.communication.request.batch.v4.ODataOutsideUpdate;
 import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
+import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.communication.request.batch.AbstractBatchStreamManager;
 import org.apache.olingo.client.core.communication.request.batch.AbstractODataBatchRequest;
 import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
@@ -43,7 +45,9 @@ public class ODataBatchRequestImpl
         extends AbstractODataBatchRequest<ODataBatchResponse, BatchStreamManager>
         implements ODataBatchRequest {
 
-  public ODataBatchRequestImpl(final CommonODataClient odataClient, final URI uri) {
+  private boolean continueOnError = false;
+
+  public ODataBatchRequestImpl(final ODataClient odataClient, final URI uri) {
     super(odataClient, uri);
     setAccept(ContentType.MULTIPART_MIXED);
   }
@@ -74,6 +78,13 @@ public class ODataBatchRequestImpl
     return this;
   }
 
+  @Override
+  public ODataBatchRequest continueOnError() {
+    addCustomHeader(HeaderName.prefer, new ODataPreferences(odataClient.getServiceVersion()).continueOnError());
+    continueOnError = true;
+    return this;
+  }
+
   /**
    * Batch request payload management.
    */
@@ -126,7 +137,7 @@ public class ODataBatchRequestImpl
      */
     @Override
     public Iterator<ODataBatchResponseItem> getBody() {
-      return new ODataBatchResponseManager(this, expectedResItems);
+      return new ODataBatchResponseManager(this, expectedResItems, continueOnError);
     }
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
index 056579f..0a78d83 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
@@ -68,7 +68,7 @@ public abstract class AbstractODataStreamedRequest<V extends ODataResponse,
T ex
    * @param method OData request HTTP method.
    * @param uri OData request URI.
    */
-  public AbstractODataStreamedRequest(final CommonODataClient odataClient,
+  public AbstractODataStreamedRequest(final CommonODataClient<?> odataClient,
           final HttpMethod method, final URI uri) {
 
     super(odataClient, ODataMediaFormat.class, method, uri);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java
index b91dd8a..9db555e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/batch/ODataBatchResponseManager.java
@@ -66,13 +66,26 @@ public class ODataBatchResponseManager implements Iterator<ODataBatchResponseIte
    */
   private ODataBatchResponseItem current = null;
 
+  private final boolean continueOnError;
+
   /**
    * Constructor.
    *
    * @param res OData batch response.
    * @param expectedItems expected batch response items.
    */
-  public ODataBatchResponseManager(final ODataBatchResponse res, final List<ODataBatchResponseItem>
expectedItems) {
+  public ODataBatchResponseManager(
+          final ODataBatchResponse res,
+          final List<ODataBatchResponseItem> expectedItems) {
+    this(res, expectedItems, false);
+  }
+
+  public ODataBatchResponseManager(
+          final ODataBatchResponse res,
+          final List<ODataBatchResponseItem> expectedItems,
+          final boolean continueOnError) {
+    this.continueOnError = continueOnError;
+
     try {
       this.expectedItemsIterator = expectedItems.iterator();
       this.batchLineIterator = new ODataBatchLineIteratorImpl(
@@ -93,7 +106,7 @@ public class ODataBatchResponseManager implements Iterator<ODataBatchResponseIte
    */
   @Override
   public boolean hasNext() {
-    return expectedItemsIterator.hasNext();
+    return (current == null || continueOnError || !current.isBreakingitem()) && expectedItemsIterator.hasNext();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6a5fc354/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/BatchTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/BatchTestITCase.java
b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/BatchTestITCase.java
index bb5b100..8a798dd 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/BatchTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/BatchTestITCase.java
@@ -32,8 +32,6 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import org.apache.http.HttpResponse;
 import org.apache.olingo.client.api.ODataBatchConstants;
-import org.apache.olingo.client.api.communication.header.HeaderName;
-import org.apache.olingo.client.api.communication.header.ODataPreferences;
 import org.apache.olingo.client.api.communication.request.ODataStreamManager;
 import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
 import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
@@ -154,8 +152,9 @@ public class BatchTestITCase extends AbstractTestITCase {
     assertEquals(200, response.getStatusCode());
     assertEquals("OK", response.getStatusMessage());
 
+    final Iterator<ODataBatchResponseItem> iter = response.getBody();
     // retrieve the first item (ODataRetrieve)
-    ODataBatchResponseItem item = response.getBody().next();
+    ODataBatchResponseItem item = iter.next();
 
     ODataChangesetResponseItem retitem = (ODataChangesetResponseItem) item;
     ODataResponse res = retitem.next();
@@ -163,6 +162,9 @@ public class BatchTestITCase extends AbstractTestITCase {
     assertEquals("Not Found", res.getStatusMessage());
     assertEquals(Integer.valueOf(3), Integer.valueOf(
             res.getHeader(ODataBatchConstants.CHANGESET_CONTENT_ID_NAME).iterator().next()));
+
+    assertFalse(retitem.hasNext());
+    assertFalse(iter.hasNext());
   }
 
   @Test
@@ -179,10 +181,7 @@ public class BatchTestITCase extends AbstractTestITCase {
     // create your request
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL);
     request.setAccept(ACCEPT);
-
-    if (continueOnError) {
-      request.addCustomHeader(HeaderName.prefer, new ODataPreferences(client.getServiceVersion()).continueOnError());
-    }
+    request.continueOnError();
 
     final BatchStreamManager streamManager = request.execute();
 


Mime
View raw message