From cc0edcb9017f07c883cd2af506ffd4185c0a40aa Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 23 Sep 2015 22:19:45 +0100 Subject: [PATCH] =?UTF-8?q?Avoid=20using=20JVM=E2=80=99s=20default=20chars?= =?UTF-8?q?et=20for=20String=20to=20byte[]=20in=20unit=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restdocs/http/HttpRequestSnippetTests.java | 2 +- .../restdocs/http/HttpResponseSnippetTests.java | 2 +- .../org/springframework/restdocs/test/OperationBuilder.java | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java index bd93a77c..83ce80ba 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java @@ -98,7 +98,7 @@ public class HttpRequestSnippetTests { "post-request-with-charset", this.snippet.getOutputDirectory()) .request("http://localhost/foo").method("POST") .header("Content-Type", "text/plain;charset=UTF-8") - .content(japaneseContent).build()); + .content(japaneseContent.getBytes("UTF-8")).build()); } @Test diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpResponseSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpResponseSnippetTests.java index c40dff68..b2a25940 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpResponseSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpResponseSnippetTests.java @@ -93,7 +93,7 @@ public class HttpResponseSnippetTests { new HttpResponseSnippet().document(new OperationBuilder("response-with-charset", this.snippet.getOutputDirectory()).response() .header("Content-Type", "text/plain;charset=UTF-8") - .content(japaneseContent).build()); + .content(japaneseContent.getBytes("UTF-8")).build()); } @Test diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OperationBuilder.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OperationBuilder.java index 50d6cd83..51d66504 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OperationBuilder.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/test/OperationBuilder.java @@ -140,6 +140,11 @@ public class OperationBuilder { return this; } + public OperationRequestBuilder content(byte[] content) { + this.content = content; + return this; + } + public OperationRequestBuilder param(String name, String... values) { for (String value : values) { this.parameters.add(name, value);