类 DefaultRequestExpectation
- java.lang.Object
- org.springframework.test.web.client.DefaultRequestExpectation
public class DefaultRequestExpectation extends Object implements RequestExpectation
Default implementation ofRequestExpectationthat simply delegates to the request matchers and the response creator it contains.- 从以下版本开始:
- 4.3
- 作者:
- Rossen Stoyanchev
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected static classDefaultRequestExpectation.RequestCountHelper 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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ResponseActionsandExpect(RequestMatcher requestMatcher)Add a request expectation.voidandRespond(ResponseCreator responseCreator)Define the response.ClientHttpResponsecreateResponse(ClientHttpRequest request)Create a response for the given request.protected DefaultRequestExpectation.RequestCountgetRequestCount()protected List<RequestMatcher>getRequestMatchers()protected ResponseCreatorgetResponseCreator()booleanhasRemainingCount()Whether there is a remaining count of invocations for this expectation.booleanisSatisfied()Whether the requirements for this request expectation have been met.voidmatch(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)
从接口复制的说明:ResponseActionsAdd a request expectation.- 指定者:
andExpect在接口中ResponseActions- 返回:
- the expectation
andRespond
public void andRespond(ResponseCreator responseCreator)
从接口复制的说明:ResponseActionsDefine the response.- 指定者:
andRespond在接口中ResponseActions- 参数:
responseCreator- the creator of the response
match
public void match(ClientHttpRequest request) throws IOException
从接口复制的说明:RequestMatcherMatch 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
从接口复制的说明:ResponseCreatorCreate a response for the given request.- 指定者:
createResponse在接口中ResponseCreator- 参数:
request- the request- 抛出:
IOException
hasRemainingCount
public boolean hasRemainingCount()
从接口复制的说明:RequestExpectationWhether there is a remaining count of invocations for this expectation.- 指定者:
hasRemainingCount在接口中RequestExpectation
isSatisfied
public boolean isSatisfied()
从接口复制的说明:RequestExpectationWhether the requirements for this request expectation have been met.- 指定者:
isSatisfied在接口中RequestExpectation