You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/07/19 21:31:03 UTC

[1/2] olingo-odata2 git commit: [OLINGO-733] More tests and moved tests

Repository: olingo-odata2
Updated Branches:
  refs/heads/OLINGO-733_BatchFix cc70e8a39 -> a9af4008c


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/HeaderTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/HeaderTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/HeaderTest.java
new file mode 100644
index 0000000..82b7ee2
--- /dev/null
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/HeaderTest.java
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * 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.odata2.core.batch.v2;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.commons.HttpContentType;
+import org.apache.olingo.odata2.api.commons.HttpHeaders;
+import org.apache.olingo.odata2.core.batch.v2.BatchParserCommon;
+import org.apache.olingo.odata2.core.batch.v2.Header;
+import org.junit.Test;
+
+public class HeaderTest {
+
+  @Test
+  public void test() {
+    Header header = new Header(1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
+
+    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeader(HttpHeaders.CONTENT_TYPE));
+    assertEquals(1, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
+    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(0));
+  }
+
+  @Test
+  public void testNotAvailable() {
+    Header header = new Header(1);
+
+    assertNull(header.getHeader(HttpHeaders.CONTENT_TYPE));
+    assertEquals(0, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
+    assertEquals("", header.getHeaderNotNull(HttpHeaders.CONTENT_TYPE));
+  }
+
+  @Test
+  public void testCaseInsensitive() {
+    Header header = new Header(1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
+
+    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeader("cOnTenT-TyPE"));
+    assertEquals(1, header.getHeaders("cOnTenT-TyPE").size());
+    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeaders("cOnTenT-TyPE").get(0));
+  }
+
+  @Test
+  public void testDuplicatedAdd() {
+    Header header = new Header(1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 2);
+
+    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeader(HttpHeaders.CONTENT_TYPE));
+    assertEquals(1, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
+    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(0));
+  }
+
+  @Test
+  public void testMatcher() {
+    Header header = new Header(1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED + ";boundary=123", 1);
+
+    assertTrue(header.isHeaderMatching(HttpHeaders.CONTENT_TYPE, BatchParserCommon.PATTERN_MULTIPART_MIXED));
+  }
+
+  @Test
+  public void testFieldName() {
+    Header header = new Header(0);
+    header.addHeader("MyFieldNamE", "myValue", 1);
+
+    assertEquals("MyFieldNamE", header.getHeaderField("myfieldname").getFieldName());
+    assertEquals("MyFieldNamE", header.toSingleMap().keySet().toArray(new String[0])[0]);
+    assertEquals("MyFieldNamE", header.toMultiMap().keySet().toArray(new String[0])[0]);
+
+    assertEquals("myValue", header.toMultiMap().get("MyFieldNamE").get(0));
+    assertEquals("myValue", header.toSingleMap().get("MyFieldNamE"));
+  }
+
+  @Test
+  public void testDeepCopy() {
+    Header header = new Header(1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED + ";boundary=123", 1);
+
+    Header copy = header.clone();
+    assertEquals(header.getHeaders(HttpHeaders.CONTENT_TYPE), copy.getHeaders(HttpHeaders.CONTENT_TYPE));
+    assertEquals(header.getHeader(HttpHeaders.CONTENT_TYPE), copy.getHeader(HttpHeaders.CONTENT_TYPE));
+    assertEquals(header.getHeaderField(HttpHeaders.CONTENT_TYPE), copy.getHeaderField(HttpHeaders.CONTENT_TYPE));
+
+    assertTrue(header.getHeaders(HttpHeaders.CONTENT_TYPE) != copy.getHeaders(HttpHeaders.CONTENT_TYPE));
+    assertTrue(header.getHeaderField(HttpHeaders.CONTENT_TYPE) != copy.getHeaderField(HttpHeaders.CONTENT_TYPE));
+  }
+
+  @Test
+  public void testMatcherNoHeader() {
+    Header header = new Header(1);
+
+    assertFalse(header.isHeaderMatching(HttpHeaders.CONTENT_TYPE,  BatchParserCommon.PATTERN_MULTIPART_MIXED));
+  }
+
+  @Test
+  public void testMatcherFail() {
+    Header header = new Header(1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED + ";boundary=123", 1);
+
+    assertFalse(header.isHeaderMatching(HttpHeaders.CONTENT_TYPE, BatchParserCommon.PATTERN_HEADER_LINE));
+  }
+
+  @Test
+  public void testDuplicatedAddList() {
+    Header header = new Header(1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, Arrays.asList(new String[] { HttpContentType.MULTIPART_MIXED,
+        HttpContentType.APPLICATION_ATOM_SVC }), 2);
+
+    assertEquals(HttpContentType.MULTIPART_MIXED + ", " + HttpContentType.APPLICATION_ATOM_SVC, header
+        .getHeader(HttpHeaders.CONTENT_TYPE));
+    assertEquals(2, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
+    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(0));
+    assertEquals(HttpContentType.APPLICATION_ATOM_SVC, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(1));
+  }
+
+  @Test
+  public void testRemove() {
+    Header header = new Header(1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
+    header.removeHeader(HttpHeaders.CONTENT_TYPE);
+
+    assertNull(header.getHeader(HttpHeaders.CONTENT_TYPE));
+    assertEquals(0, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
+  }
+
+  @Test
+  public void testMultipleValues() {
+    Header header = new Header(1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.APPLICATION_ATOM_SVC, 2);
+    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.APPLICATION_ATOM_XML, 3);
+
+    final String fullHeaderString =
+        HttpContentType.MULTIPART_MIXED + ", " + HttpContentType.APPLICATION_ATOM_SVC + ", "
+            + HttpContentType.APPLICATION_ATOM_XML;
+
+    assertEquals(fullHeaderString, header.getHeader(HttpHeaders.CONTENT_TYPE));
+    assertEquals(3, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
+    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(0));
+    assertEquals(HttpContentType.APPLICATION_ATOM_SVC, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(1));
+    assertEquals(HttpContentType.APPLICATION_ATOM_XML, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(2));
+  }
+  
+  @Test
+  public void testSplitValues() {
+    final String values = "abc, def,123,77,   99, ysd";
+    List<String> splittedValues = Header.splitValuesByComma(values);
+
+    assertEquals(6, splittedValues.size());
+    assertEquals("abc", splittedValues.get(0));
+    assertEquals("def", splittedValues.get(1));
+    assertEquals("123", splittedValues.get(2));
+    assertEquals("77", splittedValues.get(3));
+    assertEquals("99", splittedValues.get(4));
+    assertEquals("ysd", splittedValues.get(5));
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/client/ClientBatchTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/client/ClientBatchTest.java b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/client/ClientBatchTest.java
index 91c5f0d..3ab22f6 100644
--- a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/client/ClientBatchTest.java
+++ b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/client/ClientBatchTest.java
@@ -33,6 +33,7 @@ import java.util.Map;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.entity.StringEntity;
 import org.apache.olingo.odata2.api.client.batch.BatchChangeSet;
 import org.apache.olingo.odata2.api.client.batch.BatchChangeSetPart;
@@ -127,9 +128,57 @@ public class ClientBatchTest extends AbstractRefTest {
         fail();
       }
     }
+  }
+
+  @Test
+  public void testChangeSetBatchUmlauts() throws Exception {
+    List<BatchPart> batch = new ArrayList<BatchPart>();
+
+    BatchChangeSet changeSet = BatchChangeSet.newBuilder().build();
+    Map<String, String> changeSetHeaders = new HashMap<String, String>();
+    changeSetHeaders.put("content-type", "application/json;odata=verbose");
 
+    BatchChangeSetPart changeRequest = BatchChangeSetPart.method(PUT)
+        .uri("Employees('2')/EmployeeName")
+        .body("{\"EmployeeName\":\"Frederic üäö Fall\"}")
+        .headers(changeSetHeaders)
+        .build();
+    changeSet.add(changeRequest);
+    batch.add(changeSet);
+
+    BatchPart request = BatchQueryPart.method(GET)
+        .uri("Employees('2')/EmployeeName/$value")
+        .build();
+    batch.add(request);
+
+    InputStream body = EntityProvider.writeBatchRequest(batch, BOUNDARY);
+    StringHelper.Stream bodyStream = StringHelper.toStream(body);
+    String bodyAsString = bodyStream.asStringWithLineSeparation("\r\n");
+    checkMimeHeaders(bodyAsString);
+    checkBoundaryDelimiters(bodyAsString);
+
+    assertTrue(bodyAsString.contains("PUT Employees('2')/EmployeeName HTTP/1.1"));
+    assertTrue(bodyAsString.contains("GET Employees('2')/EmployeeName/$value HTTP/1.1"));
+    assertTrue(bodyAsString.contains("content-type: application/json;odata=verbose"));
+
+    HttpResponse batchResponse = execute(bodyStream.asStreamWithLineSeparation("\r\n"));
+    InputStream responseBody = batchResponse.getEntity().getContent();
+    //
+    String contentType = batchResponse.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();
+    List<BatchSingleResponse> responses = EntityProvider.parseBatchResponse(responseBody, contentType);
+    for (BatchSingleResponse response : responses) {
+      if ("204".equals(response.getStatusCode())) {
+        assertEquals("No Content", response.getStatusInfo());
+      } else if ("200".equals(response.getStatusCode())) {
+        assertEquals("OK", response.getStatusInfo());
+        assertTrue(response.getBody().contains("Frederic üäö Fall"));
+      } else {
+        fail();
+      }
+    }
   }
 
+
   @Test
   public void testContentIdReferencing() throws Exception {
     List<BatchPart> batch = new ArrayList<BatchPart>();
@@ -230,6 +279,20 @@ public class ClientBatchTest extends AbstractRefTest {
     return response;
   }
 
+  private HttpResponse execute(final InputStream body) throws Exception {
+    final HttpPost post = new HttpPost(URI.create(getEndpoint().toString() + "$batch"));
+
+    post.setHeader("Content-Type", "multipart/mixed;boundary=" + BOUNDARY);
+    HttpEntity entity = new InputStreamEntity(body, -1);
+    post.setEntity(entity);
+    HttpResponse response = getHttpClient().execute(post);
+
+    assertNotNull(response);
+    assertEquals(202, response.getStatusLine().getStatusCode());
+
+    return response;
+  }
+
   private void checkMimeHeaders(final String requestBody) {
     assertTrue(requestBody.contains("Content-Type: application/http"));
     assertTrue(requestBody.contains("Content-Transfer-Encoding: binary"));


[2/2] olingo-odata2 git commit: [OLINGO-733] More tests and moved tests

Posted by mi...@apache.org.
[OLINGO-733] More tests and moved tests


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

Branch: refs/heads/OLINGO-733_BatchFix
Commit: a9af4008ca030372723e63f9605b4c352df8c23e
Parents: cc70e8a
Author: mibo <mi...@mirb.de>
Authored: Sun Jul 19 21:15:46 2015 +0200
Committer: mibo <mi...@mirb.de>
Committed: Sun Jul 19 21:15:46 2015 +0200

----------------------------------------------------------------------
 .../odata2/core/batch/v2/BatchLineReader.java   | 228 ++++++++++++++++
 .../odata2/core/batch/v2/BatchParser.java       |   2 +-
 .../v2/BufferedReaderIncludingLineEndings.java  | 229 ----------------
 .../core/batch/BatchParserCommonTest.java       | 230 -----------------
 .../core/batch/BatchRequestWriterITTest.java    |   2 -
 .../core/batch/BatchRequestWriterTest.java      |  36 ++-
 .../core/batch/BatchResponseWriterTest.java     |  26 +-
 .../batch/BatchTransformatorCommonTest.java     | 123 ---------
 .../BufferedReaderIncludingLineEndingsTest.java | 258 -------------------
 .../olingo/odata2/core/batch/HeaderTest.java    | 179 -------------
 .../core/batch/v2/BatchLineReaderTest.java      | 255 ++++++++++++++++++
 .../core/batch/v2/BatchParserCommonTest.java    | 231 +++++++++++++++++
 .../batch/v2/BatchTransformatorCommonTest.java  | 124 +++++++++
 .../olingo/odata2/core/batch/v2/HeaderTest.java | 179 +++++++++++++
 .../odata2/fit/client/ClientBatchTest.java      |  63 +++++
 15 files changed, 1111 insertions(+), 1054 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchLineReader.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchLineReader.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchLineReader.java
new file mode 100644
index 0000000..81cde03
--- /dev/null
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchLineReader.java
@@ -0,0 +1,228 @@
+/*******************************************************************************
+ * 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.odata2.core.batch.v2;
+
+import org.apache.olingo.odata2.core.commons.ContentType;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+public class BatchLineReader {
+  private static final byte CR = '\r';
+  private static final byte LF = '\n';
+  private static final int EOF = -1;
+  private static final int BUFFER_SIZE = 8192;
+  private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+  private static final Charset CS_ISO_8859_1 = Charset.forName("iso-8859-1");
+  private static final String CONTENT_TYPE = "content-type";
+  public static final String BOUNDARY = "boundary";
+  public static final String DOUBLE_DASH = "--";
+  public static final String CRLF = "\r\n";
+  private Charset currentCharset = DEFAULT_CHARSET;
+  private String currentBoundary = null;
+  private ReadState readState = new ReadState();
+  private InputStream reader;
+  private byte[] buffer;
+  private int offset = 0;
+  private int limit = 0;
+
+  public BatchLineReader(final InputStream reader) {
+    this(reader, BUFFER_SIZE);
+  }
+
+  public BatchLineReader(final InputStream reader, final int bufferSize) {
+    if (bufferSize <= 0) {
+      throw new IllegalArgumentException("Buffer size must be greater than zero.");
+    }
+
+    this.reader = reader;
+    buffer = new byte[bufferSize];
+  }
+
+  public void close() throws IOException {
+    reader.close();
+  }
+
+  public List<String> toList() throws IOException {
+    final List<String> result = new ArrayList<String>();
+    String currentLine = readLine();
+    if(currentLine != null) {
+      currentBoundary = currentLine.trim();
+      result.add(currentLine);
+
+      while ((currentLine = readLine()) != null) {
+        result.add(currentLine);
+      }
+    }
+    return result;
+  }
+
+  public List<Line> toLineList() throws IOException {
+    final List<Line> result = new ArrayList<Line>();
+    String currentLine = readLine();
+    if(currentLine != null) {
+      currentBoundary = currentLine.trim();
+      int counter = 1;
+      result.add(new Line(currentLine, counter++));
+
+      while ((currentLine = readLine()) != null) {
+        result.add(new Line(currentLine, counter++));
+      }
+    }
+
+    return result;
+  }
+
+  private void updateCurrentCharset(String currentLine) {
+    if(currentLine != null) {
+      if(isContentTypeHeaderLine(currentLine)) {
+        currentLine = currentLine.substring(13, currentLine.length() - 2).trim();
+        ContentType ct = ContentType.parse(currentLine);
+        if (ct != null) {
+          String charsetString = ct.getParameters().get(ContentType.PARAMETER_CHARSET);
+          if (charsetString != null) {
+            currentCharset = Charset.forName(charsetString);
+          } else {
+            currentCharset = DEFAULT_CHARSET;
+          }
+          // boundary
+          String boundary = ct.getParameters().get(BOUNDARY);
+          if (boundary != null) {
+            currentBoundary = DOUBLE_DASH + boundary;
+          }
+        }
+      } else if(CRLF.equals(currentLine)) {
+        readState.foundLinebreak();
+      } else if(isBoundary(currentLine)) {
+        readState.foundBoundary();
+      }
+    }
+  }
+
+  private boolean isContentTypeHeaderLine(String currentLine) {
+    return currentLine.toLowerCase(Locale.ENGLISH).startsWith(CONTENT_TYPE);
+  }
+
+  private boolean isBoundary(String currentLine) {
+    if((currentBoundary + CRLF).equals(currentLine)) {
+      return true;
+    } else if((currentBoundary + DOUBLE_DASH + CRLF).equals(currentLine)) {
+      return true;
+    }
+    return false;
+  }
+
+  String readLine() throws IOException {
+    if (limit == EOF) {
+      return null;
+    }
+
+    ByteBuffer buffer = ByteBuffer.allocate(BUFFER_SIZE);
+    boolean foundLineEnd = false; // EOF will be considered as line ending
+
+    while (!foundLineEnd) {
+      // Is buffer refill required?
+      if (limit == offset) {
+        if (fillBuffer() == EOF) {
+          foundLineEnd = true;
+        }
+      }
+
+      if (!foundLineEnd) {
+        byte currentChar = this.buffer[offset++];
+        if(!buffer.hasRemaining()) {
+          buffer.flip();
+          ByteBuffer tmp = ByteBuffer.allocate(buffer.limit() *2);
+          tmp.put(buffer);
+          buffer = tmp;
+        }
+        buffer.put(currentChar);
+
+        if (currentChar == LF) {
+          foundLineEnd = true;
+        } else if (currentChar == CR) {
+          foundLineEnd = true;
+
+          // Check next byte. Consume \n if available
+          // Is buffer refill required?
+          if (limit == offset) {
+            fillBuffer();
+          }
+
+          // Check if there is at least one character
+          if (limit != EOF && this.buffer[offset] == LF) {
+            buffer.put(LF);
+            offset++;
+          }
+        }
+      }
+    }
+
+    if(buffer.position() == 0) {
+      return null;
+    } else {
+      String currentLine;
+      if(readState.isReadBody()) {
+        currentLine = new String(buffer.array(), 0, buffer.position(), getCurrentCharset());
+      } else {
+        currentLine = new String(buffer.array(), 0, buffer.position(), CS_ISO_8859_1);
+      }
+      updateCurrentCharset(currentLine);
+      return currentLine;
+    }
+  }
+
+  private int fillBuffer() throws IOException {
+    limit = reader.read(buffer, 0, buffer.length);
+    offset = 0;
+
+    return limit;
+  }
+
+  private Charset getCurrentCharset() {
+    return currentCharset;
+  }
+
+  /**
+   * Read state indicator (whether currently the <code>body</code> or <code>header</code> part is read).
+   */
+  private class ReadState {
+    private int state = 0;
+
+    public void foundLinebreak() {
+      state++;
+    }
+    public void foundBoundary() {
+      state = 0;
+    }
+    public boolean isReadBody() {
+      return state >= 2;
+    }
+
+    @Override
+    public String toString() {
+      return String.valueOf(state);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchParser.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchParser.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchParser.java
index f872627..7f53e0d 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchParser.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchParser.java
@@ -92,7 +92,7 @@ public class BatchParser {
   private List<List<Line>> splitBodyParts(final InputStream in, final String boundary)
       throws IOException, BatchException {
 
-    final BufferedReaderIncludingLineEndings reader = new BufferedReaderIncludingLineEndings(in);
+    final BatchLineReader reader = new BatchLineReader(in);
     final List<Line> message = reader.toLineList();
     reader.close();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BufferedReaderIncludingLineEndings.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BufferedReaderIncludingLineEndings.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BufferedReaderIncludingLineEndings.java
deleted file mode 100644
index d9a216c..0000000
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BufferedReaderIncludingLineEndings.java
+++ /dev/null
@@ -1,229 +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.odata2.core.batch.v2;
-
-import org.apache.olingo.odata2.core.commons.ContentType;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-public class BufferedReaderIncludingLineEndings {
-  private static final byte CR = '\r';
-  private static final byte LF = '\n';
-  private static final int EOF = -1;
-  private static final int BUFFER_SIZE = 8192;
-  private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
-  private static final Charset CS_ISO_8859_1 = Charset.forName("iso-8859-1");
-  private static final String CONTENT_TYPE = "content-type";
-  public static final String BOUNDARY = "boundary";
-  public static final String DOUBLE_DASH = "--";
-  public static final String CRLF = "\r\n";
-  private Charset currentCharset = DEFAULT_CHARSET;
-  private String currentBoundary = null;
-  private ReadState readState = new ReadState();
-  private InputStream reader;
-  private byte[] buffer;
-  private int offset = 0;
-  private int limit = 0;
-
-  public BufferedReaderIncludingLineEndings(final InputStream reader) {
-    this(reader, BUFFER_SIZE);
-  }
-
-  public BufferedReaderIncludingLineEndings(final InputStream reader, final int bufferSize) {
-    if (bufferSize <= 0) {
-      throw new IllegalArgumentException("Buffer size must be greater than zero.");
-    }
-
-    this.reader = reader;
-    buffer = new byte[bufferSize];
-  }
-
-  public void close() throws IOException {
-    reader.close();
-  }
-
-  public List<String> toList() throws IOException {
-    final List<String> result = new ArrayList<String>();
-    String currentLine = readLine();
-    if(currentLine != null) {
-      currentBoundary = currentLine.trim();
-      result.add(currentLine);
-
-      while ((currentLine = readLine()) != null) {
-        result.add(currentLine);
-      }
-    }
-    return result;
-  }
-
-  public List<Line> toLineList() throws IOException {
-    final List<Line> result = new ArrayList<Line>();
-    String currentLine = readLine();
-    if(currentLine != null) {
-      currentBoundary = currentLine.trim();
-      int counter = 1;
-      result.add(new Line(currentLine, counter++));
-
-      while ((currentLine = readLine()) != null) {
-        result.add(new Line(currentLine, counter++));
-      }
-    }
-
-    return result;
-  }
-
-  private void updateCurrentCharset(String currentLine) {
-    if(currentLine != null) {
-      if(isContentTypeHeaderLine(currentLine)) {
-        currentLine = currentLine.substring(13, currentLine.length() - 2).trim();
-        ContentType ct = ContentType.parse(currentLine);
-        if (ct != null) {
-          String charsetString = ct.getParameters().get(ContentType.PARAMETER_CHARSET);
-          if (charsetString != null) {
-            currentCharset = Charset.forName(charsetString);
-          } else {
-            currentCharset = DEFAULT_CHARSET;
-          }
-          // boundary
-          String boundary = ct.getParameters().get(BOUNDARY);
-          if (boundary != null) {
-            currentBoundary = DOUBLE_DASH + boundary;
-          }
-        }
-      } else if(CRLF.equals(currentLine)) {
-        readState.foundLinebreak();
-      } else if(isBoundary(currentLine)) {
-        readState.foundBoundary();
-      }
-    }
-  }
-
-  private boolean isContentTypeHeaderLine(String currentLine) {
-    return currentLine.toLowerCase(Locale.ENGLISH).startsWith(CONTENT_TYPE);
-  }
-
-  private boolean isBoundary(String currentLine) {
-    if((currentBoundary + CRLF).equals(currentLine)) {
-      return true;
-    } else if((currentBoundary + DOUBLE_DASH + CRLF).equals(currentLine)) {
-      return true;
-    }
-    return false;
-  }
-
-  // TODO: mibo: check visibility
-  public String readLine() throws IOException {
-    if (limit == EOF) {
-      return null;
-    }
-
-    ByteBuffer buffer = ByteBuffer.allocate(BUFFER_SIZE);
-    boolean foundLineEnd = false; // EOF will be considered as line ending
-
-    while (!foundLineEnd) {
-      // Is buffer refill required?
-      if (limit == offset) {
-        if (fillBuffer() == EOF) {
-          foundLineEnd = true;
-        }
-      }
-
-      if (!foundLineEnd) {
-        byte currentChar = this.buffer[offset++];
-        if(!buffer.hasRemaining()) {
-          buffer.flip();
-          ByteBuffer tmp = ByteBuffer.allocate(buffer.limit() *2);
-          tmp.put(buffer);
-          buffer = tmp;
-        }
-        buffer.put(currentChar);
-
-        if (currentChar == LF) {
-          foundLineEnd = true;
-        } else if (currentChar == CR) {
-          foundLineEnd = true;
-
-          // Check next byte. Consume \n if available
-          // Is buffer refill required?
-          if (limit == offset) {
-            fillBuffer();
-          }
-
-          // Check if there is at least one character
-          if (limit != EOF && this.buffer[offset] == LF) {
-            buffer.put(LF);
-            offset++;
-          }
-        }
-      }
-    }
-
-    if(buffer.position() == 0) {
-      return null;
-    } else {
-      String currentLine;
-      if(readState.isReadBody()) {
-        currentLine = new String(buffer.array(), 0, buffer.position(), getCurrentCharset());
-      } else {
-        currentLine = new String(buffer.array(), 0, buffer.position(), CS_ISO_8859_1);
-      }
-      updateCurrentCharset(currentLine);
-      return currentLine;
-    }
-  }
-
-  private int fillBuffer() throws IOException {
-    limit = reader.read(buffer, 0, buffer.length);
-    offset = 0;
-
-    return limit;
-  }
-
-  private Charset getCurrentCharset() {
-    return currentCharset;
-  }
-
-  /**
-   * Read state indicator (whether currently the <code>body</code> or <code>header</code> part is read).
-   */
-  private class ReadState {
-    private int state = 0;
-
-    public void foundLinebreak() {
-      state++;
-    }
-    public void foundBoundary() {
-      state = 0;
-    }
-    public boolean isReadBody() {
-      return state >= 2;
-    }
-
-    @Override
-    public String toString() {
-      return String.valueOf(state);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchParserCommonTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchParserCommonTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchParserCommonTest.java
deleted file mode 100644
index 5a5b13c..0000000
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchParserCommonTest.java
+++ /dev/null
@@ -1,230 +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.odata2.core.batch;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.batch.BatchException;
-import org.apache.olingo.odata2.api.commons.HttpHeaders;
-import org.apache.olingo.odata2.core.batch.v2.BatchParserCommon;
-import org.apache.olingo.odata2.core.batch.v2.Header;
-import org.apache.olingo.odata2.core.batch.v2.Line;
-import org.junit.Test;
-
-public class BatchParserCommonTest {
-  
-  private static final String CRLF = "\r\n";
-  
-  @Test
-  public void testMultipleHeader() throws BatchException {
-    String[] messageRaw = new String[] {
-        "Content-Id: 1" + CRLF,
-        "Content-Id: 2" + CRLF,
-        "content-type: Application/http" + CRLF,
-        "content-transfer-encoding: Binary" + CRLF
-      };
-    List<Line> message = toLineList(messageRaw);
-    
-    final Header header = BatchParserCommon.consumeHeaders(message);
-    assertNotNull(header);
-    
-    final List<String> contentIdHeaders = header.getHeaders(BatchHelper.HTTP_CONTENT_ID);
-    assertNotNull(contentIdHeaders);
-    assertEquals(2, contentIdHeaders.size());
-    assertEquals("1", contentIdHeaders.get(0));
-    assertEquals("2", contentIdHeaders.get(1));
-  }
-  
-  @Test
-  public void testMultipleHeaderSameValue() throws BatchException {
-    String[] messageRaw = new String[] {
-        "Content-Id: 1" + CRLF,
-        "Content-Id: 1" + CRLF,
-        "content-type: Application/http" + CRLF,
-        "content-transfer-encoding: Binary" + CRLF
-      };
-    List<Line> message = toLineList(messageRaw);
-    
-    final Header header = BatchParserCommon.consumeHeaders(message);
-    assertNotNull(header);
-    
-    final List<String> contentIdHeaders = header.getHeaders(BatchHelper.HTTP_CONTENT_ID);
-    assertNotNull(contentIdHeaders);
-    assertEquals(1, contentIdHeaders.size());
-    assertEquals("1", contentIdHeaders.get(0));
-  }
-  
-  @Test
-  public void testHeaderSperatedByComma() throws BatchException {
-    String[] messageRaw = new String[] {
-        "Content-Id: 1" + CRLF,
-        "Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11" + CRLF,
-        "content-type: Application/http" + CRLF,
-        "content-transfer-encoding: Binary" + CRLF
-      };
-    List<Line> message = toLineList(messageRaw);
-    
-    final Header header = BatchParserCommon.consumeHeaders(message);
-    assertNotNull(header);
-    
-    final List<String> upgradeHeader = header.getHeaders("upgrade");
-    assertNotNull(upgradeHeader);
-    assertEquals(4, upgradeHeader.size());
-    assertEquals("HTTP/2.0", upgradeHeader.get(0));
-    assertEquals("SHTTP/1.3", upgradeHeader.get(1));
-    assertEquals("IRC/6.9", upgradeHeader.get(2));
-    assertEquals("RTA/x11", upgradeHeader.get(3));
-  }
-  
-  @Test
-  public void testMultipleAcceptHeader() throws BatchException {
-    String[] messageRaw = new String[] {
-        "Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1" + CRLF,
-        "Accept: text/plain;q=0.3" + CRLF,
-        "Accept-Language:en-US,en;q=0.7,en-UK;q=0.9" + CRLF,
-        "content-type: Application/http" + CRLF,
-        "content-transfer-encoding: Binary" + CRLF
-      };
-    List<Line> message = toLineList(messageRaw);
-    
-    final Header header = BatchParserCommon.consumeHeaders(message);
-    assertNotNull(header);
-    
-    final List<String> acceptHeader = header.getHeaders(HttpHeaders.ACCEPT);
-    assertNotNull(acceptHeader);
-    assertEquals(4, acceptHeader.size());
-  }
-  
-  @Test
-  public void testMultipleAcceptHeaderSameValue() throws BatchException {
-    String[] messageRaw = new String[] {
-        "Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1" + CRLF,
-        "Accept: application/atomsvc+xml;q=0.8" + CRLF,
-        "Accept-Language:en-US,en;q=0.7,en-UK;q=0.9" + CRLF,
-        "content-type: Application/http" + CRLF,
-        "content-transfer-encoding: Binary" + CRLF
-      };
-    List<Line> message = toLineList(messageRaw);
-    
-    final Header header = BatchParserCommon.consumeHeaders(message);
-    assertNotNull(header);
-    
-    final List<String> acceptHeader = header.getHeaders(HttpHeaders.ACCEPT);
-    assertNotNull(acceptHeader);
-    assertEquals(3, acceptHeader.size());
-  }
-  
-  @Test
-  public void testMultipleAccepLanguagetHeader() throws BatchException {
-    String[] messageRaw = new String[] {
-        "Accept-Language:en-US,en;q=0.7,en-UK;q=0.9" + CRLF,
-        "Accept-Language: de-DE;q=0.3" + CRLF,
-        "content-type: Application/http" + CRLF,
-        "content-transfer-encoding: Binary" + CRLF
-      };
-    List<Line> message = toLineList(messageRaw);
-    
-    final Header header = BatchParserCommon.consumeHeaders(message);
-    assertNotNull(header);
-    
-    final List<String> acceptLanguageHeader = header.getHeaders(HttpHeaders.ACCEPT_LANGUAGE);
-    assertNotNull(acceptLanguageHeader);
-    assertEquals(4, acceptLanguageHeader.size());
-  }
-  
-  @Test
-  public void testMultipleAccepLanguagetHeaderSameValue() throws BatchException {
-    String[] messageRaw = new String[] {
-        "Accept-Language:en-US,en;q=0.7,en-UK;q=0.9" + CRLF,
-        "Accept-Language:en-US,en;q=0.7" + CRLF,
-        "content-type: Application/http" + CRLF,
-        "content-transfer-encoding: Binary" + CRLF
-      };
-    List<Line> message = toLineList(messageRaw);
-    
-    final Header header = BatchParserCommon.consumeHeaders(message);
-    assertNotNull(header);
-    
-    final List<String> acceptLanguageHeader = header.getHeaders(HttpHeaders.ACCEPT_LANGUAGE);
-    assertNotNull(acceptLanguageHeader);
-    assertEquals(3, acceptLanguageHeader.size());
-  }
-  
-  @Test
-  public void testRemoveEndingCRLF() {
-    String line = "Test\r\n";
-    assertEquals("Test", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
-  }
-
-  @Test
-  public void testRemoveLastEndingCRLF() {
-    String line = "Test\r\n\r\n";
-    assertEquals("Test\r\n", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
-  }
-
-  @Test
-  public void testRemoveEndingCRLFWithWS() {
-    String line = "Test\r\n            ";
-    assertEquals("Test", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
-  }
-
-  @Test
-  public void testRemoveEndingCRLFNothingToRemove() {
-    String line = "Hallo\r\nBla";
-    assertEquals("Hallo\r\nBla", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
-  }
-
-  @Test
-  public void testRemoveEndingCRLFAll() {
-    String line = "\r\n";
-    assertEquals("", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
-  }
-
-  @Test
-  public void testRemoveEndingCRLFSpace() {
-    String line = "\r\n                      ";
-    assertEquals("", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
-  }
-
-  @Test
-  public void testRemoveLastEndingCRLFWithWS() {
-    String line = "Test            \r\n";
-    assertEquals("Test            ", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
-  }
-
-  @Test
-  public void testRemoveLastEndingCRLFWithWSLong() {
-    String line = "Test            \r\nTest2    \r\n";
-    assertEquals("Test            \r\nTest2    ", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
-  }
-  
-  private List<Line> toLineList(String[] messageRaw) {
-    final List<Line> lineList = new ArrayList<Line>();
-    int counter = 1;
-    
-    for(final String currentLine : messageRaw) {
-      lineList.add(new Line(currentLine, counter++));
-    }
-    
-    return lineList;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
index 1faf807..e2aa353 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
@@ -22,7 +22,6 @@ import static org.junit.Assert.*;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -41,7 +40,6 @@ import org.apache.olingo.odata2.api.ep.EntityProviderBatchProperties;
 import org.apache.olingo.odata2.api.processor.ODataRequest;
 import org.apache.olingo.odata2.core.PathInfoImpl;
 import org.apache.olingo.odata2.core.batch.v2.BatchParser;
-import org.apache.olingo.odata2.core.batch.v2.BufferedReaderIncludingLineEndings;
 import org.apache.olingo.odata2.testutil.helper.StringHelper;
 import org.junit.BeforeClass;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterTest.java
index 704e0aa..5be59ae 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -34,9 +33,8 @@ import org.apache.olingo.odata2.api.client.batch.BatchChangeSet;
 import org.apache.olingo.odata2.api.client.batch.BatchChangeSetPart;
 import org.apache.olingo.odata2.api.client.batch.BatchPart;
 import org.apache.olingo.odata2.api.client.batch.BatchQueryPart;
-import org.apache.olingo.odata2.core.batch.v2.BufferedReaderIncludingLineEndings;
+import org.apache.olingo.odata2.core.batch.v2.BatchLineReader;
 import org.apache.olingo.odata2.core.batch.v2.Line;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class BatchRequestWriterTest {
@@ -58,8 +56,8 @@ public class BatchRequestWriterTest {
     BatchRequestWriter writer = new BatchRequestWriter();
     InputStream batchRequest = writer.writeBatchRequest(batch, BOUNDARY);
     
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchRequest);
+    BatchLineReader reader =
+        new BatchLineReader(batchRequest);
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;
@@ -93,8 +91,8 @@ public class BatchRequestWriterTest {
     BatchRequestWriter writer = new BatchRequestWriter();
     InputStream batchRequest = writer.writeBatchRequest(batch, BOUNDARY);
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchRequest);
+    BatchLineReader reader =
+        new BatchLineReader(batchRequest);
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;
@@ -134,8 +132,8 @@ public class BatchRequestWriterTest {
     BatchRequestWriter writer = new BatchRequestWriter();
     InputStream batchRequest = writer.writeBatchRequest(batch, BOUNDARY);
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchRequest);
+    BatchLineReader reader =
+        new BatchLineReader(batchRequest);
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;
@@ -175,8 +173,8 @@ public class BatchRequestWriterTest {
     BatchRequestWriter writer = new BatchRequestWriter();
     InputStream batchRequest = writer.writeBatchRequest(batch, BOUNDARY);
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchRequest);
+    BatchLineReader reader =
+        new BatchLineReader(batchRequest);
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;
@@ -221,8 +219,8 @@ public class BatchRequestWriterTest {
     BatchRequestWriter writer = new BatchRequestWriter();
     InputStream batchRequest = writer.writeBatchRequest(batch, BOUNDARY);
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchRequest);
+    BatchLineReader reader =
+        new BatchLineReader(batchRequest);
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;
@@ -268,8 +266,8 @@ public class BatchRequestWriterTest {
     BatchRequestWriter writer = new BatchRequestWriter();
     InputStream batchRequest = writer.writeBatchRequest(batch, BOUNDARY);
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchRequest);
+    BatchLineReader reader =
+        new BatchLineReader(batchRequest);
     List<Line> lines = reader.toLineList();
     reader.close();
 
@@ -328,8 +326,8 @@ public class BatchRequestWriterTest {
     BatchRequestWriter writer = new BatchRequestWriter();
     InputStream batchRequest = writer.writeBatchRequest(batch, BOUNDARY);
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchRequest);
+    BatchLineReader reader =
+        new BatchLineReader(batchRequest);
     List<Line> lines = reader.toLineList();
     reader.close();
 
@@ -395,8 +393,8 @@ public class BatchRequestWriterTest {
     BatchRequestWriter writer = new BatchRequestWriter();
     InputStream batchRequest = writer.writeBatchRequest(batch, BOUNDARY);
     
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchRequest);
+    BatchLineReader reader =
+        new BatchLineReader(batchRequest);
     List<Line> lines = reader.toLineList();
     reader.close();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseWriterTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseWriterTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseWriterTest.java
index 128f2c8..20caa1e 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseWriterTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseWriterTest.java
@@ -22,7 +22,7 @@ import org.apache.olingo.odata2.api.batch.BatchResponsePart;
 import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
 import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.core.batch.v2.BufferedReaderIncludingLineEndings;
+import org.apache.olingo.odata2.core.batch.v2.BatchLineReader;
 import org.apache.olingo.odata2.core.batch.v2.Line;
 import org.apache.olingo.odata2.testutil.helper.StringHelper;
 import org.junit.Test;
@@ -61,8 +61,8 @@ public class BatchResponseWriterTest {
     assertEquals(202, batchResponse.getStatus().getStatusCode());
     assertNotNull(batchResponse.getEntity());
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchResponse.getEntityAsStream());
+    BatchLineReader reader =
+        new BatchLineReader(batchResponse.getEntityAsStream());
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;
@@ -106,8 +106,8 @@ public class BatchResponseWriterTest {
     assertNotNull(batchResponse.getEntity());
 //    String body = (String) batchResponse.getEntity();
     
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchResponse.getEntityAsStream());
+    BatchLineReader reader =
+        new BatchLineReader(batchResponse.getEntityAsStream());
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;
@@ -138,8 +138,8 @@ public class BatchResponseWriterTest {
     assertEquals(202, batchResponse.getStatus().getStatusCode());
     assertNotNull(batchResponse.getEntity());
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchResponse.getEntityAsStream());
+    BatchLineReader reader =
+        new BatchLineReader(batchResponse.getEntityAsStream());
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;
@@ -176,8 +176,8 @@ public class BatchResponseWriterTest {
     assertEquals(202, batchResponse.getStatus().getStatusCode());
     assertNotNull(batchResponse.getEntity());
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchResponse.getEntityAsStream());
+    BatchLineReader reader =
+        new BatchLineReader(batchResponse.getEntityAsStream());
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;
@@ -214,8 +214,8 @@ public class BatchResponseWriterTest {
     assertEquals(202, batchResponse.getStatus().getStatusCode());
     assertNotNull(batchResponse.getEntity());
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchResponse.getEntityAsStream());
+    BatchLineReader reader =
+        new BatchLineReader(batchResponse.getEntityAsStream());
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;
@@ -252,8 +252,8 @@ public class BatchResponseWriterTest {
     assertNotNull(batchResponse.getEntity());
 //    String body = (String) batchResponse.getEntity();
 
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(batchResponse.getEntityAsStream());
+    BatchLineReader reader =
+        new BatchLineReader(batchResponse.getEntityAsStream());
     List<Line> lines = reader.toLineList();
     reader.close();
     int index = 0;

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchTransformatorCommonTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchTransformatorCommonTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchTransformatorCommonTest.java
deleted file mode 100644
index 3e18304..0000000
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchTransformatorCommonTest.java
+++ /dev/null
@@ -1,123 +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.odata2.core.batch;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.batch.BatchException;
-import org.apache.olingo.odata2.api.commons.HttpContentType;
-import org.apache.olingo.odata2.api.commons.HttpHeaders;
-import org.apache.olingo.odata2.core.batch.v2.BatchTransformatorCommon;
-import org.apache.olingo.odata2.core.batch.v2.Header;
-import org.junit.Test;
-
-public class BatchTransformatorCommonTest {
-
-  private static final String BASE64_ENCODING = "BASE64";
-
-  @Test
-  public void testValidateContentTypeApplicationHTTP() throws BatchException {
-    List<String> contentTypeValues = Arrays.asList(new String[] { HttpContentType.APPLICATION_HTTP });
-    final Header headers = makeHeaders(HttpHeaders.CONTENT_TYPE, contentTypeValues);
-
-    BatchTransformatorCommon.validateContentType(headers);
-  }
-
-  @Test
-  public void testValidateContentTypeMultipartMixed() throws BatchException {
-    List<String> contentTypeValues =
-        Arrays.asList(new String[] { HttpContentType.MULTIPART_MIXED + "; boundary=batch_32332_32323_fdsf" });
-    final Header headers = makeHeaders(HttpHeaders.CONTENT_TYPE, contentTypeValues);
-
-    BatchTransformatorCommon.validateContentType(headers);
-  }
-
-  @Test
-  public void testValidateContentTypeMultipartMixedCaseInsensitiv() throws BatchException {
-    List<String> contentTypeValues =
-        Arrays.asList(new String[] { "mulTiPart/MiXed; boundary=batch_32332_32323_fdsf" });
-    final Header headers = makeHeaders(HttpHeaders.CONTENT_TYPE, contentTypeValues);
-
-    BatchTransformatorCommon.validateContentType(headers);
-  }
-
-  @Test(expected = BatchException.class)
-  public void testValidateContentTypeNoValue() throws BatchException {
-    List<String> contentTypeValues = Arrays.asList(new String[] {});
-    final Header headers = makeHeaders(HttpHeaders.CONTENT_TYPE, contentTypeValues);
-
-    BatchTransformatorCommon.validateContentType(headers);
-  }
-
-  @Test(expected = BatchException.class)
-  public void testValidateContentTypeMissingHeader() throws BatchException {
-    final Header headers = new Header(1);
-    
-    BatchTransformatorCommon.validateContentType(headers);
-  }
-
-  @Test(expected = BatchException.class)
-  public void testValidateContentTypeMultipleValues() throws BatchException {
-    List<String> contentTypeValues =
-        Arrays.asList(new String[] { HttpContentType.APPLICATION_HTTP, HttpContentType.MULTIPART_MIXED });
-    final Header headers = makeHeaders(HttpHeaders.CONTENT_TYPE, contentTypeValues);
-
-    BatchTransformatorCommon.validateContentType(headers);
-  }
-
-  @Test
-  public void testValidateContentTransferEncoding() throws BatchException {
-    List<String> contentTransferEncoding = Arrays.asList(new String[] { BatchHelper.BINARY_ENCODING });
-    final Header headers = makeHeaders(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
-
-    BatchTransformatorCommon.validateContentTransferEncoding(headers, false);
-  }
-
-  @Test(expected = BatchException.class)
-  public void testValidateContentTransferEncodingMultipleValues() throws BatchException {
-    List<String> contentTransferEncoding = Arrays.asList(new String[] { BatchHelper.BINARY_ENCODING, BASE64_ENCODING });
-    final Header headers = makeHeaders(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
-
-    BatchTransformatorCommon.validateContentTransferEncoding(headers, false);
-  }
-
-  @Test(expected = BatchException.class)
-  public void testValidateContentTransferEncodingMissingHeader() throws BatchException {
-    final Header headers = new Header(1);
-    
-    BatchTransformatorCommon.validateContentTransferEncoding(headers, true);
-  }
-
-  @Test(expected = BatchException.class)
-  public void testValidateContentTransferEncodingMissingValue() throws BatchException {
-    List<String> contentTransferEncoding = Arrays.asList(new String[] {});
-    final Header headers = makeHeaders(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
-
-    BatchTransformatorCommon.validateContentTransferEncoding(headers, true);
-  }
-
-  private Header makeHeaders(final String headerName, final List<String> values) {
-    final Header headers = new Header(1);
-    headers.addHeader(headerName, values, 1);
-
-    return headers;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BufferedReaderIncludingLineEndingsTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BufferedReaderIncludingLineEndingsTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BufferedReaderIncludingLineEndingsTest.java
deleted file mode 100644
index 784ef46..0000000
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BufferedReaderIncludingLineEndingsTest.java
+++ /dev/null
@@ -1,258 +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.odata2.core.batch;
-
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-
-import org.apache.olingo.odata2.core.batch.v2.BufferedReaderIncludingLineEndings;
-import org.apache.olingo.odata2.core.batch.v2.Line;
-import org.junit.Test;
-
-public class BufferedReaderIncludingLineEndingsTest {
-
-  private static final String TEXT_COMBINED = "Test\r" +
-      "Test2\r\n" +
-      "Test3\n" +
-      "Test4\r" +
-      "\r" +
-      "\r\n" +
-      "\r\n" +
-      "Test5\n" +
-      "Test6\r\n" +
-      "Test7\n" +
-      "\n";
-
-  private static final String TEXT_SMALL = "Test\r" +
-      "123";
-  private static final String TEXT_EMPTY = "";
-
-  @Test
-  public void testSimpleText() throws IOException {
-    final String TEXT = "Test";
-    BufferedReaderIncludingLineEndings reader = create(TEXT);
-
-    assertEquals(TEXT, reader.readLine());
-    assertNull(reader.readLine());
-    assertNull(reader.readLine());
-    reader.close();
-  }
-
-  @Test
-  public void testNoText() throws IOException {
-    final String TEXT = "";
-    BufferedReaderIncludingLineEndings reader = create(TEXT);
-
-    assertNull(reader.readLine());
-    assertNull(reader.readLine());
-    reader.close();
-  }
-
-  @Test
-  public void testNoBytes() throws IOException {
-    BufferedReaderIncludingLineEndings reader =
-        new BufferedReaderIncludingLineEndings(new ByteArrayInputStream(new byte[0]));
-
-    assertNull(reader.readLine());
-    assertNull(reader.readLine());
-    reader.close();
-  }
-
-  @Test
-  public void testCRLF() throws IOException {
-    final String TEXT = "Test\r\n" +
-        "Test2";
-
-    BufferedReaderIncludingLineEndings reader = create(TEXT);
-
-    assertEquals("Test\r\n", reader.readLine());
-    assertEquals("Test2", reader.readLine());
-    assertNull(reader.readLine());
-    assertNull(reader.readLine());
-    reader.close();
-  }
-
-  @Test
-  public void testLF() throws IOException {
-    final String TEXT = "Test\n" +
-        "Test2";
-
-    BufferedReaderIncludingLineEndings reader = create(TEXT);
-
-    assertEquals("Test\n", reader.readLine());
-    assertEquals("Test2", reader.readLine());
-    assertNull(reader.readLine());
-    assertNull(reader.readLine());
-    reader.close();
-  }
-
-  @Test
-  public void testCR() throws IOException {
-    final String TEXT = "Test\r" +
-        "Test2";
-
-    BufferedReaderIncludingLineEndings reader = create(TEXT);
-
-    assertEquals("Test\r", reader.readLine());
-    assertEquals("Test2", reader.readLine());
-    assertNull(reader.readLine());
-    assertNull(reader.readLine());
-    reader.close();
-  }
-
-  @Test
-  public void testCombined() throws IOException {
-    BufferedReaderIncludingLineEndings reader = create(TEXT_COMBINED);
-
-    assertEquals("Test\r", reader.readLine());
-    assertEquals("Test2\r\n", reader.readLine());
-    assertEquals("Test3\n", reader.readLine());
-    assertEquals("Test4\r", reader.readLine());
-    assertEquals("\r", reader.readLine());
-    assertEquals("\r\n", reader.readLine());
-    assertEquals("\r\n", reader.readLine());
-    assertEquals("Test5\n", reader.readLine());
-    assertEquals("Test6\r\n", reader.readLine());
-    assertEquals("Test7\n", reader.readLine());
-    assertEquals("\n", reader.readLine());
-    assertNull(reader.readLine());
-    assertNull(reader.readLine());
-    reader.close();
-  }
-
-  @Test
-  public void testCombinedBufferSizeTwo() throws IOException {
-    BufferedReaderIncludingLineEndings reader = create(TEXT_COMBINED, 2);
-
-    assertEquals("Test\r", reader.readLine());
-    assertEquals("Test2\r\n", reader.readLine());
-    assertEquals("Test3\n", reader.readLine());
-    assertEquals("Test4\r", reader.readLine());
-    assertEquals("\r", reader.readLine());
-    assertEquals("\r\n", reader.readLine());
-    assertEquals("\r\n", reader.readLine());
-    assertEquals("Test5\n", reader.readLine());
-    assertEquals("Test6\r\n", reader.readLine());
-    assertEquals("Test7\n", reader.readLine());
-    assertEquals("\n", reader.readLine());
-    assertNull(reader.readLine());
-    assertNull(reader.readLine());
-    reader.close();
-  }
-
-  @Test
-  public void testCombinedBufferSizeOne() throws IOException {
-    final String TEXT = "Test\r" +
-        "Test2\r\n" +
-        "Test3\n" +
-        "Test4\r" +
-        "\r" +
-        "\r\n" +
-        "\r\n" +
-        "Test5\n" +
-        "Test6\r\n" +
-        "Test7\n" +
-        "\r\n";
-
-    BufferedReaderIncludingLineEndings reader = create(TEXT, 1);
-
-    assertEquals("Test\r", reader.readLine());
-    assertEquals("Test2\r\n", reader.readLine());
-    assertEquals("Test3\n", reader.readLine());
-    assertEquals("Test4\r", reader.readLine());
-    assertEquals("\r", reader.readLine());
-    assertEquals("\r\n", reader.readLine());
-    assertEquals("\r\n", reader.readLine());
-    assertEquals("Test5\n", reader.readLine());
-    assertEquals("Test6\r\n", reader.readLine());
-    assertEquals("Test7\n", reader.readLine());
-    assertEquals("\r\n", reader.readLine());
-    assertNull(reader.readLine());
-    assertNull(reader.readLine());
-
-    reader.close();
-  }
-
-  @Test
-  public void testDoubleLF() throws IOException {
-    final String TEXT = "Test\r" +
-        "\r";
-
-    BufferedReaderIncludingLineEndings reader = create(TEXT, 1);
-
-    assertEquals("Test\r", reader.readLine());
-    assertEquals("\r", reader.readLine());
-    reader.close();
-  }
-
-
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testFailBufferSizeZero() throws IOException {
-    BufferedReaderIncludingLineEndings reader = create(TEXT_EMPTY, 0);
-    reader.close();
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testInputStreamIsNull() throws IOException {
-    // Same behaviour like BufferedReader
-    BufferedReaderIncludingLineEndings reader = new BufferedReaderIncludingLineEndings(null);
-    reader.close();
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testFailBufferSizeNegative() throws IOException {
-    BufferedReaderIncludingLineEndings reader = create(TEXT_EMPTY, -1);
-    reader.close();
-  }
-
-  @Test
-  public void testToList() throws IOException {
-    BufferedReaderIncludingLineEndings reader = create(TEXT_COMBINED);
-    List<Line> stringList = reader.toLineList();
-
-    assertEquals(11, stringList.size());
-    assertEquals("Test\r", stringList.get(0).toString());
-    assertEquals("Test2\r\n", stringList.get(1).toString());
-    assertEquals("Test3\n", stringList.get(2).toString());
-    assertEquals("Test4\r", stringList.get(3).toString());
-    assertEquals("\r", stringList.get(4).toString());
-    assertEquals("\r\n", stringList.get(5).toString());
-    assertEquals("\r\n", stringList.get(6).toString());
-    assertEquals("Test5\n", stringList.get(7).toString());
-    assertEquals("Test6\r\n", stringList.get(8).toString());
-    assertEquals("Test7\n", stringList.get(9).toString());
-    assertEquals("\n", stringList.get(10).toString());
-    reader.close();
-  }
-
-  private BufferedReaderIncludingLineEndings create(final String inputString) throws UnsupportedEncodingException {
-    return new BufferedReaderIncludingLineEndings(new ByteArrayInputStream(inputString.getBytes("UTF-8")));
-  }
-
-  private BufferedReaderIncludingLineEndings create(final String inputString, int bufferSize)
-      throws UnsupportedEncodingException {
-    return new BufferedReaderIncludingLineEndings(new ByteArrayInputStream(inputString.getBytes("UTF-8")), bufferSize);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/HeaderTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/HeaderTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/HeaderTest.java
deleted file mode 100644
index e630a54..0000000
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/HeaderTest.java
+++ /dev/null
@@ -1,179 +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.odata2.core.batch;
-
-import static org.junit.Assert.*;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.commons.HttpContentType;
-import org.apache.olingo.odata2.api.commons.HttpHeaders;
-import org.apache.olingo.odata2.core.batch.v2.BatchParserCommon;
-import org.apache.olingo.odata2.core.batch.v2.Header;
-import org.junit.Test;
-
-public class HeaderTest {
-
-  @Test
-  public void test() {
-    Header header = new Header(1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
-
-    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeader(HttpHeaders.CONTENT_TYPE));
-    assertEquals(1, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
-    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(0));
-  }
-
-  @Test
-  public void testNotAvailable() {
-    Header header = new Header(1);
-
-    assertNull(header.getHeader(HttpHeaders.CONTENT_TYPE));
-    assertEquals(0, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
-    assertEquals("", header.getHeaderNotNull(HttpHeaders.CONTENT_TYPE));
-  }
-
-  @Test
-  public void testCaseInsensitive() {
-    Header header = new Header(1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
-
-    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeader("cOnTenT-TyPE"));
-    assertEquals(1, header.getHeaders("cOnTenT-TyPE").size());
-    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeaders("cOnTenT-TyPE").get(0));
-  }
-
-  @Test
-  public void testDuplicatedAdd() {
-    Header header = new Header(1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 2);
-
-    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeader(HttpHeaders.CONTENT_TYPE));
-    assertEquals(1, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
-    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(0));
-  }
-
-  @Test
-  public void testMatcher() {
-    Header header = new Header(1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED + ";boundary=123", 1);
-
-    assertTrue(header.isHeaderMatching(HttpHeaders.CONTENT_TYPE, BatchParserCommon.PATTERN_MULTIPART_MIXED));
-  }
-
-  @Test
-  public void testFieldName() {
-    Header header = new Header(0);
-    header.addHeader("MyFieldNamE", "myValue", 1);
-
-    assertEquals("MyFieldNamE", header.getHeaderField("myfieldname").getFieldName());
-    assertEquals("MyFieldNamE", header.toSingleMap().keySet().toArray(new String[0])[0]);
-    assertEquals("MyFieldNamE", header.toMultiMap().keySet().toArray(new String[0])[0]);
-
-    assertEquals("myValue", header.toMultiMap().get("MyFieldNamE").get(0));
-    assertEquals("myValue", header.toSingleMap().get("MyFieldNamE"));
-  }
-
-  @Test
-  public void testDeepCopy() {
-    Header header = new Header(1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED + ";boundary=123", 1);
-
-    Header copy = header.clone();
-    assertEquals(header.getHeaders(HttpHeaders.CONTENT_TYPE), copy.getHeaders(HttpHeaders.CONTENT_TYPE));
-    assertEquals(header.getHeader(HttpHeaders.CONTENT_TYPE), copy.getHeader(HttpHeaders.CONTENT_TYPE));
-    assertEquals(header.getHeaderField(HttpHeaders.CONTENT_TYPE), copy.getHeaderField(HttpHeaders.CONTENT_TYPE));
-
-    assertTrue(header.getHeaders(HttpHeaders.CONTENT_TYPE) != copy.getHeaders(HttpHeaders.CONTENT_TYPE));
-    assertTrue(header.getHeaderField(HttpHeaders.CONTENT_TYPE) != copy.getHeaderField(HttpHeaders.CONTENT_TYPE));
-  }
-
-  @Test
-  public void testMatcherNoHeader() {
-    Header header = new Header(1);
-
-    assertFalse(header.isHeaderMatching(HttpHeaders.CONTENT_TYPE,  BatchParserCommon.PATTERN_MULTIPART_MIXED));
-  }
-
-  @Test
-  public void testMatcherFail() {
-    Header header = new Header(1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED + ";boundary=123", 1);
-
-    assertFalse(header.isHeaderMatching(HttpHeaders.CONTENT_TYPE, BatchParserCommon.PATTERN_HEADER_LINE));
-  }
-
-  @Test
-  public void testDuplicatedAddList() {
-    Header header = new Header(1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, Arrays.asList(new String[] { HttpContentType.MULTIPART_MIXED,
-        HttpContentType.APPLICATION_ATOM_SVC }), 2);
-
-    assertEquals(HttpContentType.MULTIPART_MIXED + ", " + HttpContentType.APPLICATION_ATOM_SVC, header
-        .getHeader(HttpHeaders.CONTENT_TYPE));
-    assertEquals(2, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
-    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(0));
-    assertEquals(HttpContentType.APPLICATION_ATOM_SVC, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(1));
-  }
-
-  @Test
-  public void testRemove() {
-    Header header = new Header(1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
-    header.removeHeader(HttpHeaders.CONTENT_TYPE);
-
-    assertNull(header.getHeader(HttpHeaders.CONTENT_TYPE));
-    assertEquals(0, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
-  }
-
-  @Test
-  public void testMultipleValues() {
-    Header header = new Header(1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.MULTIPART_MIXED, 1);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.APPLICATION_ATOM_SVC, 2);
-    header.addHeader(HttpHeaders.CONTENT_TYPE, HttpContentType.APPLICATION_ATOM_XML, 3);
-
-    final String fullHeaderString =
-        HttpContentType.MULTIPART_MIXED + ", " + HttpContentType.APPLICATION_ATOM_SVC + ", "
-            + HttpContentType.APPLICATION_ATOM_XML;
-
-    assertEquals(fullHeaderString, header.getHeader(HttpHeaders.CONTENT_TYPE));
-    assertEquals(3, header.getHeaders(HttpHeaders.CONTENT_TYPE).size());
-    assertEquals(HttpContentType.MULTIPART_MIXED, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(0));
-    assertEquals(HttpContentType.APPLICATION_ATOM_SVC, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(1));
-    assertEquals(HttpContentType.APPLICATION_ATOM_XML, header.getHeaders(HttpHeaders.CONTENT_TYPE).get(2));
-  }
-  
-  @Test
-  public void testSplitValues() {
-    final String values = "abc, def,123,77,   99, ysd";
-    List<String> splittedValues = Header.splitValuesByComma(values);
-
-    assertEquals(6, splittedValues.size());
-    assertEquals("abc", splittedValues.get(0));
-    assertEquals("def", splittedValues.get(1));
-    assertEquals("123", splittedValues.get(2));
-    assertEquals("77", splittedValues.get(3));
-    assertEquals("99", splittedValues.get(4));
-    assertEquals("ysd", splittedValues.get(5));
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchLineReaderTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchLineReaderTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchLineReaderTest.java
new file mode 100644
index 0000000..a734dd1
--- /dev/null
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchLineReaderTest.java
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * 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.odata2.core.batch.v2;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import org.apache.olingo.odata2.core.batch.v2.BatchLineReader;
+import org.apache.olingo.odata2.core.batch.v2.Line;
+import org.junit.Test;
+
+public class BatchLineReaderTest {
+
+  private static final String TEXT_COMBINED = "Test\r" +
+      "Test2\r\n" +
+      "Test3\n" +
+      "Test4\r" +
+      "\r" +
+      "\r\n" +
+      "\r\n" +
+      "Test5\n" +
+      "Test6\r\n" +
+      "Test7\n" +
+      "\n";
+
+  private static final String TEXT_EMPTY = "";
+
+  @Test
+  public void testSimpleText() throws IOException {
+    final String TEXT = "Test";
+    BatchLineReader reader = create(TEXT);
+
+    assertEquals(TEXT, reader.readLine());
+    assertNull(reader.readLine());
+    assertNull(reader.readLine());
+    reader.close();
+  }
+
+  @Test
+  public void testNoText() throws IOException {
+    final String TEXT = "";
+    BatchLineReader reader = create(TEXT);
+
+    assertNull(reader.readLine());
+    assertNull(reader.readLine());
+    reader.close();
+  }
+
+  @Test
+  public void testNoBytes() throws IOException {
+    BatchLineReader reader =
+        new BatchLineReader(new ByteArrayInputStream(new byte[0]));
+
+    assertNull(reader.readLine());
+    assertNull(reader.readLine());
+    reader.close();
+  }
+
+  @Test
+  public void testCRLF() throws IOException {
+    final String TEXT = "Test\r\n" +
+        "Test2";
+
+    BatchLineReader reader = create(TEXT);
+
+    assertEquals("Test\r\n", reader.readLine());
+    assertEquals("Test2", reader.readLine());
+    assertNull(reader.readLine());
+    assertNull(reader.readLine());
+    reader.close();
+  }
+
+  @Test
+  public void testLF() throws IOException {
+    final String TEXT = "Test\n" +
+        "Test2";
+
+    BatchLineReader reader = create(TEXT);
+
+    assertEquals("Test\n", reader.readLine());
+    assertEquals("Test2", reader.readLine());
+    assertNull(reader.readLine());
+    assertNull(reader.readLine());
+    reader.close();
+  }
+
+  @Test
+  public void testCR() throws IOException {
+    final String TEXT = "Test\r" +
+        "Test2";
+
+    BatchLineReader reader = create(TEXT);
+
+    assertEquals("Test\r", reader.readLine());
+    assertEquals("Test2", reader.readLine());
+    assertNull(reader.readLine());
+    assertNull(reader.readLine());
+    reader.close();
+  }
+
+  @Test
+  public void testCombined() throws IOException {
+    BatchLineReader reader = create(TEXT_COMBINED);
+
+    assertEquals("Test\r", reader.readLine());
+    assertEquals("Test2\r\n", reader.readLine());
+    assertEquals("Test3\n", reader.readLine());
+    assertEquals("Test4\r", reader.readLine());
+    assertEquals("\r", reader.readLine());
+    assertEquals("\r\n", reader.readLine());
+    assertEquals("\r\n", reader.readLine());
+    assertEquals("Test5\n", reader.readLine());
+    assertEquals("Test6\r\n", reader.readLine());
+    assertEquals("Test7\n", reader.readLine());
+    assertEquals("\n", reader.readLine());
+    assertNull(reader.readLine());
+    assertNull(reader.readLine());
+    reader.close();
+  }
+
+  @Test
+  public void testCombinedBufferSizeTwo() throws IOException {
+    BatchLineReader reader = create(TEXT_COMBINED, 2);
+
+    assertEquals("Test\r", reader.readLine());
+    assertEquals("Test2\r\n", reader.readLine());
+    assertEquals("Test3\n", reader.readLine());
+    assertEquals("Test4\r", reader.readLine());
+    assertEquals("\r", reader.readLine());
+    assertEquals("\r\n", reader.readLine());
+    assertEquals("\r\n", reader.readLine());
+    assertEquals("Test5\n", reader.readLine());
+    assertEquals("Test6\r\n", reader.readLine());
+    assertEquals("Test7\n", reader.readLine());
+    assertEquals("\n", reader.readLine());
+    assertNull(reader.readLine());
+    assertNull(reader.readLine());
+    reader.close();
+  }
+
+  @Test
+  public void testCombinedBufferSizeOne() throws IOException {
+    final String TEXT = "Test\r" +
+        "Test2\r\n" +
+        "Test3\n" +
+        "Test4\r" +
+        "\r" +
+        "\r\n" +
+        "\r\n" +
+        "Test5\n" +
+        "Test6\r\n" +
+        "Test7\n" +
+        "\r\n";
+
+    BatchLineReader reader = create(TEXT, 1);
+
+    assertEquals("Test\r", reader.readLine());
+    assertEquals("Test2\r\n", reader.readLine());
+    assertEquals("Test3\n", reader.readLine());
+    assertEquals("Test4\r", reader.readLine());
+    assertEquals("\r", reader.readLine());
+    assertEquals("\r\n", reader.readLine());
+    assertEquals("\r\n", reader.readLine());
+    assertEquals("Test5\n", reader.readLine());
+    assertEquals("Test6\r\n", reader.readLine());
+    assertEquals("Test7\n", reader.readLine());
+    assertEquals("\r\n", reader.readLine());
+    assertNull(reader.readLine());
+    assertNull(reader.readLine());
+
+    reader.close();
+  }
+
+  @Test
+  public void testDoubleLF() throws IOException {
+    final String TEXT = "Test\r" +
+        "\r";
+
+    BatchLineReader reader = create(TEXT, 1);
+
+    assertEquals("Test\r", reader.readLine());
+    assertEquals("\r", reader.readLine());
+    reader.close();
+  }
+
+
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testFailBufferSizeZero() throws IOException {
+    BatchLineReader reader = create(TEXT_EMPTY, 0);
+    reader.close();
+  }
+
+  @Test(expected = NullPointerException.class)
+  public void testInputStreamIsNull() throws IOException {
+    // Same behaviour like BufferedReader
+    BatchLineReader reader = new BatchLineReader(null);
+    reader.close();
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testFailBufferSizeNegative() throws IOException {
+    BatchLineReader reader = create(TEXT_EMPTY, -1);
+    reader.close();
+  }
+
+  @Test
+  public void testToList() throws IOException {
+    BatchLineReader reader = create(TEXT_COMBINED);
+    List<Line> stringList = reader.toLineList();
+
+    assertEquals(11, stringList.size());
+    assertEquals("Test\r", stringList.get(0).toString());
+    assertEquals("Test2\r\n", stringList.get(1).toString());
+    assertEquals("Test3\n", stringList.get(2).toString());
+    assertEquals("Test4\r", stringList.get(3).toString());
+    assertEquals("\r", stringList.get(4).toString());
+    assertEquals("\r\n", stringList.get(5).toString());
+    assertEquals("\r\n", stringList.get(6).toString());
+    assertEquals("Test5\n", stringList.get(7).toString());
+    assertEquals("Test6\r\n", stringList.get(8).toString());
+    assertEquals("Test7\n", stringList.get(9).toString());
+    assertEquals("\n", stringList.get(10).toString());
+    reader.close();
+  }
+
+  private BatchLineReader create(final String inputString) throws UnsupportedEncodingException {
+    return new BatchLineReader(new ByteArrayInputStream(inputString.getBytes("UTF-8")));
+  }
+
+  private BatchLineReader create(final String inputString, int bufferSize)
+      throws UnsupportedEncodingException {
+    return new BatchLineReader(new ByteArrayInputStream(inputString.getBytes("UTF-8")), bufferSize);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchParserCommonTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchParserCommonTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchParserCommonTest.java
new file mode 100644
index 0000000..95d7dc5
--- /dev/null
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchParserCommonTest.java
@@ -0,0 +1,231 @@
+/*******************************************************************************
+ * 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.odata2.core.batch.v2;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.batch.BatchException;
+import org.apache.olingo.odata2.api.commons.HttpHeaders;
+import org.apache.olingo.odata2.core.batch.BatchHelper;
+import org.apache.olingo.odata2.core.batch.v2.BatchParserCommon;
+import org.apache.olingo.odata2.core.batch.v2.Header;
+import org.apache.olingo.odata2.core.batch.v2.Line;
+import org.junit.Test;
+
+public class BatchParserCommonTest {
+  
+  private static final String CRLF = "\r\n";
+  
+  @Test
+  public void testMultipleHeader() throws BatchException {
+    String[] messageRaw = new String[] {
+        "Content-Id: 1" + CRLF,
+        "Content-Id: 2" + CRLF,
+        "content-type: Application/http" + CRLF,
+        "content-transfer-encoding: Binary" + CRLF
+      };
+    List<Line> message = toLineList(messageRaw);
+    
+    final Header header = BatchParserCommon.consumeHeaders(message);
+    assertNotNull(header);
+    
+    final List<String> contentIdHeaders = header.getHeaders(BatchHelper.HTTP_CONTENT_ID);
+    assertNotNull(contentIdHeaders);
+    assertEquals(2, contentIdHeaders.size());
+    assertEquals("1", contentIdHeaders.get(0));
+    assertEquals("2", contentIdHeaders.get(1));
+  }
+  
+  @Test
+  public void testMultipleHeaderSameValue() throws BatchException {
+    String[] messageRaw = new String[] {
+        "Content-Id: 1" + CRLF,
+        "Content-Id: 1" + CRLF,
+        "content-type: Application/http" + CRLF,
+        "content-transfer-encoding: Binary" + CRLF
+      };
+    List<Line> message = toLineList(messageRaw);
+    
+    final Header header = BatchParserCommon.consumeHeaders(message);
+    assertNotNull(header);
+    
+    final List<String> contentIdHeaders = header.getHeaders(BatchHelper.HTTP_CONTENT_ID);
+    assertNotNull(contentIdHeaders);
+    assertEquals(1, contentIdHeaders.size());
+    assertEquals("1", contentIdHeaders.get(0));
+  }
+  
+  @Test
+  public void testHeaderSperatedByComma() throws BatchException {
+    String[] messageRaw = new String[] {
+        "Content-Id: 1" + CRLF,
+        "Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11" + CRLF,
+        "content-type: Application/http" + CRLF,
+        "content-transfer-encoding: Binary" + CRLF
+      };
+    List<Line> message = toLineList(messageRaw);
+    
+    final Header header = BatchParserCommon.consumeHeaders(message);
+    assertNotNull(header);
+    
+    final List<String> upgradeHeader = header.getHeaders("upgrade");
+    assertNotNull(upgradeHeader);
+    assertEquals(4, upgradeHeader.size());
+    assertEquals("HTTP/2.0", upgradeHeader.get(0));
+    assertEquals("SHTTP/1.3", upgradeHeader.get(1));
+    assertEquals("IRC/6.9", upgradeHeader.get(2));
+    assertEquals("RTA/x11", upgradeHeader.get(3));
+  }
+  
+  @Test
+  public void testMultipleAcceptHeader() throws BatchException {
+    String[] messageRaw = new String[] {
+        "Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1" + CRLF,
+        "Accept: text/plain;q=0.3" + CRLF,
+        "Accept-Language:en-US,en;q=0.7,en-UK;q=0.9" + CRLF,
+        "content-type: Application/http" + CRLF,
+        "content-transfer-encoding: Binary" + CRLF
+      };
+    List<Line> message = toLineList(messageRaw);
+    
+    final Header header = BatchParserCommon.consumeHeaders(message);
+    assertNotNull(header);
+    
+    final List<String> acceptHeader = header.getHeaders(HttpHeaders.ACCEPT);
+    assertNotNull(acceptHeader);
+    assertEquals(4, acceptHeader.size());
+  }
+  
+  @Test
+  public void testMultipleAcceptHeaderSameValue() throws BatchException {
+    String[] messageRaw = new String[] {
+        "Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1" + CRLF,
+        "Accept: application/atomsvc+xml;q=0.8" + CRLF,
+        "Accept-Language:en-US,en;q=0.7,en-UK;q=0.9" + CRLF,
+        "content-type: Application/http" + CRLF,
+        "content-transfer-encoding: Binary" + CRLF
+      };
+    List<Line> message = toLineList(messageRaw);
+    
+    final Header header = BatchParserCommon.consumeHeaders(message);
+    assertNotNull(header);
+    
+    final List<String> acceptHeader = header.getHeaders(HttpHeaders.ACCEPT);
+    assertNotNull(acceptHeader);
+    assertEquals(3, acceptHeader.size());
+  }
+  
+  @Test
+  public void testMultipleAccepLanguagetHeader() throws BatchException {
+    String[] messageRaw = new String[] {
+        "Accept-Language:en-US,en;q=0.7,en-UK;q=0.9" + CRLF,
+        "Accept-Language: de-DE;q=0.3" + CRLF,
+        "content-type: Application/http" + CRLF,
+        "content-transfer-encoding: Binary" + CRLF
+      };
+    List<Line> message = toLineList(messageRaw);
+    
+    final Header header = BatchParserCommon.consumeHeaders(message);
+    assertNotNull(header);
+    
+    final List<String> acceptLanguageHeader = header.getHeaders(HttpHeaders.ACCEPT_LANGUAGE);
+    assertNotNull(acceptLanguageHeader);
+    assertEquals(4, acceptLanguageHeader.size());
+  }
+  
+  @Test
+  public void testMultipleAccepLanguagetHeaderSameValue() throws BatchException {
+    String[] messageRaw = new String[] {
+        "Accept-Language:en-US,en;q=0.7,en-UK;q=0.9" + CRLF,
+        "Accept-Language:en-US,en;q=0.7" + CRLF,
+        "content-type: Application/http" + CRLF,
+        "content-transfer-encoding: Binary" + CRLF
+      };
+    List<Line> message = toLineList(messageRaw);
+    
+    final Header header = BatchParserCommon.consumeHeaders(message);
+    assertNotNull(header);
+    
+    final List<String> acceptLanguageHeader = header.getHeaders(HttpHeaders.ACCEPT_LANGUAGE);
+    assertNotNull(acceptLanguageHeader);
+    assertEquals(3, acceptLanguageHeader.size());
+  }
+  
+  @Test
+  public void testRemoveEndingCRLF() {
+    String line = "Test\r\n";
+    assertEquals("Test", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
+  }
+
+  @Test
+  public void testRemoveLastEndingCRLF() {
+    String line = "Test\r\n\r\n";
+    assertEquals("Test\r\n", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
+  }
+
+  @Test
+  public void testRemoveEndingCRLFWithWS() {
+    String line = "Test\r\n            ";
+    assertEquals("Test", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
+  }
+
+  @Test
+  public void testRemoveEndingCRLFNothingToRemove() {
+    String line = "Hallo\r\nBla";
+    assertEquals("Hallo\r\nBla", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
+  }
+
+  @Test
+  public void testRemoveEndingCRLFAll() {
+    String line = "\r\n";
+    assertEquals("", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
+  }
+
+  @Test
+  public void testRemoveEndingCRLFSpace() {
+    String line = "\r\n                      ";
+    assertEquals("", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
+  }
+
+  @Test
+  public void testRemoveLastEndingCRLFWithWS() {
+    String line = "Test            \r\n";
+    assertEquals("Test            ", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
+  }
+
+  @Test
+  public void testRemoveLastEndingCRLFWithWSLong() {
+    String line = "Test            \r\nTest2    \r\n";
+    assertEquals("Test            \r\nTest2    ", BatchParserCommon.removeEndingCRLF(new Line(line,1)).toString());
+  }
+  
+  private List<Line> toLineList(String[] messageRaw) {
+    final List<Line> lineList = new ArrayList<Line>();
+    int counter = 1;
+    
+    for(final String currentLine : messageRaw) {
+      lineList.add(new Line(currentLine, counter++));
+    }
+    
+    return lineList;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a9af4008/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchTransformatorCommonTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchTransformatorCommonTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchTransformatorCommonTest.java
new file mode 100644
index 0000000..3da4328
--- /dev/null
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/v2/BatchTransformatorCommonTest.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.odata2.core.batch.v2;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.batch.BatchException;
+import org.apache.olingo.odata2.api.commons.HttpContentType;
+import org.apache.olingo.odata2.api.commons.HttpHeaders;
+import org.apache.olingo.odata2.core.batch.BatchHelper;
+import org.apache.olingo.odata2.core.batch.v2.BatchTransformatorCommon;
+import org.apache.olingo.odata2.core.batch.v2.Header;
+import org.junit.Test;
+
+public class BatchTransformatorCommonTest {
+
+  private static final String BASE64_ENCODING = "BASE64";
+
+  @Test
+  public void testValidateContentTypeApplicationHTTP() throws BatchException {
+    List<String> contentTypeValues = Arrays.asList(new String[] { HttpContentType.APPLICATION_HTTP });
+    final Header headers = makeHeaders(HttpHeaders.CONTENT_TYPE, contentTypeValues);
+
+    BatchTransformatorCommon.validateContentType(headers);
+  }
+
+  @Test
+  public void testValidateContentTypeMultipartMixed() throws BatchException {
+    List<String> contentTypeValues =
+        Arrays.asList(new String[] { HttpContentType.MULTIPART_MIXED + "; boundary=batch_32332_32323_fdsf" });
+    final Header headers = makeHeaders(HttpHeaders.CONTENT_TYPE, contentTypeValues);
+
+    BatchTransformatorCommon.validateContentType(headers);
+  }
+
+  @Test
+  public void testValidateContentTypeMultipartMixedCaseInsensitiv() throws BatchException {
+    List<String> contentTypeValues =
+        Arrays.asList(new String[] { "mulTiPart/MiXed; boundary=batch_32332_32323_fdsf" });
+    final Header headers = makeHeaders(HttpHeaders.CONTENT_TYPE, contentTypeValues);
+
+    BatchTransformatorCommon.validateContentType(headers);
+  }
+
+  @Test(expected = BatchException.class)
+  public void testValidateContentTypeNoValue() throws BatchException {
+    List<String> contentTypeValues = Arrays.asList(new String[] {});
+    final Header headers = makeHeaders(HttpHeaders.CONTENT_TYPE, contentTypeValues);
+
+    BatchTransformatorCommon.validateContentType(headers);
+  }
+
+  @Test(expected = BatchException.class)
+  public void testValidateContentTypeMissingHeader() throws BatchException {
+    final Header headers = new Header(1);
+    
+    BatchTransformatorCommon.validateContentType(headers);
+  }
+
+  @Test(expected = BatchException.class)
+  public void testValidateContentTypeMultipleValues() throws BatchException {
+    List<String> contentTypeValues =
+        Arrays.asList(new String[] { HttpContentType.APPLICATION_HTTP, HttpContentType.MULTIPART_MIXED });
+    final Header headers = makeHeaders(HttpHeaders.CONTENT_TYPE, contentTypeValues);
+
+    BatchTransformatorCommon.validateContentType(headers);
+  }
+
+  @Test
+  public void testValidateContentTransferEncoding() throws BatchException {
+    List<String> contentTransferEncoding = Arrays.asList(new String[] { BatchHelper.BINARY_ENCODING });
+    final Header headers = makeHeaders(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
+
+    BatchTransformatorCommon.validateContentTransferEncoding(headers, false);
+  }
+
+  @Test(expected = BatchException.class)
+  public void testValidateContentTransferEncodingMultipleValues() throws BatchException {
+    List<String> contentTransferEncoding = Arrays.asList(new String[] { BatchHelper.BINARY_ENCODING, BASE64_ENCODING });
+    final Header headers = makeHeaders(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
+
+    BatchTransformatorCommon.validateContentTransferEncoding(headers, false);
+  }
+
+  @Test(expected = BatchException.class)
+  public void testValidateContentTransferEncodingMissingHeader() throws BatchException {
+    final Header headers = new Header(1);
+    
+    BatchTransformatorCommon.validateContentTransferEncoding(headers, true);
+  }
+
+  @Test(expected = BatchException.class)
+  public void testValidateContentTransferEncodingMissingValue() throws BatchException {
+    List<String> contentTransferEncoding = Arrays.asList(new String[] {});
+    final Header headers = makeHeaders(BatchHelper.HTTP_CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
+
+    BatchTransformatorCommon.validateContentTransferEncoding(headers, true);
+  }
+
+  private Header makeHeaders(final String headerName, final List<String> values) {
+    final Header headers = new Header(1);
+    headers.addHeader(headerName, values, 1);
+
+    return headers;
+  }
+
+}