Class MockClientHttpRequest
java.lang.Object
org.springframework.mock.http.MockHttpOutputMessage
org.springframework.mock.http.client.MockClientHttpRequest
- All Implemented Interfaces:
- ClientHttpRequest,- HttpMessage,- HttpOutputMessage,- HttpRequest
Mock implementation of 
ClientHttpRequest.- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Brian Clozel, Sam Brannen
- 
Constructor SummaryConstructorsConstructorDescriptionMockClientHttpRequest(HttpMethod httpMethod, String uriTemplate, Object... vars) Create aMockClientHttpRequestwith the givenHttpMethod, URI template, and URI template variable values.MockClientHttpRequest(HttpMethod httpMethod, URI uri) 
- 
Method SummaryModifier and TypeMethodDescriptionfinal ClientHttpResponseexecute()protected ClientHttpResponseThe default implementation returns the configuredresponse.Return a mutable map of request attributes for this request.Return the HTTP method of the request.getURI()Return the URI of the request (including a query string if any, but only if it is well-formed for a URI representation).booleanGet theexecutedflag.voidsetMethod(HttpMethod httpMethod) Set the HTTP method of the request.voidsetResponse(ClientHttpResponse clientHttpResponse) Set theClientHttpResponseto be used as the result of executing this request.voidSet the URI of the request.toString()Methods inherited from class org.springframework.mock.http.MockHttpOutputMessagegetBody, getBodyAsBytes, getBodyAsString, getBodyAsString, getHeadersMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.http.HttpMessagegetHeadersMethods inherited from interface org.springframework.http.HttpOutputMessagegetBody
- 
Constructor Details- 
MockClientHttpRequestpublic MockClientHttpRequest()
- 
MockClientHttpRequestCreate aMockClientHttpRequestwith the givenHttpMethod, URI template, and URI template variable values.- Since:
- 6.0.3
 
- 
MockClientHttpRequest
 
- 
- 
Method Details- 
setMethodSet the HTTP method of the request.
- 
getMethodDescription copied from interface:HttpRequestReturn the HTTP method of the request.- Specified by:
- getMethodin interface- HttpRequest
- Returns:
- the HTTP method as an HttpMethod value
- See Also:
 
- 
setURISet the URI of the request.
- 
getURIDescription copied from interface:HttpRequestReturn the URI of the request (including a query string if any, but only if it is well-formed for a URI representation).- Specified by:
- getURIin interface- HttpRequest
- Returns:
- the URI of the request (never null)
 
- 
setResponseSet theClientHttpResponseto be used as the result of executing this request.- See Also:
 
- 
isExecutedpublic boolean isExecuted()Get theexecutedflag.- See Also:
 
- 
getAttributesDescription copied from interface:HttpRequestReturn a mutable map of request attributes for this request.- Specified by:
- getAttributesin interface- HttpRequest
 
- 
execute- Specified by:
- executein interface- ClientHttpRequest
- Returns:
- the response result of the execution
- Throws:
- IOException- in case of I/O errors
- See Also:
 
- 
executeInternalThe default implementation returns the configuredresponse.Override this method to execute the request and provide a response, potentially different from the configured response. - Throws:
- IOException
 
- 
toString
 
-