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 2014/08/06 09:06:28 UTC
git commit: [OLINGO-394] Made test stable for different environments
Repository: olingo-odata2
Updated Branches:
refs/heads/master 6fd6f064d -> d9e90388f
[OLINGO-394] Made test stable for different environments
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/d9e90388
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/d9e90388
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/d9e90388
Branch: refs/heads/master
Commit: d9e90388f27c3b673bbc511aa4315f154ba18f11
Parents: 6fd6f06
Author: Michael Bolz <mi...@apache.org>
Authored: Wed Aug 6 09:05:56 2014 +0200
Committer: Michael Bolz <mi...@apache.org>
Committed: Wed Aug 6 09:05:56 2014 +0200
----------------------------------------------------------------------
.../odata2/core/batch/BatchResponseParserTest.java | 3 ++-
.../odata2/testutil/helper/StringHelper.java | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/d9e90388/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseParserTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseParserTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseParserTest.java
index 23e4cf3..f7e4602 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseParserTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchResponseParserTest.java
@@ -31,6 +31,7 @@ import org.apache.olingo.odata2.api.client.batch.BatchSingleResponse;
import org.apache.olingo.odata2.api.commons.HttpContentType;
import org.apache.olingo.odata2.api.commons.HttpHeaders;
import org.apache.olingo.odata2.api.ep.EntityProvider;
+import org.apache.olingo.odata2.testutil.helper.StringHelper;
import org.junit.Test;
public class BatchResponseParserTest {
@@ -74,7 +75,7 @@ public class BatchResponseParserTest {
throw new IOException("Requested file '" + fileName + "' was not found.");
}
BatchResponseParser parser = new BatchResponseParser("multipart/mixed;boundary=batch_123");
- List<BatchSingleResponse> responses = parser.parse(in);
+ List<BatchSingleResponse> responses = parser.parse(StringHelper.toStream(in).asStreamWithLineSeparation("\r\n"));
for (BatchSingleResponse response : responses) {
if ("1".equals(response.getContentId())) {
assertEquals("204", response.getStatusCode());
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/d9e90388/odata2-lib/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/helper/StringHelper.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/helper/StringHelper.java b/odata2-lib/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/helper/StringHelper.java
index 2ef1c6c..f47bde6 100644
--- a/odata2-lib/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/helper/StringHelper.java
+++ b/odata2-lib/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/helper/StringHelper.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.Random;
@@ -72,6 +73,22 @@ public class StringHelper {
return print(System.out);
}
+ public String asStringWithLineSeparation(String separator) throws IOException {
+ BufferedReader br = new BufferedReader(new StringReader(asString()));
+ StringBuilder sb = new StringBuilder(br.readLine());
+ String line = br.readLine();
+ while(line != null) {
+ sb.append(separator).append(line);
+ line = br.readLine();
+ }
+ return sb.toString();
+ }
+
+ public InputStream asStreamWithLineSeparation(String separator) throws IOException {
+ String asString = asStringWithLineSeparation(separator);
+ return new ByteArrayInputStream(asString.getBytes("UTF-8"));
+ }
+
/**
* Number of lines separated by line breaks (<code>CRLF</code>).
* A content string like <code>text\r\nmoreText</code> will result in