This is an automated email from the ASF dual-hosted git repository. aldettinger pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 29bd4c2 Fixed the camel-servlet build reproducibility 29bd4c2 is described below commit 29bd4c25ad13f2d01c5fe33fc4016b87797e2176 Author: aldettinger <aldettin...@gmail.com> AuthorDate: Mon Jun 29 10:49:15 2020 +0200 Fixed the camel-servlet build reproducibility --- .../org/apache/camel/component/servlet/HttpClientRouteTest.java | 6 ++++-- .../camel/component/servlet/ServletCamelRouterTestSupport.java | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java index 878390a..c4f82ff 100644 --- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java +++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java @@ -17,6 +17,8 @@ package org.apache.camel.component.servlet; import java.io.ByteArrayInputStream; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -92,7 +94,7 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport { new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8"); WebResponse response = query(req, false); assertEquals("OK", response.getResponseMessage(), "The response message is wrong"); - assertEquals(UNICODE_TEXT, response.getText(), "The response body is wrong"); + assertEquals(UNICODE_TEXT, response.getText(StandardCharsets.UTF_8), "The response body is wrong"); } @Test @@ -101,7 +103,7 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport { new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8"); WebResponse response = query(req, false); assertEquals("OK", response.getResponseMessage(), "The response message is wrong"); - assertEquals(UNICODE_TEXT, response.getText(), "The response body is wrong"); + assertEquals(UNICODE_TEXT, response.getText(StandardCharsets.UTF_8), "The response body is wrong"); } @Test diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java index c45a621..26f7892 100644 --- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java +++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java @@ -22,6 +22,7 @@ import java.io.InputStream; import java.lang.reflect.Field; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; @@ -207,12 +208,12 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport { return con.getResponseCode(); } - public String getText() throws IOException { + public String getText(Charset charset) throws IOException { if (text == null) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOHelper.copy(con.getInputStream(), baos); - text = baos.toString(); + text = baos.toString(charset.name()); } catch (IOException e) { text = "Exception"; } @@ -220,6 +221,10 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport { return text; } + public String getText() throws IOException { + return getText(Charset.defaultCharset()); + } + public String getContentType() { String content = con.getContentType(); return content != null && content.contains(";")