类 AbstractRequestExpectationManager
java.lang.Object
cn.taketoday.test.web.client.AbstractRequestExpectationManager
- 所有已实现的接口:
RequestExpectationManager
public abstract class AbstractRequestExpectationManager
extends Object
implements RequestExpectationManager
Base class for
RequestExpectationManager implementations responsible
for storing expectations and actual requests, and checking for unsatisfied
expectations at the end.
Subclasses are responsible for validating each request by matching it to to expectations following the order of declaration or not.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Harry Yang
-
嵌套类概要
嵌套类修饰符和类型类说明protected static classHelper class to manage a group of remaining expectations. -
字段概要
字段修饰符和类型字段说明private final List<RequestExpectation>private final List<cn.taketoday.http.client.ClientHttpRequest> -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voidInvoked at the time of the first actual request, which effectively means the expectations declaration phase is over.protected AssertionErrorcreateUnexpectedRequestError(cn.taketoday.http.client.ClientHttpRequest request) Return anAssertionErrorthat a sub-class can raise for an unexpected request.expectRequest(ExpectedCount count, RequestMatcher matcher) Set up a new request expectation.protected List<RequestExpectation>Return a read-only list of the expectations.protected StringReturn details of executed requests.protected List<cn.taketoday.http.client.ClientHttpRequest>Return a read-only list of requests executed so far.protected RequestExpectationmatchRequest(cn.taketoday.http.client.ClientHttpRequest request) subclasses should implement this method instead of#validateRequestInternal(ClientHttpRequest)in order to match the request to an expectation, leaving the call to create the response as a separate step (to be invoked by this class).voidreset()Reset the internal state removing all expectations and recorded requests.cn.taketoday.http.client.ClientHttpResponsevalidateRequest(cn.taketoday.http.client.ClientHttpRequest request) Validate the given actual request against the declared expectations.voidverify()Verify that all expectations have been met.voidVariant ofRequestExpectationManager.verify()that waits for up to the specified time for all expectations to be fulfilled.private int
-
字段详细资料
-
expectations
-
requests
-
requestFailures
-
-
构造器详细资料
-
AbstractRequestExpectationManager
public AbstractRequestExpectationManager()
-
-
方法详细资料
-
getExpectations
Return a read-only list of the expectations. -
getRequests
Return a read-only list of requests executed so far. -
expectRequest
从接口复制的说明:RequestExpectationManagerSet up a new request expectation. The returnedResponseActionsis used to add more expectations and define a response.This is a delegate for
MockRestServiceServer.expect(ExpectedCount, RequestMatcher).- 指定者:
expectRequest在接口中RequestExpectationManagermatcher- a request expectation- 返回:
- for setting up further expectations and define a response
- 另请参阅:
-
validateRequest
public cn.taketoday.http.client.ClientHttpResponse validateRequest(cn.taketoday.http.client.ClientHttpRequest request) throws IOException 从接口复制的说明:RequestExpectationManagerValidate the given actual request against the declared expectations. Is successful return the mock response to use or raise an error.This is used in
MockRestServiceServeragainst actual requests.- 指定者:
validateRequest在接口中RequestExpectationManager- 参数:
request- the request- 返回:
- the response to return if the request was validated.
- 抛出:
IOException- in case of any validation errors
-
afterExpectationsDeclared
protected void afterExpectationsDeclared()Invoked at the time of the first actual request, which effectively means the expectations declaration phase is over. -
matchRequest
protected RequestExpectation matchRequest(cn.taketoday.http.client.ClientHttpRequest request) throws IOException subclasses should implement this method instead of#validateRequestInternal(ClientHttpRequest)in order to match the request to an expectation, leaving the call to create the response as a separate step (to be invoked by this class).- 参数:
request- the current request- 返回:
- the matched expectation with its request count updated via
RequestExpectation.incrementAndValidate(). - 抛出:
IOException
-
verify
public void verify()从接口复制的说明:RequestExpectationManagerVerify that all expectations have been met.This is a delegate for
MockRestServiceServer.verify().- 指定者:
verify在接口中RequestExpectationManager- 另请参阅:
-
verify
从接口复制的说明:RequestExpectationManagerVariant ofRequestExpectationManager.verify()that waits for up to the specified time for all expectations to be fulfilled. This can be useful for tests that involve asynchronous requests.- 指定者:
verify在接口中RequestExpectationManager- 参数:
timeout- how long to wait for all expecations to be met
-
verifyInternal
private int verifyInternal() -
getRequestDetails
Return details of executed requests. -
createUnexpectedRequestError
protected AssertionError createUnexpectedRequestError(cn.taketoday.http.client.ClientHttpRequest request) Return anAssertionErrorthat a sub-class can raise for an unexpected request. -
reset
public void reset()从接口复制的说明:RequestExpectationManagerReset the internal state removing all expectations and recorded requests.This is a delegate for
MockRestServiceServer.reset().- 指定者:
reset在接口中RequestExpectationManager- 另请参阅:
-