Class MockClientHttpResponse

java.lang.Object
org.springframework.mock.http.MockHttpInputMessage
org.springframework.mock.http.client.MockClientHttpResponse
All Implemented Interfaces:
Closeable, AutoCloseable, org.springframework.http.client.ClientHttpResponse, org.springframework.http.HttpInputMessage, org.springframework.http.HttpMessage

public class MockClientHttpResponse extends MockHttpInputMessage implements org.springframework.http.client.ClientHttpResponse
Mock implementation of ClientHttpResponse.
Since:
3.2
Author:
Rossen Stoyanchev, Sam Brannen
  • Constructor Details

    • MockClientHttpResponse

      public MockClientHttpResponse()
      Create a MockClientHttpResponse with an empty response body and HTTP status code OK.
      Since:
      6.0.3
    • MockClientHttpResponse

      public MockClientHttpResponse(byte[] body, org.springframework.http.HttpStatusCode statusCode)
      Create a MockClientHttpResponse with response body as a byte array and the supplied HTTP status code.
    • MockClientHttpResponse

      public MockClientHttpResponse(byte[] body, int statusCode)
      Create a MockClientHttpResponse with response body as a byte array and a custom HTTP status code.
      Since:
      5.3.17
    • MockClientHttpResponse

      public MockClientHttpResponse(InputStream body, org.springframework.http.HttpStatusCode statusCode)
      Create a MockClientHttpResponse with response body as InputStream and the supplied HTTP status code.
    • MockClientHttpResponse

      public MockClientHttpResponse(InputStream body, int statusCode)
      Create a MockClientHttpResponse with response body as InputStream and a custom HTTP status code.
      Since:
      5.3.17
  • Method Details

    • getStatusCode

      public org.springframework.http.HttpStatusCode getStatusCode()
      Specified by:
      getStatusCode in interface org.springframework.http.client.ClientHttpResponse
    • getRawStatusCode

      @Deprecated public int getRawStatusCode()
      Deprecated.
      Specified by:
      getRawStatusCode in interface org.springframework.http.client.ClientHttpResponse
    • getStatusText

      public String getStatusText()
      Specified by:
      getStatusText in interface org.springframework.http.client.ClientHttpResponse
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface org.springframework.http.client.ClientHttpResponse
      Specified by:
      close in interface Closeable