Update HTTP request and response snippets to honour charset of content

Closes gh-126
This commit is contained in:
MURAKAMI Masahiko
2015-09-14 13:39:00 +09:00
committed by Andy Wilkinson
parent e04d361dcd
commit 9b31c0ce9b
8 changed files with 123 additions and 7 deletions

View File

@@ -84,7 +84,23 @@ public class HttpRequestSnippetTests {
.request("http://localhost/foo").method("POST").content("Hello, world")
.build());
}
@Test
public void postRequestWithCharset() throws IOException {
this.snippet.expectHttpRequest("post-request-with-charset").withContents(
httpRequest(POST, "/foo")
.header(HttpHeaders.HOST, "localhost")
.header("Content-Type", "text/plain;charset=UTF-8").content(
"こんにちわ, 世界")); // Hello, World in japanese.
new HttpRequestSnippet().document(new OperationBuilder(
"post-request-with-charset", this.snippet.getOutputDirectory())
.request("http://localhost/foo").method("POST")
.header("Content-Type", "text/plain;charset=UTF-8")
.content("こんにちわ, 世界")
.build());
}
@Test
public void postRequestWithParameter() throws IOException {
this.snippet.expectHttpRequest("post-request-with-parameter").withContents(

View File

@@ -84,7 +84,15 @@ public class HttpResponseSnippetTests {
new HttpResponseSnippet().document(new OperationBuilder("response-with-content",
this.snippet.getOutputDirectory()).response().content("content").build());
}
@Test
public void responseWithCharset() throws IOException {
this.snippet.expectHttpResponse("response-with-charset").withContents(
httpResponse(OK).header("Content-Type", "text/plain;charset=UTF-8").content("コンテンツ"));
new HttpResponseSnippet().document(new OperationBuilder("response-with-charset",
this.snippet.getOutputDirectory()).response().header("Content-Type", "text/plain;charset=UTF-8").content("コンテンツ").build());
}
@Test
public void responseWithCustomSnippetAttributes() throws IOException {
this.snippet.expectHttpResponse("response-with-snippet-attributes").withContents(