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 Summary
ConstructorsConstructorDescriptionMockClientHttpRequest(HttpMethod httpMethod, String uriTemplate, Object... vars) Create aMockClientHttpRequestwith the givenHttpMethod, URI template, and URI template variable values.MockClientHttpRequest(HttpMethod httpMethod, URI uri) -
Method Summary
Modifier 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 MockHttpOutputMessage
getBody, getBodyAsBytes, getBodyAsString, getBodyAsString, getHeadersMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface HttpMessage
getHeadersMethods inherited from interface HttpOutputMessage
getBody
-
Constructor Details
-
MockClientHttpRequest
-
MockClientHttpRequest
Create aMockClientHttpRequestwith the givenHttpMethod, URI template, and URI template variable values.- Since:
- 6.0.3
-
MockClientHttpRequest
-
-
Method Details
-
setMethod
Set the HTTP method of the request. -
getMethod
Description copied from interface:HttpRequestReturn the HTTP method of the request.- Specified by:
getMethodin interfaceHttpRequest- Returns:
- the HTTP method as an HttpMethod value
- See Also:
-
setURI
Set the URI of the request. -
getURI
Description 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 interfaceHttpRequest- Returns:
- the URI of the request (never
null)
-
setResponse
Set theClientHttpResponseto be used as the result of executing this request.- See Also:
-
isExecuted
-
getAttributes
Description copied from interface:HttpRequestReturn a mutable map of request attributes for this request.- Specified by:
getAttributesin interfaceHttpRequest
-
execute
- Specified by:
executein interfaceClientHttpRequest- Returns:
- the response result of the execution
- Throws:
IOException- in case of I/O errors- See Also:
-
executeInternal
The 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
-