Polish contribution
See gh-23219
This commit is contained in:
@@ -56,6 +56,7 @@ import org.springframework.web.util.WebUtils;
|
|||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @author Vedran Pavic
|
* @author Vedran Pavic
|
||||||
|
* @author Sebastien Deleuze
|
||||||
* @since 1.0.2
|
* @since 1.0.2
|
||||||
*/
|
*/
|
||||||
public class MockHttpServletResponse implements HttpServletResponse {
|
public class MockHttpServletResponse implements HttpServletResponse {
|
||||||
@@ -219,10 +220,11 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the content of the response body as a {@code String}, using the provided
|
* Get the content of the response body as a {@code String}, using the provided
|
||||||
* {@code fallbackCharset} if no charset has been explicitly defined, else using
|
* {@code fallbackCharset} if no charset has been explicitly defined and otherwise
|
||||||
* using the configured {@linkplain #getCharacterEncoding character encoding}.
|
* using the configured {@linkplain #getCharacterEncoding character encoding}.
|
||||||
* @return the content as a {@code String}
|
* @return the content as a {@code String}
|
||||||
* @throws UnsupportedEncodingException if the character encoding is not supported
|
* @throws UnsupportedEncodingException if the character encoding is not supported
|
||||||
|
* @since 5.2
|
||||||
* @see #getContentAsString()
|
* @see #getContentAsString()
|
||||||
*/
|
*/
|
||||||
public String getContentAsString(Charset fallbackCharset) throws UnsupportedEncodingException {
|
public String getContentAsString(Charset fallbackCharset) throws UnsupportedEncodingException {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.io.OutputStreamWriter;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -55,6 +56,7 @@ import org.springframework.web.util.WebUtils;
|
|||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @author Vedran Pavic
|
* @author Vedran Pavic
|
||||||
|
* @author Sebastien Deleuze
|
||||||
* @since 1.0.2
|
* @since 1.0.2
|
||||||
*/
|
*/
|
||||||
public class MockHttpServletResponse implements HttpServletResponse {
|
public class MockHttpServletResponse implements HttpServletResponse {
|
||||||
@@ -204,11 +206,33 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||||||
return this.content.toByteArray();
|
return this.content.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the content of the response body as a {@code String}, using the configured
|
||||||
|
* {@linkplain #getCharacterEncoding character encoding}.
|
||||||
|
* @return the content as a {@code String}
|
||||||
|
* @throws UnsupportedEncodingException if the character encoding is not supported
|
||||||
|
* @see #getContentAsString(Charset)
|
||||||
|
*/
|
||||||
public String getContentAsString() throws UnsupportedEncodingException {
|
public String getContentAsString() throws UnsupportedEncodingException {
|
||||||
return (this.characterEncoding != null ?
|
return (this.characterEncoding != null ?
|
||||||
this.content.toString(this.characterEncoding) : this.content.toString());
|
this.content.toString(this.characterEncoding) : this.content.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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}.
|
||||||
|
* @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) :
|
||||||
|
this.content.toString(fallbackCharset.name());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContentLength(int contentLength) {
|
public void setContentLength(int contentLength) {
|
||||||
this.contentLength = contentLength;
|
this.contentLength = contentLength;
|
||||||
|
|||||||
Reference in New Issue
Block a user