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, Sam Brannen
-
Constructor Summary
ConstructorDescriptionDefault constructor.MockClientHttpRequest
(HttpMethod httpMethod, URI uri) Create an instance with the given HttpMethod and URI. -
Method Summary
Modifier and TypeMethodDescriptionfinal ClientHttpResponse
execute()
protected ClientHttpResponse
The default implementation returns the configuredresponse
.Return the HTTP method of the request.Deprecated.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
void
setMethod
(HttpMethod httpMethod) void
setResponse
(ClientHttpResponse clientHttpResponse) void
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()Default constructor. -
MockClientHttpRequest
Create an instance with the given HttpMethod and URI.
-
-
Method Details
-
setMethod
-
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:
-
getMethodValue
Deprecated.Description copied from interface:HttpRequest
Return the HTTP method of the request as a String value.- Specified by:
getMethodValue
in interfaceHttpRequest
- Returns:
- the HTTP method as a plain String
- See Also:
-
setURI
-
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
-
isExecuted
public boolean isExecuted() -
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 than the configured response.
- Throws:
IOException
-
toString
-