Package org.springframework.mock.http
Class MockHttpOutputMessage
- java.lang.Object
- org.springframework.mock.http.MockHttpOutputMessage
- All Implemented Interfaces:
HttpMessage
,HttpOutputMessage
- Direct Known Subclasses:
MockClientHttpRequest
public class MockHttpOutputMessage extends Object implements HttpOutputMessage
Mock implementation ofHttpOutputMessage
.- Since:
- 3.2
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description MockHttpOutputMessage()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OutputStream
getBody()
Return the body content.byte[]
getBodyAsBytes()
Return body content as a byte array.String
getBodyAsString()
Return the body content interpreted as a UTF-8 string.String
getBodyAsString(Charset charset)
Return the body content as a string.HttpHeaders
getHeaders()
Return the headers.
Constructor Detail
MockHttpOutputMessage
public MockHttpOutputMessage()
Method Detail
getHeaders
public HttpHeaders getHeaders()
Return the headers.- Specified by:
getHeaders
in interfaceHttpMessage
- Returns:
- a corresponding HttpHeaders object (never
null
)
getBody
public OutputStream getBody() throws IOException
Return the body content.- Specified by:
getBody
in interfaceHttpOutputMessage
- Returns:
- the output stream body (never
null
) - Throws:
IOException
- in case of I/O errors
getBodyAsBytes
public byte[] getBodyAsBytes()
Return body content as a byte array.
getBodyAsString
public String getBodyAsString()
Return the body content interpreted as a UTF-8 string.
getBodyAsString
public String getBodyAsString(Charset charset)
Return the body content as a string.- Parameters:
charset
- the charset to use to turn the body content to a String