类 MockClientHttpRequest
- java.lang.Object
- org.springframework.mock.http.MockHttpOutputMessage
- org.springframework.mock.http.client.MockClientHttpRequest
- 所有已实现的接口:
ClientHttpRequest
,HttpMessage
,HttpOutputMessage
,HttpRequest
- 直接已知子类:
MockAsyncClientHttpRequest
public class MockClientHttpRequest extends MockHttpOutputMessage implements ClientHttpRequest
Mock implementation ofClientHttpRequest
.- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev, Sam Brannen
构造器概要
构造器 构造器 说明 MockClientHttpRequest()
Default constructor.MockClientHttpRequest(HttpMethod httpMethod, URI uri)
Create an instance with the given HttpMethod and URI.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ClientHttpResponse
execute()
protected ClientHttpResponse
executeInternal()
The default implementation returns the configuredresponse
.HttpMethod
getMethod()
Return the HTTP method of the request.URI
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
isExecuted()
void
setMethod(HttpMethod httpMethod)
void
setResponse(ClientHttpResponse clientHttpResponse)
void
setURI(URI uri)
String
toString()
从类继承的方法 org.springframework.mock.http.MockHttpOutputMessage
getBody, getBodyAsBytes, getBodyAsString, getBodyAsString, getHeaders
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口继承的方法 org.springframework.http.HttpMessage
getHeaders
从接口继承的方法 org.springframework.http.HttpOutputMessage
getBody
构造器详细资料
MockClientHttpRequest
public MockClientHttpRequest()
Default constructor.
MockClientHttpRequest
public MockClientHttpRequest(HttpMethod httpMethod, URI uri)
Create an instance with the given HttpMethod and URI.
方法详细资料
setMethod
public void setMethod(HttpMethod httpMethod)
getMethod
public HttpMethod getMethod()
从接口复制的说明:HttpRequest
Return the HTTP method of the request.- 指定者:
getMethod
在接口中HttpRequest
- 返回:
- the HTTP method as an HttpMethod enum value, or
null
if not resolvable (e.g. in case of a non-standard HTTP method)
getURI
public URI getURI()
从接口复制的说明:HttpRequest
Return the URI of the request (including a query string if any, but only if it is well-formed for a URI representation).- 指定者:
getURI
在接口中HttpRequest
- 返回:
- the URI of the request (never
null
)
setResponse
public void setResponse(ClientHttpResponse clientHttpResponse)
isExecuted
public boolean isExecuted()
execute
public final ClientHttpResponse execute() throws IOException
- 指定者:
execute
在接口中ClientHttpRequest
- 返回:
- the response result of the execution
- 抛出:
IOException
- in case of I/O errors- 另请参阅:
executeInternal()
executeInternal
protected ClientHttpResponse executeInternal() throws IOException
The default implementation returns the configuredresponse
.Override this method to execute the request and provide a response, potentially different than the configured response.
- 抛出:
IOException