类 DefaultRequestExpectation
- java.lang.Object
- org.springframework.test.web.client.DefaultRequestExpectation
public class DefaultRequestExpectation extends Object implements RequestExpectation
Default implementation ofRequestExpectation
that simply delegates to the request matchers and the response creator it contains.- 从以下版本开始:
- 4.3
- 作者:
- Rossen Stoyanchev
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected static class
DefaultRequestExpectation.RequestCount
Helper class that keeps track of actual vs expected request count.
构造器概要
构造器 构造器 说明 DefaultRequestExpectation(ExpectedCount expectedCount, RequestMatcher requestMatcher)
Create a new request expectation that should be called a number of times as indicated byRequestCount
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ResponseActions
andExpect(RequestMatcher requestMatcher)
Add a request expectation.void
andRespond(ResponseCreator responseCreator)
Define the response.ClientHttpResponse
createResponse(ClientHttpRequest request)
Create a response for the given request.protected DefaultRequestExpectation.RequestCount
getRequestCount()
protected List<RequestMatcher>
getRequestMatchers()
protected ResponseCreator
getResponseCreator()
boolean
hasRemainingCount()
Whether there is a remaining count of invocations for this expectation.boolean
isSatisfied()
Whether the requirements for this request expectation have been met.void
match(ClientHttpRequest request)
Match the given request against specific expectations.
构造器详细资料
DefaultRequestExpectation
public DefaultRequestExpectation(ExpectedCount expectedCount, RequestMatcher requestMatcher)
Create a new request expectation that should be called a number of times as indicated byRequestCount
.- 参数:
expectedCount
- the expected request expectedCount
方法详细资料
getRequestCount
protected DefaultRequestExpectation.RequestCount getRequestCount()
getRequestMatchers
protected List<RequestMatcher> getRequestMatchers()
getResponseCreator
protected ResponseCreator getResponseCreator()
andExpect
public ResponseActions andExpect(RequestMatcher requestMatcher)
从接口复制的说明:ResponseActions
Add a request expectation.- 指定者:
andExpect
在接口中ResponseActions
- 返回:
- the expectation
andRespond
public void andRespond(ResponseCreator responseCreator)
从接口复制的说明:ResponseActions
Define the response.- 指定者:
andRespond
在接口中ResponseActions
- 参数:
responseCreator
- the creator of the response
match
public void match(ClientHttpRequest request) throws IOException
从接口复制的说明:RequestMatcher
Match the given request against specific expectations.- 指定者:
match
在接口中RequestMatcher
- 参数:
request
- the request to make assertions on- 抛出:
IOException
- in case of I/O errors
createResponse
public ClientHttpResponse createResponse(ClientHttpRequest request) throws IOException
从接口复制的说明:ResponseCreator
Create a response for the given request.- 指定者:
createResponse
在接口中ResponseCreator
- 参数:
request
- the request- 抛出:
IOException
hasRemainingCount
public boolean hasRemainingCount()
从接口复制的说明:RequestExpectation
Whether there is a remaining count of invocations for this expectation.- 指定者:
hasRemainingCount
在接口中RequestExpectation
isSatisfied
public boolean isSatisfied()
从接口复制的说明:RequestExpectation
Whether the requirements for this request expectation have been met.- 指定者:
isSatisfied
在接口中RequestExpectation