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, Brian Clozel, Sam Brannen
-
Constructor Summary
ConstructorDescriptionMockClientHttpRequest
(org.springframework.http.HttpMethod httpMethod, String uriTemplate, Object... vars) Create aMockClientHttpRequest
with the givenHttpMethod
, URI template, and URI template variable values.MockClientHttpRequest
(org.springframework.http.HttpMethod httpMethod, URI uri) -
Method Summary
Modifier and TypeMethodDescriptionfinal org.springframework.http.client.ClientHttpResponse
execute()
protected org.springframework.http.client.ClientHttpResponse
The default implementation returns the configuredresponse
.org.springframework.http.HttpMethod
getURI()
boolean
Get theexecuted
flag.void
setMethod
(org.springframework.http.HttpMethod httpMethod) Set the HTTP method of the request.void
setResponse
(org.springframework.http.client.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
Methods inherited from interface org.springframework.http.HttpRequest
getMethodValue
-
Constructor Details
-
MockClientHttpRequest
public MockClientHttpRequest() -
MockClientHttpRequest
public MockClientHttpRequest(org.springframework.http.HttpMethod httpMethod, String uriTemplate, Object... vars) Create aMockClientHttpRequest
with the givenHttpMethod
, URI template, and URI template variable values.- Since:
- 6.0.3
-
MockClientHttpRequest
-
-
Method Details
-
setMethod
public void setMethod(org.springframework.http.HttpMethod httpMethod) Set the HTTP method of the request. -
getMethod
public org.springframework.http.HttpMethod getMethod()- Specified by:
getMethod
in interfaceorg.springframework.http.HttpRequest
-
setURI
Set the URI of the request. -
getURI
- Specified by:
getURI
in interfaceorg.springframework.http.HttpRequest
-
setResponse
public void setResponse(org.springframework.http.client.ClientHttpResponse clientHttpResponse) Set theClientHttpResponse
to be used as the result of executing the this request.- See Also:
-
isExecuted
public boolean isExecuted()Get theexecuted
flag.- See Also:
-
execute
- Specified by:
execute
in interfaceorg.springframework.http.client.ClientHttpRequest
- Throws:
IOException
- 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
-