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 of HttpOutputMessage.
Since:
3.2
Author:
Rossen Stoyanchev
  • Constructor Details

    • MockHttpOutputMessage

      public MockHttpOutputMessage()
  • Method Details

    • getHeaders

      public HttpHeaders getHeaders()
      Description copied from interface: HttpMessage
      Return the headers of this message.
      Specified by:
      getHeaders in interface HttpMessage
      Returns:
      a corresponding HttpHeaders object (never null)
    • getBody

      public OutputStream getBody() throws IOException
      Description copied from interface: HttpOutputMessage
      Return the body of the message as an output stream.
      Specified by:
      getBody in interface HttpOutputMessage
      Returns:
      the output stream body (never null)
      Throws:
      IOException - in case of I/O errors
    • getBodyAsBytes

      public byte[] getBodyAsBytes()
      Return the 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 interpreted as a string using the supplied character set.
      Parameters:
      charset - the charset to use to turn the body content into a String