Class MockClientHttpRequest

java.lang.Object
org.springframework.mock.http.MockHttpOutputMessage
org.springframework.mock.http.client.MockClientHttpRequest
All Implemented Interfaces:
org.springframework.http.client.ClientHttpRequest, org.springframework.http.HttpMessage, org.springframework.http.HttpOutputMessage, org.springframework.http.HttpRequest

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

    • MockClientHttpRequest

      public MockClientHttpRequest()
      Default constructor.
    • MockClientHttpRequest

      public MockClientHttpRequest(org.springframework.http.HttpMethod httpMethod, URI uri)
      Create an instance with the given HttpMethod and URI.
  • Method Details

    • setMethod

      public void setMethod(org.springframework.http.HttpMethod httpMethod)
    • getMethod

      public org.springframework.http.HttpMethod getMethod()
      Specified by:
      getMethod in interface org.springframework.http.HttpRequest
    • setURI

      public void setURI(URI uri)
    • getURI

      public URI getURI()
      Specified by:
      getURI in interface org.springframework.http.HttpRequest
    • setResponse

      public void setResponse(org.springframework.http.client.ClientHttpResponse clientHttpResponse)
    • isExecuted

      public boolean isExecuted()
    • execute

      public final org.springframework.http.client.ClientHttpResponse execute() throws IOException
      Set the executed flag to true and return the configured response.
      Specified by:
      execute in interface org.springframework.http.client.ClientHttpRequest
      Throws:
      IOException
      See Also:
    • executeInternal

      protected org.springframework.http.client.ClientHttpResponse executeInternal() throws IOException
      The default implementation returns the configured response.

      Override this method to execute the request and provide a response, potentially different from the configured response.

      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object