Avoid using JVM’s default charset for String to byte[] in unit tests

This commit is contained in:
Andy Wilkinson
2015-09-23 22:19:45 +01:00
parent 8f9c4249af
commit cc0edcb901
3 changed files with 7 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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);