From d6e3394b81778009b1ee74435fe1a96b40cad22b Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 16 Jul 2019 19:23:21 +0200 Subject: [PATCH] Polishing See gh-23219 --- .../mock/web/test/MockHttpServletResponse.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java index bb1240f26e..40791c6a26 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java @@ -207,8 +207,10 @@ public class MockHttpServletResponse implements HttpServletResponse { } /** - * Get the content of the response body as a {@code String}, using the configured - * {@linkplain #getCharacterEncoding character encoding}. + * Get the content of the response body as a {@code String}, using the charset + * specified for the response by the application, either through + * {@link HttpServletResponse} methods or through a charset parameter on the + * {@code Content-Type}. * @return the content as a {@code String} * @throws UnsupportedEncodingException if the character encoding is not supported * @see #getContentAsString(Charset) @@ -221,12 +223,15 @@ public class MockHttpServletResponse implements HttpServletResponse { /** * Get the content of the response body as a {@code String}, using the provided * {@code fallbackCharset} if no charset has been explicitly defined and otherwise - * using the configured {@linkplain #getCharacterEncoding character encoding}. + * using the charset specified for the response by the application, either + * through {@link HttpServletResponse} methods or through a charset parameter on the + * {@code Content-Type}. * @return the content as a {@code String} * @throws UnsupportedEncodingException if the character encoding is not supported * @since 5.2 * @see #getContentAsString() */ + public String getContentAsString(Charset fallbackCharset) throws UnsupportedEncodingException { return isCharset() ? this.content.toString(this.characterEncoding) :