You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/11/18 16:12:20 UTC

[19/22] olingo-odata4 git commit: [OLINGO-472] Batch Refactoring

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/51acf8ae/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/BatchRequestParserTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/BatchRequestParserTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/BatchRequestParserTest.java
deleted file mode 100644
index cc249be..0000000
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/BatchRequestParserTest.java
+++ /dev/null
@@ -1,1326 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-package org.apache.olingo.server.core.batch;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URISyntaxException;
-import java.util.List;
-
-import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.batch.BatchException;
-import org.apache.olingo.server.api.batch.BatchRequestPart;
-import org.apache.olingo.server.api.batch.BatchException.MessageKeys;
-import org.apache.olingo.server.core.batch.parser.BatchParser;
-import org.apache.olingo.server.core.batch.parser.BatchParserCommon;
-import org.junit.Test;
-
-public class BatchRequestParserTest {
-
-  private static final String SERVICE_ROOT = "http://localhost/odata";
-  private static final String CONTENT_TYPE = "multipart/mixed;boundary=batch_8194-cf13-1f56";
-  private static final String CRLF = "\r\n";
-  private static final String MIME_HEADERS = "Content-Type: application/http" + CRLF
-      + "Content-Transfer-Encoding: binary" + CRLF;
-  private static final String GET_REQUEST = ""
-      + MIME_HEADERS
-      + CRLF
-      + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-      + CRLF
-      + CRLF;
-
-  @Test
-  public void test() throws IOException, BatchException, URISyntaxException {
-    final InputStream in = readFile("/batchWithPost.batch");
-    final List<BatchRequestPart> batchRequestParts = parse(in);
-
-    assertNotNull(batchRequestParts);
-    assertFalse(batchRequestParts.isEmpty());
-
-    for (BatchRequestPart object : batchRequestParts) {
-      if (!object.isChangeSet()) {
-        assertEquals(1, object.getRequests().size());
-        ODataRequest retrieveRequest = object.getRequests().get(0);
-        assertEquals(HttpMethod.GET, retrieveRequest.getMethod());
-
-        if (retrieveRequest.getHeaders(HttpHeader.ACCEPT_LANGUAGE) != null) {
-          assertEquals(3, retrieveRequest.getHeaders(HttpHeader.ACCEPT_LANGUAGE).size());
-        }
-
-        assertEquals(SERVICE_ROOT, retrieveRequest.getRawBaseUri());
-        assertEquals("/Employees('2')/EmployeeName", retrieveRequest.getRawODataPath());
-        assertEquals("http://localhost/odata/Employees('2')/EmployeeName?$format=json", retrieveRequest
-            .getRawRequestUri());
-        assertEquals("$format=json", retrieveRequest.getRawQueryPath());
-      } else {
-        List<ODataRequest> requests = object.getRequests();
-        for (ODataRequest request : requests) {
-
-          assertEquals(HttpMethod.PUT, request.getMethod());
-          assertEquals("100000", request.getHeader(HttpHeader.CONTENT_LENGTH));
-          assertEquals("application/json;odata=verbose", request.getHeader(HttpHeader.CONTENT_TYPE));
-
-          List<String> acceptHeader = request.getHeaders(HttpHeader.ACCEPT);
-          assertEquals(3, request.getHeaders(HttpHeader.ACCEPT).size());
-          assertEquals("application/atomsvc+xml;q=0.8", acceptHeader.get(0));
-          assertEquals("*/*;q=0.1", acceptHeader.get(2));
-
-          assertEquals("http://localhost/odata/Employees('2')/EmployeeName", request.getRawRequestUri());
-          assertEquals("http://localhost/odata", request.getRawBaseUri());
-          assertEquals("/Employees('2')/EmployeeName", request.getRawODataPath());
-          assertEquals("", request.getRawQueryPath()); // No query parameter
-        }
-      }
-    }
-  }
-
-  @Test
-  public void testImageInContent() throws IOException, BatchException, URISyntaxException {
-    final InputStream contentInputStream = readFile("/batchWithContent.batch");
-    final String content = StringUtil.toString(contentInputStream);
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees?$filter=Age%20gt%2040 HTTP/1.1" + CRLF
-        + "Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1" + CRLF
-        + "MaxDataServiceVersion: 2.0" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + "content-type:     Application/http" + CRLF
-        + "content-transfer-encoding: Binary" + CRLF
-        + "Content-ID: 1" + CRLF
-        + CRLF
-        + "POST Employees HTTP/1.1" + CRLF
-        + "Content-length: 100000" + CRLF
-        + "Content-type: application/octet-stream" + CRLF
-        + CRLF
-        + content
-        + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + "--batch_8194-cf13-1f56--";
-    final List<BatchRequestPart> BatchRequestParts = parse(batch);
-
-    for (BatchRequestPart part : BatchRequestParts) {
-      if (!part.isChangeSet()) {
-        assertEquals(1, part.getRequests().size());
-        final ODataRequest retrieveRequest = part.getRequests().get(0);
-
-        assertEquals(HttpMethod.GET, retrieveRequest.getMethod());
-        assertEquals("http://localhost/odata/Employees?$filter=Age%20gt%2040", retrieveRequest.getRawRequestUri());
-        assertEquals("http://localhost/odata", retrieveRequest.getRawBaseUri());
-        assertEquals("/Employees", retrieveRequest.getRawODataPath());
-        assertEquals("$filter=Age%20gt%2040", retrieveRequest.getRawQueryPath());
-      } else {
-        final List<ODataRequest> requests = part.getRequests();
-        for (ODataRequest request : requests) {
-          assertEquals(HttpMethod.POST, request.getMethod());
-          assertEquals("100000", request.getHeader(HttpHeader.CONTENT_LENGTH));
-          assertEquals("1", request.getHeader(BatchParserCommon.HTTP_CONTENT_ID));
-          assertEquals("application/octet-stream", request.getHeader(HttpHeader.CONTENT_TYPE));
-
-          final InputStream body = request.getBody();
-          assertEquals(content, StringUtil.toString(body));
-        }
-      }
-    }
-  }
-
-  @Test
-  public void testPostWithoutBody() throws IOException, BatchException, URISyntaxException {
-    final String batch = CRLF
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: changeRequest1" + CRLF
-        + CRLF
-        + "POST Employees('2') HTTP/1.1" + CRLF
-        + "Content-Length: 100" + CRLF
-        + "Content-Type: application/octet-stream" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-    final List<BatchRequestPart> batchRequestParts = parse(batch);
-
-    for (BatchRequestPart object : batchRequestParts) {
-      if (object.isChangeSet()) {
-        final List<ODataRequest> requests = object.getRequests();
-
-        for (ODataRequest request : requests) {
-          assertEquals(HttpMethod.POST, request.getMethod());
-          assertEquals("100", request.getHeader(HttpHeader.CONTENT_LENGTH));
-          assertEquals("application/octet-stream", request.getHeader(HttpHeader.CONTENT_TYPE));
-          assertNotNull(request.getBody());
-        }
-      }
-    }
-  }
-
-  @Test
-  public void testBoundaryParameterWithQuotas() throws BatchException, UnsupportedEncodingException {
-    final String contentType = "multipart/mixed; boundary=\"batch_1.2+34:2j)0?\"";
-    final String batch = ""
-        + "--batch_1.2+34:2j)0?" + CRLF
-        + GET_REQUEST
-        + "--batch_1.2+34:2j)0?--";
-    final BatchParser parser = new BatchParser();
-    final List<BatchRequestPart> batchRequestParts =
-        parser.parseBatchRequest(StringUtil.toInputStream(batch), contentType, SERVICE_ROOT, "", true);
-
-    assertNotNull(batchRequestParts);
-    assertFalse(batchRequestParts.isEmpty());
-  }
-
-  @Test
-  public void testBatchWithInvalidContentType() throws UnsupportedEncodingException {
-    final String invalidContentType = "multipart;boundary=batch_1740-bb84-2f7f";
-    final String batch = ""
-        + "--batch_1740-bb84-2f7f" + CRLF
-        + GET_REQUEST
-        + "--batch_1740-bb84-2f7f--";
-    final BatchParser parser = new BatchParser();
-
-    try {
-      parser.parseBatchRequest(StringUtil.toInputStream(batch), invalidContentType, SERVICE_ROOT, "", true);
-      fail();
-    } catch (BatchException e) {
-      assertMessageKey(e, BatchException.MessageKeys.INVALID_CONTENT_TYPE);
-    }
-  }
-
-  @Test
-  public void testContentTypeCharset() throws BatchException {
-    final String contentType = "multipart/mixed; charset=UTF-8;boundary=batch_14d1-b293-b99a";
-    final String batch = ""
-        + "--batch_14d1-b293-b99a" + CRLF
-        + GET_REQUEST
-        + "--batch_14d1-b293-b99a--";
-    final BatchParser parser = new BatchParser();
-    final List<BatchRequestPart> parts =
-        parser.parseBatchRequest(StringUtil.toInputStream(batch), contentType, SERVICE_ROOT, "", true);
-
-    assertEquals(1, parts.size());
-  }
-
-  @Test
-  public void testBatchWithoutBoundaryParameter() throws UnsupportedEncodingException {
-    final String invalidContentType = "multipart/mixed";
-    final String batch = ""
-        + "--batch_1740-bb84-2f7f" + CRLF
-        + GET_REQUEST
-        + "--batch_1740-bb84-2f7f--";
-    final BatchParser parser = new BatchParser();
-
-    try {
-      parser.parseBatchRequest(StringUtil.toInputStream(batch), invalidContentType, SERVICE_ROOT, "", true);
-      fail();
-    } catch (BatchException e) {
-      assertMessageKey(e, BatchException.MessageKeys.INVALID_CONTENT_TYPE);
-    }
-  }
-
-  @Test
-  public void testBoundaryParameterWithoutQuota() throws UnsupportedEncodingException {
-    final String invalidContentType = "multipart/mixed;boundary=batch_1740-bb:84-2f7f";
-    final String batch = ""
-        + "--batch_1740-bb:84-2f7f" + CRLF
-        + GET_REQUEST
-        + "--batch_1740-bb:84-2f7f--";
-    final BatchParser parser = new BatchParser();
-
-    try {
-      parser.parseBatchRequest(StringUtil.toInputStream(batch), invalidContentType, SERVICE_ROOT, "", true);
-      fail();
-    } catch (BatchException e) {
-      assertMessageKey(e, BatchException.MessageKeys.INVALID_BOUNDARY);
-    }
-  }
-
-  @Test
-  public void testWrongBoundaryString() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f5" + CRLF
-        + GET_REQUEST
-        + "--batch_8194-cf13-1f56--";
-
-    final List<BatchRequestPart> parts = parse(batch);
-    assertEquals(0, parts.size());
-  }
-
-  @Test
-  public void testMissingHttpVersion() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding:binary" + CRLF
-        + CRLF
-        + "GET Employees?$format=json" + CRLF
-        + "Host: localhost:8080" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_STATUS_LINE);
-  }
-
-  @Test
-  public void testMissingHttpVersion2() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding:binary" + CRLF
-        + CRLF
-        + "GET Employees?$format=json " + CRLF
-        + "Host: localhost:8080" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_HTTP_VERSION);
-  }
-
-  @Test
-  public void testMissingHttpVersion3() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding:binary" + CRLF
-        + CRLF
-        + "GET Employees?$format=json SMTP:3.1" + CRLF
-        + "Host: localhost:8080" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_HTTP_VERSION);
-  }
-
-  @Test
-  public void testBoundaryWithoutHyphen() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + GET_REQUEST
-        + "batch_8194-cf13-1f56" + CRLF
-        + GET_REQUEST
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_CONTENT);
-  }
-
-  @Test
-  public void testNoBoundaryString() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + GET_REQUEST
-        // + no boundary string
-        + GET_REQUEST
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_CONTENT);
-  }
-
-  @Test
-  public void testBatchBoundaryEqualsChangeSetBoundary() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed;boundary=batch_8194-cf13-1f56" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "PUT Employees('2')/EmployeeName HTTP/1.1" + CRLF
-        + "Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "MaxDataServiceVersion: 2.0" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Frederic Fall MODIFIED\"}" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--"
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.MISSING_BLANK_LINE);
-  }
-
-  @Test
-  public void testNoContentType() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.MISSING_CONTENT_TYPE);
-  }
-
-  @Test
-  public void testMimeHeaderContentType() throws UnsupportedEncodingException {
-    final String batch = "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: text/plain" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_CONTENT_TYPE);
-  }
-
-  @Test
-  public void testMimeHeaderEncoding() throws UnsupportedEncodingException {
-    String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: 8bit" + CRLF
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_CONTENT_TRANSFER_ENCODING);
-  }
-
-  @Test
-  public void testGetRequestMissingCRLF() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: 1" + CRLF
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        // + CRLF // Belongs to the GET request
-        + CRLF // Belongs to the
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.MISSING_BLANK_LINE);
-  }
-
-  @Test
-  public void testInvalidMethodForBatch() throws UnsupportedEncodingException {
-    final String batch = "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "POST Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_QUERY_OPERATION_METHOD);
-  }
-
-  @Test
-  public void testNoBoundaryFound() throws UnsupportedEncodingException {
-    final String batch = "batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "POST Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + CRLF;
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.MISSING_CLOSE_DELIMITER);
-  }
-
-  @Test
-  public void testEmptyRequest() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56--";
-
-    final List<BatchRequestPart> parts = parse(batch);
-    assertEquals(0, parts.size());
-  }
-
-  @Test
-  public void testBadRequest() throws UnsupportedEncodingException {
-    final String batch = "This is a bad request. There is no syntax and also no semantic";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.MISSING_CLOSE_DELIMITER);
-  }
-
-  @Test
-  public void testNoMethod() throws UnsupportedEncodingException {
-    final String batch = "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + /* GET */"Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_STATUS_LINE);
-  }
-
-  @Test
-  public void testInvalidMethodForChangeset() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "GET Employees('2')/EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "MaxDataServiceVersion: 2.0" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd--"
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_CHANGESET_METHOD);
-  }
-
-  @Test
-  public void testInvalidChangeSetBoundary() throws UnsupportedEncodingException, BatchException {
-    final String batch = "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed;boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94d"/* +"d" */+ CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "POST Employees('2') HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "MaxDataServiceVersion: 2.0" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    final List<BatchRequestPart> parts = parse(batch);
-    assertEquals(1, parts.size());
-
-    final BatchRequestPart part = parts.get(0);
-    assertTrue(part.isChangeSet());
-    assertEquals(0, part.getRequests().size());
-  }
-
-  @Test
-  public void testNestedChangeset() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed;boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Type: multipart/mixed;boundary=changeset_f980-1cb6-94dd2" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd2" + CRLF
-        + MIME_HEADERS
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "POST Employees('2') HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "MaxDataServiceVersion: 2.0" + CRLF
-        + "Content-Id: 2"
-        + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_CONTENT_TYPE);
-  }
-
-  @Test
-  public void testMissingContentTransferEncoding() throws UnsupportedEncodingException {
-    final String batch = "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed;boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + "Content-Id: 1" + CRLF
-        + "Content-Type: application/http" + CRLF
-        // + "Content-Transfer-Encoding: binary" + CRLF
-        + CRLF
-        + "POST Employees('2') HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "MaxDataServiceVersion: 2.0" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.MISSING_CONTENT_TRANSFER_ENCODING);
-  }
-
-  @Test
-  public void testMissingContentType() throws UnsupportedEncodingException {
-    final String batch = "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed;boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + "Content-Id: 1"
-        // + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + CRLF
-        + "POST Employees('2') HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "MaxDataServiceVersion: 2.0" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.MISSING_CONTENT_TYPE);
-  }
-
-  @Test
-  public void testNoCloseDelimiter() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + GET_REQUEST;
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.MISSING_CLOSE_DELIMITER);
-  }
-
-  @Test
-  public void testNoCloseDelimiter2() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF;
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.MISSING_CLOSE_DELIMITER);
-  }
-
-  @Test
-  public void testInvalidUri() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET http://localhost/aa/odata/Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_URI);
-  }
-
-  @Test
-  public void testUriWithAbsolutePath() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET /odata/Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + "Host: http://localhost" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    final List<BatchRequestPart> parts = parse(batch);
-    assertEquals(1, parts.size());
-
-    final BatchRequestPart part = parts.get(0);
-    assertEquals(1, part.getRequests().size());
-    final ODataRequest request = part.getRequests().get(0);
-
-    assertEquals("http://localhost/odata/Employees('1')/EmployeeName", request.getRawRequestUri());
-    assertEquals("http://localhost/odata", request.getRawBaseUri());
-    assertEquals("/Employees('1')/EmployeeName", request.getRawODataPath());
-    assertEquals("", request.getRawQueryPath());
-  }
-
-  @Test
-  public void testUriWithAbsolutePathMissingHostHeader() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET /odata/Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, MessageKeys.MISSING_MANDATORY_HEADER);
-  }
-
-  @Test
-  public void testUriWithAbsolutePathMissingHostDulpicatedHeader() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET /odata/Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + "Host: http://localhost" + CRLF
-        + "Host: http://localhost/odata" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, MessageKeys.MISSING_MANDATORY_HEADER);
-  }
-
-  @Test
-  public void testUriWithAbsolutePathOtherHost() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET /odata/Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + "Host: http://localhost2" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, MessageKeys.INVALID_URI);
-  }
-
-  @Test
-  public void testUriWithAbsolutePathWrongPath() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET /myservice/Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + "Host: http://localhost" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, MessageKeys.INVALID_URI);
-  }
-
-  @Test
-  public void testNoCloseDelimiter3() throws UnsupportedEncodingException {
-    final String batch = "--batch_8194-cf13-1f56" + CRLF + GET_REQUEST + "--batch_8194-cf13-1f56-"/* no hyphen */;
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.MISSING_CLOSE_DELIMITER);
-  }
-
-  @Test
-  public void testNegativeContentLengthChangeSet() throws BatchException, IOException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: 1" + CRLF
-        + "Content-Length: -2" + CRLF
-        + CRLF
-        + "PUT EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parse(batch);
-  }
-
-  @Test
-  public void testNegativeContentLengthRequest() throws BatchException, IOException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: 1" + CRLF
-        + CRLF
-        + "PUT EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "Content-Id: 1" + CRLF
-        + "Content-Length: 2" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parse(batch);
-  }
-
-  @Test
-  public void testContentLengthGreatherThanBodyLength() throws BatchException, IOException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: 1" + CRLF
-        + CRLF
-        + "PUT Employee/Name HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "Content-Length: 100000" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-    final List<BatchRequestPart> batchRequestParts = parse(batch);
-
-    assertNotNull(batchRequestParts);
-
-    for (BatchRequestPart multipart : batchRequestParts) {
-      if (multipart.isChangeSet()) {
-        assertEquals(1, multipart.getRequests().size());
-
-        final ODataRequest request = multipart.getRequests().get(0);
-        assertEquals("{\"EmployeeName\":\"Peter Fall\"}", StringUtil.toString(request.getBody()));
-      }
-    }
-  }
-
-  @Test
-  public void testContentLengthSmallerThanBodyLength() throws BatchException, IOException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: 1" + CRLF
-        + CRLF
-        + "PUT EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "Content-Length: 10" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-    final List<BatchRequestPart> batchRequestParts = parse(batch);
-
-    assertNotNull(batchRequestParts);
-
-    for (BatchRequestPart multipart : batchRequestParts) {
-      if (multipart.isChangeSet()) {
-        assertEquals(1, multipart.getRequests().size());
-
-        final ODataRequest request = multipart.getRequests().get(0);
-        assertEquals("{\"Employee", StringUtil.toString(request.getBody()));
-      }
-    }
-  }
-
-  @Test
-  public void testNonNumericContentLength() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: 1" + CRLF
-        + CRLF
-        + "PUT EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "Content-Length: 10abc" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_HEADER);
-  }
-
-  @Test
-  public void testNonStrictParser() throws BatchException, IOException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed;boundary=changeset_8194-cf13-1f56" + CRLF
-        + "--changeset_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: myRequest" + CRLF
-        + "PUT Employees('2')/EmployeeName HTTP/1.1" + CRLF
-        + "Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "MaxDataServiceVersion: 2.0" + CRLF
-        + "{\"EmployeeName\":\"Frederic Fall MODIFIED\"}" + CRLF
-        + "--changeset_8194-cf13-1f56--" + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    final List<BatchRequestPart> requests = parse(batch, false);
-
-    assertNotNull(requests);
-    assertEquals(1, requests.size());
-
-    final BatchRequestPart part = requests.get(0);
-    assertTrue(part.isChangeSet());
-    assertNotNull(part.getRequests());
-    assertEquals(1, part.getRequests().size());
-
-    final ODataRequest changeRequest = part.getRequests().get(0);
-    assertEquals("{\"EmployeeName\":\"Frederic Fall MODIFIED\"}",
-        StringUtil.toString(changeRequest.getBody()));
-    assertEquals("application/json;odata=verbose", changeRequest.getHeader(HttpHeader.CONTENT_TYPE));
-    assertEquals(HttpMethod.PUT, changeRequest.getMethod());
-  }
-
-  @Test
-  public void testNonStrictParserMoreCRLF() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed;boundary=changeset_8194-cf13-1f56" + CRLF
-        + "--changeset_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + CRLF // Only one CRLF allowed
-        + "PUT Employees('2')/EmployeeName HTTP/1.1" + CRLF
-        + "Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "MaxDataServiceVersion: 2.0" + CRLF
-        + "{\"EmployeeName\":\"Frederic Fall MODIFIED\"}" + CRLF
-        + "--changeset_8194-cf13-1f56--" + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, BatchException.MessageKeys.INVALID_STATUS_LINE, false);
-  }
-
-  @Test
-  public void testContentId() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees HTTP/1.1" + CRLF
-        + "accept: */*,application/atom+xml,application/atomsvc+xml,application/xml" + CRLF
-        + "Content-Id: BBB" + CRLF
-        + CRLF + CRLF
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "POST Employees HTTP/1.1" + CRLF
-        + "Content-type: application/octet-stream" + CRLF
-        + CRLF
-        + "/9j/4AAQSkZJRgABAQEBLAEsAAD/4RM0RXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAA" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "PUT $1/EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + "Content-Id: 2" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    final List<BatchRequestPart> batchRequestParts = parse(batch);
-    assertNotNull(batchRequestParts);
-
-    for (BatchRequestPart multipart : batchRequestParts) {
-      if (!multipart.isChangeSet()) {
-        assertEquals(1, multipart.getRequests().size());
-        final ODataRequest retrieveRequest = multipart.getRequests().get(0);
-
-        assertEquals("BBB", retrieveRequest.getHeader(BatchParserCommon.HTTP_CONTENT_ID));
-      } else {
-        for (ODataRequest request : multipart.getRequests()) {
-          if (HttpMethod.POST.equals(request.getMethod())) {
-            assertEquals("1", request.getHeader(BatchParserCommon.HTTP_CONTENT_ID));
-          } else if (HttpMethod.PUT.equals(request.getMethod())) {
-            assertEquals("2", request.getHeader(BatchParserCommon.HTTP_CONTENT_ID));
-            assertEquals("/$1/EmployeeName", request.getRawODataPath());
-            assertEquals("http://localhost/odata/$1/EmployeeName", request.getRawRequestUri());
-          }
-        }
-      }
-    }
-  }
-
-  @Test
-  public void testNoContentId() throws BatchException, UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees HTTP/1.1" + CRLF
-        + "accept: */*,application/atom+xml,application/atomsvc+xml,application/xml" + CRLF
-        + CRLF + CRLF
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "POST Employees HTTP/1.1" + CRLF
-        + "Content-type: application/octet-stream" + CRLF
-        + CRLF
-        + "/9j/4AAQSkZJRgABAQEBLAEsAAD/4RM0RXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAA" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "PUT $1/EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parse(batch);
-  }
-
-  @Test
-  public void testPreamble() throws BatchException, IOException {
-    final String batch = ""
-        + "This is a preamble and must be ignored" + CRLF
-        + CRLF
-        + CRLF
-        + "----1242" + CRLF
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees HTTP/1.1" + CRLF
-        + "accept: */*,application/atom+xml,application/atomsvc+xml,application/xml" + CRLF
-        + "Content-Id: BBB" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "This is a preamble and must be ignored" + CRLF
-        + CRLF
-        + CRLF
-        + "----1242" + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "POST Employees HTTP/1.1" + CRLF
-        + "Content-type: application/octet-stream" + CRLF
-        + CRLF
-        + "/9j/4AAQSkZJRgABAQEBLAEsAAD/4RM0RXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAA" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: 2" + CRLF
-        + CRLF
-        + "PUT $1/EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-    final List<BatchRequestPart> batchRequestParts = parse(batch);
-
-    assertNotNull(batchRequestParts);
-    assertEquals(2, batchRequestParts.size());
-
-    final BatchRequestPart getRequestPart = batchRequestParts.get(0);
-    assertEquals(1, getRequestPart.getRequests().size());
-
-    final ODataRequest getRequest = getRequestPart.getRequests().get(0);
-    assertEquals(HttpMethod.GET, getRequest.getMethod());
-
-    final BatchRequestPart changeSetPart = batchRequestParts.get(1);
-    assertEquals(2, changeSetPart.getRequests().size());
-    assertEquals("/9j/4AAQSkZJRgABAQEBLAEsAAD/4RM0RXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAA"
-        + CRLF,
-        StringUtil.toString(changeSetPart.getRequests().get(0).getBody()));
-    assertEquals("{\"EmployeeName\":\"Peter Fall\"}",
-        StringUtil.toString(changeSetPart.getRequests().get(1).getBody()));
-  }
-
-  @Test
-  public void testContentTypeCaseInsensitive() throws BatchException, IOException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: muLTiParT/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: 1" + CRLF
-        + "Content-Length: 200" + CRLF
-        + CRLF
-        + "PUT EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parse(batch);
-  }
-
-  @Test
-  public void testContentTypeBoundaryCaseInsensitive() throws BatchException, IOException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; bOunDaRy=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: 1" + CRLF
-        + CRLF
-        + "PUT EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-    final List<BatchRequestPart> batchRequestParts = parse(batch);
-
-    assertNotNull(batchRequestParts);
-    assertEquals(1, batchRequestParts.size());
-    assertTrue(batchRequestParts.get(0).isChangeSet());
-    assertEquals(1, batchRequestParts.get(0).getRequests().size());
-  }
-
-  @Test
-  public void testEpilog() throws BatchException, IOException {
-    String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees HTTP/1.1" + CRLF
-        + "accept: */*,application/atom+xml,application/atomsvc+xml,application/xml" + CRLF
-        + "Content-Id: BBB" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "POST Employees HTTP/1.1" + CRLF
-        + "Content-type: application/octet-stream" + CRLF
-        + CRLF
-        + "/9j/4AAQSkZJRgABAQEBLAEsAAD/4RM0RXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAA" + CRLF
-        + CRLF
-        + "--changeset_f980-1cb6-94dd" + CRLF
-        + MIME_HEADERS
-        + "Content-ID: 2" + CRLF
-        + CRLF
-        + "PUT $1/EmployeeName HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + "{\"EmployeeName\":\"Peter Fall\"}" + CRLF
-        + "--changeset_f980-1cb6-94dd--" + CRLF
-        + CRLF
-        + "This is an epilog and must be ignored" + CRLF
-        + CRLF
-        + CRLF
-        + "----1242"
-        + CRLF
-        + "--batch_8194-cf13-1f56--"
-        + CRLF
-        + "This is an epilog and must be ignored" + CRLF
-        + CRLF
-        + CRLF
-        + "----1242";
-    final List<BatchRequestPart> batchRequestParts = parse(batch);
-
-    assertNotNull(batchRequestParts);
-    assertEquals(2, batchRequestParts.size());
-
-    BatchRequestPart getRequestPart = batchRequestParts.get(0);
-    assertEquals(1, getRequestPart.getRequests().size());
-    ODataRequest getRequest = getRequestPart.getRequests().get(0);
-    assertEquals(HttpMethod.GET, getRequest.getMethod());
-
-    BatchRequestPart changeSetPart = batchRequestParts.get(1);
-    assertEquals(2, changeSetPart.getRequests().size());
-    assertEquals("/9j/4AAQSkZJRgABAQEBLAEsAAD/4RM0RXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAA"
-        + CRLF,
-        StringUtil.toString(changeSetPart.getRequests().get(0).getBody()));
-    assertEquals("{\"EmployeeName\":\"Peter Fall\"}",
-        StringUtil.toString(changeSetPart.getRequests().get(1).getBody()));
-  }
-
-  @Test
-  public void testLargeBatch() throws BatchException, IOException {
-    final InputStream in = readFile("/batchLarge.batch");
-    parse(in);
-  }
-
-  @Test
-  public void testForddenHeaderAuthorisation() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + "Authorization: Basic QWxhZdsdsddsduIHNlc2FtZQ==" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, MessageKeys.FORBIDDEN_HEADER);
-  }
-
-  @Test
-  public void testForddenHeaderExpect() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + "Expect: 100-continue" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, MessageKeys.FORBIDDEN_HEADER);
-  }
-
-  @Test
-  public void testForddenHeaderFrom() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + "From: test@test.com" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, MessageKeys.FORBIDDEN_HEADER);
-  }
-
-  @Test
-  public void testForddenHeaderRange() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + "Range: 200-256" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, MessageKeys.FORBIDDEN_HEADER);
-  }
-
-  @Test
-  public void testForddenHeaderMaxForwards() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + "Max-Forwards: 3" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, MessageKeys.FORBIDDEN_HEADER);
-  }
-
-  @Test
-  public void testForddenHeaderTE() throws UnsupportedEncodingException {
-    final String batch = ""
-        + "--batch_8194-cf13-1f56" + CRLF
-        + MIME_HEADERS
-        + CRLF
-        + "GET Employees('1')/EmployeeName HTTP/1.1" + CRLF
-        + "TE: deflate" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_8194-cf13-1f56--";
-
-    parseInvalidBatchBody(batch, MessageKeys.FORBIDDEN_HEADER);
-  }
-
-  private List<BatchRequestPart> parse(final InputStream in, final boolean isStrict) throws BatchException {
-    final BatchParser parser = new BatchParser();
-    final List<BatchRequestPart> batchRequestParts =
-        parser.parseBatchRequest(in, CONTENT_TYPE, SERVICE_ROOT, "", isStrict);
-
-    assertNotNull(batchRequestParts);
-
-    return batchRequestParts;
-  }
-
-  private List<BatchRequestPart> parse(final InputStream in) throws BatchException {
-    return parse(in, true);
-  }
-
-  private List<BatchRequestPart> parse(final String batch) throws BatchException, UnsupportedEncodingException {
-    return parse(batch, true);
-  }
-
-  private List<BatchRequestPart> parse(final String batch, final boolean isStrict) throws BatchException,
-      UnsupportedEncodingException {
-    return parse(StringUtil.toInputStream(batch), isStrict);
-  }
-
-  private void parseInvalidBatchBody(final String batch, final MessageKeys key, final boolean isStrict)
-      throws UnsupportedEncodingException {
-    final BatchParser parser = new BatchParser();
-
-    try {
-      parser.parseBatchRequest(StringUtil.toInputStream(batch), CONTENT_TYPE, SERVICE_ROOT, "", isStrict);
-      fail("No exception thrown. Expect: " + key.toString());
-    } catch (BatchException e) {
-      assertMessageKey(e, key);
-    }
-  }
-
-  private void parseInvalidBatchBody(final String batch, final MessageKeys key) throws UnsupportedEncodingException {
-    parseInvalidBatchBody(batch, key, true);
-  }
-
-  private void assertMessageKey(final BatchException e, final MessageKeys key) {
-    assertEquals(key, e.getMessageKey());
-  }
-
-  private InputStream readFile(final String fileName) throws IOException {
-    final InputStream in = ClassLoader.class.getResourceAsStream(fileName);
-    if (in == null) {
-      throw new IOException("Requested file '" + fileName + "' was not found.");
-    }
-    return in;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/51acf8ae/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/StringUtil.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/StringUtil.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/StringUtil.java
deleted file mode 100644
index 2602852..0000000
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/StringUtil.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-package org.apache.olingo.server.core.batch;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.server.core.batch.parser.BufferedReaderIncludingLineEndings;
-
-public class StringUtil {
-  
-  
-  public static String toString(final InputStream in) throws IOException {
-    final StringBuilder builder = new StringBuilder();
-    final BufferedReaderIncludingLineEndings reader = new BufferedReaderIncludingLineEndings(new InputStreamReader(in));
-    String currentLine;
-    
-    while((currentLine = reader.readLine()) != null) {
-      builder.append(currentLine);
-    }
-    
-    reader.close();
-    
-    return builder.toString();
-  }
-
-  public static InputStream toInputStream(final String string) {
-    try {
-      return new ByteArrayInputStream(string.getBytes("UTF-8"));
-    } catch (UnsupportedEncodingException e) {
-      throw new ODataRuntimeException("Charset UTF-8 not found");
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/51acf8ae/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/handler/BatchChangeSetSorterTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/handler/BatchChangeSetSorterTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/handler/BatchChangeSetSorterTest.java
deleted file mode 100644
index c8b725a..0000000
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/handler/BatchChangeSetSorterTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-package org.apache.olingo.server.core.batch.handler;
-
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.batch.BatchException;
-import org.apache.olingo.server.core.batch.parser.BatchParserCommon;
-import org.junit.Test;
-
-public class BatchChangeSetSorterTest {
-
-  private static final String BASE_URI = "http://localhost/odata.src";
-  
-  @Test
-  public void test() throws BatchException {
-    final List<ODataRequest> changeSet = new ArrayList<ODataRequest>();
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "$1/Adress", "2"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "/Employees", "1"));
-    
-   BatchChangeSetSorter sorter = new BatchChangeSetSorter(changeSet);
-   final List<ODataRequest> sortedChangeSet = sorter.getOrderdRequests();
-   
-   assertEquals(2, sortedChangeSet.size());
-   assertEquals("1", getContentId(sortedChangeSet.get(0)));
-   assertEquals("2", getContentId(sortedChangeSet.get(1)));
-  }
-  
-  private String getContentId(ODataRequest request) {
-    return request.getHeader(BatchParserCommon.HTTP_CONTENT_ID);
-  }
-  
-  @Test
-  public void testNoContentId() throws BatchException {
-    final List<ODataRequest> changeSet = new ArrayList<ODataRequest>();
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "$1/Department", "2"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "Employees", "1"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "Employee('2')/Address"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "Employee('3')/Address"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "$2/Manager", "3"));
-    
-    BatchChangeSetSorter sorter = new BatchChangeSetSorter(changeSet);
-   final List<ODataRequest> sortedChangeSet = sorter.getOrderdRequests();
-   
-   assertEquals(5, sortedChangeSet.size());
-   assertEquals("1", getContentId(sortedChangeSet.get(0)));
-   assertEquals(null, getContentId(sortedChangeSet.get(1)));
-   assertEquals(null, getContentId(sortedChangeSet.get(2)));
-   assertEquals("2", getContentId(sortedChangeSet.get(3)));
-   assertEquals("3", getContentId(sortedChangeSet.get(4)));
-  }
-  
-  @SuppressWarnings("unused")
-  @Test(expected=BatchException.class)
-  public void testContentIdNotAvailable() throws BatchException {
-    final List<ODataRequest> changeSet = new ArrayList<ODataRequest>();
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "$1/Department", "2"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "Employees", "1"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "Employee('2')/Address"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "Employee('3')/Address"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "$4/Manager", "3")); //4 is not available
-    
-   BatchChangeSetSorter sorter = new BatchChangeSetSorter(changeSet);
-   final List<ODataRequest> sortedChangeSet = sorter.getOrderdRequests();
-  }
-  
-  @Test
-  public void testStringAsContentId() throws BatchException {
-    final List<ODataRequest> changeSet = new ArrayList<ODataRequest>();
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "$One/Department", "Two"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "Employees", "One"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "Employee('2')/Address"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "Employee('3')/Address"));
-    changeSet.add(createRequest(HttpMethod.POST, BASE_URI, "$Two/Manager", "Three"));
-    
-   BatchChangeSetSorter sorter = new BatchChangeSetSorter(changeSet);
-   final List<ODataRequest> sortedChangeSet = sorter.getOrderdRequests();
-   
-   assertEquals(5, sortedChangeSet.size());
-   assertEquals("One", getContentId(sortedChangeSet.get(0)));
-   assertEquals(null, getContentId(sortedChangeSet.get(1)));
-   assertEquals(null, getContentId(sortedChangeSet.get(2)));
-   assertEquals("Two", getContentId(sortedChangeSet.get(3)));
-   assertEquals("Three", getContentId(sortedChangeSet.get(4)));
-  }
-  
-  @Test
-  public void testRewriting() {
-    final String CONTENT_ID = "1";
-    final String ODATA_PATH ="/$" + CONTENT_ID + "/Address";
-    final String RESOURCE_URI = "Employee('1')";
-    final ODataRequest request = createRequest(HttpMethod.POST, BASE_URI, ODATA_PATH);
-    
-    BatchChangeSetSorter.replaceContentIdReference(request, CONTENT_ID, RESOURCE_URI);
-    assertEquals(BASE_URI + "/" + "Employee('1')/Address", request.getRawRequestUri());
-    assertEquals("Employee('1')/Address", request.getRawODataPath());
-  }
-  
-  @Test
-  public void testRewritingNoContentId() {
-    final String CONTENT_ID = "1";
-    final String ODATA_PATH = /* "$" + CONTENT_ID + */ "Address";
-    final String RESOURCE_URI = "Employee('1')";
-    final ODataRequest request = createRequest(HttpMethod.POST, BASE_URI, ODATA_PATH);
-    
-    BatchChangeSetSorter.replaceContentIdReference(request, CONTENT_ID, RESOURCE_URI);
-    assertEquals(BASE_URI + "/" + "Address", request.getRawRequestUri());
-    assertEquals("Address", request.getRawODataPath());
-  }
-  
-  @Test
-  public void testWrongRewriting() {
-    final String CONTENT_ID = "1";
-    final String ODATA_PATH = /*"$1" */ "$2" + "/Address";
-    final String RESOURCE_URI = "Employee('1')";
-    final ODataRequest request = createRequest(HttpMethod.POST, BASE_URI, ODATA_PATH);
-    
-    BatchChangeSetSorter.replaceContentIdReference(request, CONTENT_ID, RESOURCE_URI);
-    assertEquals(BASE_URI + "/" + "$2/Address", request.getRawRequestUri());
-    assertEquals("$2/Address", request.getRawODataPath());
-  }
-  
-  private ODataRequest createRequest(HttpMethod method, String baseUrl, String oDataPath) {
-    return createRequest(method, baseUrl, oDataPath, null);
-  }
-  
-  private ODataRequest createRequest(HttpMethod method, String baseUrl, String oDataPath, String contentId) {
-    final ODataRequest request = new ODataRequest();
-    request.setBody(new ByteArrayInputStream(new byte[0]));
-    request.setMethod(HttpMethod.GET);
-    request.setRawBaseUri(baseUrl);
-    request.setRawODataPath(oDataPath);
-    request.setRawRequestUri(baseUrl + "/" + oDataPath);
-    request.setRawQueryPath("");
-    
-    if(contentId != null) {
-      request.addHeader(BatchParserCommon.HTTP_CONTENT_ID, Arrays.asList(new String[] { contentId }));
-    }
-    return request;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/51acf8ae/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/handler/MockedBatchHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/handler/MockedBatchHandlerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/handler/MockedBatchHandlerTest.java
deleted file mode 100644
index c68919c..0000000
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/batch/handler/MockedBatchHandlerTest.java
+++ /dev/null
@@ -1,664 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-package org.apache.olingo.server.core.batch.handler;
-
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.server.api.batch.BatchException;
-import org.apache.olingo.server.api.batch.BatchOperation;
-import org.apache.olingo.server.api.batch.BatchRequestPart;
-import org.apache.olingo.server.api.batch.ODataResponsePart;
-import org.apache.olingo.server.api.processor.BatchProcessor;
-import org.apache.olingo.server.core.ODataHandler;
-import org.apache.olingo.server.core.batch.parser.BatchParserCommon;
-import org.apache.olingo.server.core.batch.parser.BufferedReaderIncludingLineEndings;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class MockedBatchHandlerTest {
-
-  private static final String BATCH_CONTENT_TYPE = "multipart/mixed;boundary=batch_12345";
-  private static final String BATCH_ODATA_PATH = "/$batch";
-  private static final String BATCH_REQUEST_URI = "http://localhost:8080/odata/$batch";
-  private static final String BASE_URI = "http://localhost:8080/odata";
-  private static final String CRLF = "\r\n";
-  private ODataHandler oDataHandler;
-  private BatchHandler batchHandler;
-  private int entityCounter = 1;
-
-  @Before
-  public void setup() {
-    final BatchProcessor batchProcessor = new BatchTestProcessorImpl();
-
-    entityCounter = 1;
-    oDataHandler = mock(ODataHandler.class);
-    batchHandler = new BatchHandler(oDataHandler, batchProcessor);
-  }
-
-  @Test
-  public void test() throws BatchException, IOException {
-    final String content = "--batch_12345" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_12345" + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 4" + CRLF
-        + CRLF
-        + "PUT /$3/PropertyInt32 HTTP/1.1" + CRLF // Absolute URI with separate Host header and ref.
-        + "Host: http://localhost:8080/odata" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 5" + CRLF
-        + CRLF
-        + "POST http://localhost:8080/odata/$1/NavPropertyETTwoPrimMany HTTP/1.1" + CRLF // Absolute URI with ref.
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 2" + CRLF
-        + CRLF
-        + "POST $1/NavPropertyETTwoPrimMany HTTP/1.1" + CRLF // Relative URI with ref.
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "POST http://localhost:8080/odata/ESAllPrim HTTP/1.1" + CRLF // Absolute URI
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 3" + CRLF
-        + CRLF
-        + "PUT ESAllPrim(1) HTTP/1.1" + CRLF // Relative URI
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 6" + CRLF
-        + CRLF
-        + "PUT /ESAllPrim(1) HTTP/1.1" + CRLF // Absolute URI with separate Host header
-        + "Host: http://localhost:8080/odata"
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345--" + CRLF
-        + CRLF
-        + "--batch_12345--";
-    final Map<String, List<String>> header = getMimeHeader();
-    final ODataResponse response = new ODataResponse();
-    final ODataRequest request = buildODataRequest(content, header);
-
-    batchHandler.process(request, response, true);
-
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(new InputStreamReader(response.getContent()));
-
-    final List<String> responseContent = reader.toList();
-    reader.close();
-
-    int line = 0;
-    assertEquals(63, responseContent.size());
-
-    // Check change set
-    assertTrue(responseContent.get(line++).contains("--batch_"));
-    assertTrue(responseContent.get(line++).contains("Content-Type: multipart/mixed; boundary=changeset_"));
-
-    for (int i = 0; i < 6; i++) {
-      String contentId = checkChangeSetPartHeader(responseContent, line);
-      line += 6;
-
-      if ("1".equals(contentId)) {
-        assertEquals("HTTP/1.1 201 Created" + CRLF, responseContent.get(line++));
-        assertEquals("Location: " + BASE_URI + "/ESAllPrim(1)" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else if ("2".equals(contentId)) {
-        assertEquals("HTTP/1.1 201 Created" + CRLF, responseContent.get(line++));
-        assertEquals("Location: " + BASE_URI + "/ESTwoPrim(3)" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else if ("3".equals(contentId)) {
-        assertEquals("HTTP/1.1 200 OK" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else if ("4".equals(contentId)) {
-        assertEquals("HTTP/1.1 200 OK" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else if ("5".equals(contentId)) {
-        assertEquals("HTTP/1.1 201 Created" + CRLF, responseContent.get(line++));
-        assertEquals("Location: " + BASE_URI + "/ESTwoPrim(2)" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else if ("6".equals(contentId)) {
-        assertEquals("HTTP/1.1 200 OK" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else {
-        fail();
-      }
-
-      assertEquals(CRLF, responseContent.get(line++));
-    }
-
-    // Close body part (change set)
-    assertEquals(CRLF, responseContent.get(line++));
-    assertTrue(responseContent.get(line++).contains("--changeset_"));
-
-    // Close batch
-    assertEquals(CRLF, responseContent.get(line++));
-    assertTrue(responseContent.get(line++).contains("--batch_"));
-    assertEquals(63, line);
-  }
-
-  @Test
-  public void testGetRequest() throws BatchException, IOException {
-    final String content = ""
-        + "--batch_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + CRLF
-        + "GET ESAllPrim(0) HTTP/1.1" + CRLF
-        + CRLF
-        + CRLF
-        + "--batch_12345--";
-
-    final Map<String, List<String>> header = getMimeHeader();
-    final ODataResponse response = new ODataResponse();
-    final ODataRequest request = buildODataRequest(content, header);
-
-    batchHandler.process(request, response, true);
-
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(new InputStreamReader(response.getContent()));
-
-    final List<String> responseContent = reader.toList();
-    int line = 0;
-
-    assertEquals(9, responseContent.size());
-    assertTrue(responseContent.get(line++).contains("--batch_"));
-    assertEquals("Content-Type: application/http" + CRLF, responseContent.get(line++));
-    assertEquals("Content-Transfer-Encoding: binary" + CRLF, responseContent.get(line++));
-    assertEquals(CRLF, responseContent.get(line++));
-    assertEquals("HTTP/1.1 200 OK" + CRLF, responseContent.get(line++));
-    assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-    assertEquals(CRLF, responseContent.get(line++));
-    assertEquals(CRLF, responseContent.get(line++));
-    assertTrue(responseContent.get(line++).contains("--batch_"));
-
-    assertEquals(9, line);
-
-    reader.close();
-  }
-
-  @Test
-  public void testMultipleChangeSets() throws BatchException, IOException {
-    final String content = ""
-        + "--batch_12345" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_12345" + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 2" + CRLF
-        + CRLF
-        + "POST /$1/NavPropertyETTwoPrimMany HTTP/1.1" + CRLF
-        + "Host: http://localhost:8080/odata" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "PUT ESAllPrim(1) HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345--" + CRLF
-
-        + "--batch_12345" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_54321" + CRLF
-        + CRLF
-        + "--changeset_54321" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 2" + CRLF
-        + CRLF
-        + "POST /$1/NavPropertyETTwoPrimMany HTTP/1.1" + CRLF
-        + "Host: http://localhost:8080/odata" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_54321" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "PUT ESAllPrim(2) HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_54321--" + CRLF
-
-        + CRLF
-        + "--batch_12345--";
-    final Map<String, List<String>> header = getMimeHeader();
-    final ODataResponse response = new ODataResponse();
-    final ODataRequest request = buildODataRequest(content, header);
-
-    batchHandler.process(request, response, true);
-
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(new InputStreamReader(response.getContent()));
-
-    final List<String> responseContent = reader.toList();
-    reader.close();
-
-    int line = 0;
-    assertEquals(49, responseContent.size());
-
-    // Check first change set
-    assertTrue(responseContent.get(line++).contains("--batch_"));
-    assertTrue(responseContent.get(line++).contains("Content-Type: multipart/mixed; boundary=changeset_"));
-
-    for (int i = 0; i < 2; i++) {
-      String contentId = checkChangeSetPartHeader(responseContent, line);
-      line += 6;
-
-      if ("1".equals(contentId)) {
-        assertEquals("HTTP/1.1 200 OK" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else if ("2".equals(contentId)) {
-        assertEquals("HTTP/1.1 201 Created" + CRLF, responseContent.get(line++));
-        assertEquals("Location: " + BASE_URI + "/ESTwoPrim(1)" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else {
-        fail();
-      }
-
-      assertEquals(CRLF, responseContent.get(line++));
-    }
-    // Close body part (1st change set)
-    assertEquals(CRLF, responseContent.get(line++));
-    assertTrue(responseContent.get(line++).contains("--changeset_"));
-
-    // Check second change set
-    assertEquals(CRLF, responseContent.get(line++));
-    assertTrue(responseContent.get(line++).contains("--batch_"));
-    assertTrue(responseContent.get(line++).contains("Content-Type: multipart/mixed; boundary=changeset_"));
-
-    for (int i = 0; i < 2; i++) {
-      String contentId = checkChangeSetPartHeader(responseContent, line);
-      line += 6;
-
-      if ("1".equals(contentId)) {
-        assertEquals("HTTP/1.1 200 OK" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else if ("2".equals(contentId)) {
-        assertEquals("HTTP/1.1 201 Created" + CRLF, responseContent.get(line++));
-        assertEquals("Location: " + BASE_URI + "/ESTwoPrim(2)" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else {
-        fail();
-      }
-
-      assertEquals(CRLF, responseContent.get(line++));
-    }
-    // Close body part (2nd change set)
-    assertEquals(CRLF, responseContent.get(line++));
-    assertTrue(responseContent.get(line++).contains("--changeset_"));
-
-    // Close batch
-    assertEquals(CRLF, responseContent.get(line++));
-    assertTrue(responseContent.get(line++).contains("--batch_"));
-
-    assertEquals(49, line);
-  }
-
-  @Test
-  public void testMineBodyPartTransitiv() throws BatchException, IOException {
-    final String content = ""
-        + "--batch_12345" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_12345" + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 4" + CRLF
-        + CRLF
-        + "POST $3/NavPropertyETTwoPrimOne HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 2" + CRLF
-        + CRLF
-        + "POST /$1/NavPropertyETTwoPrimMany HTTP/1.1" + CRLF
-        + "Host: http://localhost:8080/odata" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "PUT ESAllPrim(1) HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 3" + CRLF
-        + CRLF
-        + "POST $2/NavPropertyETAllPrimMany HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345--" + CRLF
-
-        + CRLF
-        + "--batch_12345--";
-
-    final Map<String, List<String>> header = getMimeHeader();
-    final ODataResponse response = new ODataResponse();
-    final ODataRequest request = buildODataRequest(content, header);
-
-    batchHandler.process(request, response, true);
-
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(new InputStreamReader(response.getContent()));
-
-    final List<String> responseContent = reader.toList();
-    reader.close();
-
-    int line = 0;
-    assertEquals(45, responseContent.size());
-
-    // Check change set
-    assertTrue(responseContent.get(line++).contains("--batch_"));
-    assertTrue(responseContent.get(line++).contains("Content-Type: multipart/mixed; boundary=changeset_"));
-
-    for (int i = 0; i < 4; i++) {
-      String contentId = checkChangeSetPartHeader(responseContent, line);
-      line += 6;
-
-      if ("1".equals(contentId)) {
-        assertEquals("HTTP/1.1 200 OK" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else if ("2".equals(contentId)) {
-        assertEquals("HTTP/1.1 201 Created" + CRLF, responseContent.get(line++));
-        assertEquals("Location: " + BASE_URI + "/ESTwoPrim(1)" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else if ("3".equals(contentId)) {
-        assertEquals("HTTP/1.1 201 Created" + CRLF, responseContent.get(line++));
-        assertEquals("Location: " + BASE_URI + "/ESAllPrim(2)" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else if ("4".equals(contentId)) {
-        assertEquals("HTTP/1.1 201 Created" + CRLF, responseContent.get(line++));
-        assertEquals("Location: " + BASE_URI + "/ESTwoPrim(3)" + CRLF, responseContent.get(line++));
-        assertEquals("Content-Length: 0" + CRLF, responseContent.get(line++));
-      } else {
-        fail();
-      }
-
-      assertEquals(CRLF, responseContent.get(line++));
-    }
-
-    // Close body part (change set)
-    assertEquals(CRLF, responseContent.get(line++));
-    assertTrue(responseContent.get(line++).contains("--changeset_"));
-
-    // Close batch
-    assertEquals(CRLF, responseContent.get(line++));
-    assertTrue(responseContent.get(line++).contains("--batch_"));
-    assertEquals(45, line);
-  }
-
-  private String checkChangeSetPartHeader(final List<String> response, int line) {
-    assertEquals(CRLF, response.get(line++));
-    assertTrue(response.get(line++).contains("--changeset_"));
-    assertEquals("Content-Type: application/http" + CRLF, response.get(line++));
-    assertEquals("Content-Transfer-Encoding: binary" + CRLF, response.get(line++));
-
-    assertTrue(response.get(line).contains("Content-Id:"));
-    String contentId = response.get(line).split(":")[1].trim();
-    line++;
-
-    assertEquals(CRLF, response.get(line++));
-
-    return contentId;
-  }
-
-  @Test(expected = BatchException.class)
-  public void testInvalidMethod() throws UnsupportedEncodingException, BatchException {
-    final String content = ""
-        + "--batch_12345" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_12345" + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "PUT ESAllPrim(1) HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345--" + CRLF
-        + CRLF
-        + "--batch_12345--";
-
-    final Map<String, List<String>> header = getMimeHeader();
-    final ODataResponse response = new ODataResponse();
-    final ODataRequest request = buildODataRequest(content, header);
-    request.setMethod(HttpMethod.GET);
-
-    batchHandler.process(request, response, true);
-  }
-
-  @Test(expected = BatchException.class)
-  public void testInvalidContentType() throws UnsupportedEncodingException, BatchException {
-    final String content = ""
-        + "--batch_12345" + CRLF
-        + "Content-Type: multipart/mixed; boundary=changeset_12345" + CRLF
-        + CRLF
-        + "--changeset_12345" + CRLF
-        + "Content-Type: application/http" + CRLF
-        + "Content-Transfer-Encoding: binary" + CRLF
-        + "Content-Id: 1" + CRLF
-        + CRLF
-        + "PUT ESAllPrim(1) HTTP/1.1" + CRLF
-        + "Content-Type: application/json;odata=verbose" + CRLF
-        + CRLF
-        + CRLF
-        + "--changeset_12345--" + CRLF
-        + CRLF
-        + "--batch_12345--";
-
-    final Map<String, List<String>> header = new HashMap<String, List<String>>();
-    header.put(HttpHeader.CONTENT_TYPE, Arrays.asList(new String[] { "application/http" }));
-    final ODataResponse response = new ODataResponse();
-    final ODataRequest request = buildODataRequest(content, header);
-
-    batchHandler.process(request, response, true);
-  }
-
-  /*
-   * Helper methods
-   */
-  private Map<String, List<String>> getMimeHeader() {
-    final Map<String, List<String>> header = new HashMap<String, List<String>>();
-    header.put(HttpHeader.CONTENT_TYPE, Arrays.asList(new String[] { BATCH_CONTENT_TYPE }));
-
-    return header;
-  }
-
-  private ODataRequest buildODataRequest(final String content, final Map<String, List<String>> header)
-      throws UnsupportedEncodingException {
-    final ODataRequest request = new ODataRequest();
-
-    for (final String key : header.keySet()) {
-      request.addHeader(key, header.get(key));
-    }
-
-    request.setMethod(HttpMethod.POST);
-    request.setRawBaseUri(BASE_URI);
-    request.setRawODataPath(BATCH_ODATA_PATH);
-    request.setRawQueryPath("");
-    request.setRawRequestUri(BATCH_REQUEST_URI);
-    request.setRawServiceResolutionUri("");
-
-    request.setBody(new ByteArrayInputStream(content.getBytes("UTF-8")));
-
-    return request;
-  }
-
-  /**
-   * Batch processor
-   */
-  private class BatchTestProcessorImpl implements BatchProcessor {
-    @Override
-    public void init(OData odata, ServiceMetadata serviceMetadata) {}
-
-    @Override
-    public ODataResponsePart executeChangeSet(BatchOperation operation, List<ODataRequest> requests,
-        BatchRequestPart requestPart) {
-      List<ODataResponse> responses = new ArrayList<ODataResponse>();
-
-      for (ODataRequest request : requests) {
-        try {
-          responses.add(operation.handleODataRequest(request, requestPart));
-        } catch (BatchException e) {
-          fail();
-        }
-      }
-
-      return new ODataResponsePart(responses, true);
-    }
-
-    @Override
-    public void executeBatch(BatchOperation operation, ODataRequest request, ODataResponse response) {
-      try {
-        final List<BatchRequestPart> parts = operation.parseBatchRequest(request, true);
-        final List<ODataResponsePart> responseParts = new ArrayList<ODataResponsePart>();
-
-        for (BatchRequestPart part : parts) {
-          for (final ODataRequest oDataRequest : part.getRequests()) {
-            // Mock the processor for a given requests
-            when(oDataHandler.process(oDataRequest)).then(new Answer<ODataResponse>() {
-              @Override
-              public ODataResponse answer(InvocationOnMock invocation) throws Throwable {
-                Object[] arguments = invocation.getArguments();
-
-                return buildResponse((ODataRequest) arguments[0]);
-              }
-            });
-          }
-
-          responseParts.add(operation.handleBatchRequest(part));
-        }
-
-        operation.writeResponseParts(responseParts, response);
-      } catch (BatchException e) {
-        throw new ODataRuntimeException(e);
-      } catch (IOException e) {
-        throw new ODataRuntimeException(e);
-      }
-    }
-  }
-
-  private ODataResponse buildResponse(ODataRequest request) {
-    final ODataResponse oDataResponse = new ODataResponse();
-
-    if (request.getMethod() == HttpMethod.POST) {
-      oDataResponse.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
-      oDataResponse.setHeader(HttpHeader.LOCATION, createResourceUri(request));
-    } else {
-      oDataResponse.setStatusCode(HttpStatusCode.OK.getStatusCode());
-    }
-
-    final String contentId = request.getHeader(BatchParserCommon.HTTP_CONTENT_ID);
-    if (contentId != null) {
-      oDataResponse.setHeader(BatchParserCommon.HTTP_CONTENT_ID, contentId);
-    }
-
-    return oDataResponse;
-  }
-
-  private String createResourceUri(final ODataRequest request) {
-    final String parts[] = request.getRawODataPath().split("/");
-    String oDataPath = "";
-
-    if (parts.length == 2) {
-      // Entity Collection
-      oDataPath = parts[1];
-    } else {
-      // Navigation property
-
-      final String navProperty = parts[parts.length - 1];
-      if (navProperty.equals("NavPropertyETTwoPrimMany")) {
-        oDataPath = "ESTwoPrim";
-      } else if (navProperty.equals("NavPropertyETAllPrimMany")) {
-        oDataPath = "ESAllPrim";
-      } else if (navProperty.equals("NavPropertyETTwoPrimOne")) {
-        oDataPath = "ESTwoPrim";
-      }
-    }
-
-    return BASE_URI + "/" + oDataPath + "(" + entityCounter++ + ")";
-  }
-}