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
ConstructorDescriptionMockClientHttpRequest
(HttpMethod httpMethod, String uriTemplate, Object... vars) Create aMockClientHttpRequest
with the givenHttpMethod
, URI template, and URI template variable values.MockClientHttpRequest
(HttpMethod httpMethod, URI uri) -
Method Summary
Modifier and TypeMethodDescriptionfinal ClientHttpResponse
execute()
protected ClientHttpResponse
The 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).boolean
Get theexecuted
flag.void
setMethod
(HttpMethod httpMethod) Set the HTTP method of the request.void
setResponse
(ClientHttpResponse clientHttpResponse) Set theClientHttpResponse
to be used as the result of executing the this request.void
Set the URI of the request.toString()
Methods inherited from class org.springframework.mock.http.MockHttpOutputMessage
getBody, getBodyAsBytes, getBodyAsString, getBodyAsString, getHeaders
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.http.HttpMessage
getHeaders
Methods inherited from interface org.springframework.http.HttpOutputMessage
getBody
-
Constructor Details
-
MockClientHttpRequest
public MockClientHttpRequest() -
MockClientHttpRequest
Create aMockClientHttpRequest
with 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:HttpRequest
Return the HTTP method of the request.- Specified by:
getMethod
in interfaceHttpRequest
- Returns:
- the HTTP method as an HttpMethod value
- See Also:
-
setURI
Set the URI of the request. -
getURI
Description copied from interface:HttpRequest
Return the URI of the request (including a query string if any, but only if it is well-formed for a URI representation).- Specified by:
getURI
in interfaceHttpRequest
- Returns:
- the URI of the request (never
null
)
-
setResponse
Set theClientHttpResponse
to be used as the result of executing the this request.- See Also:
-
isExecuted
public boolean isExecuted()Get theexecuted
flag.- See Also:
-
getAttributes
Description copied from interface:HttpRequest
Return a mutable map of request attributes for this request.- Specified by:
getAttributes
in interfaceHttpRequest
-
execute
- Specified by:
execute
in 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
-