类 AbstractRequestExpectationManager
- java.lang.Object
- org.springframework.test.web.client.AbstractRequestExpectationManager
- 所有已实现的接口:
RequestExpectationManager
public abstract class AbstractRequestExpectationManager extends Object implements RequestExpectationManager
Base class forRequestExpectationManager
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.3
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected static class
AbstractRequestExpectationManager.RequestExpectationGroup
Helper class to manage a group of remaining expectations.
构造器概要
构造器 构造器 说明 AbstractRequestExpectationManager()
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 protected void
afterExpectationsDeclared()
Invoked at the time of the first actual request, which effectively means the expectations declaration phase is over.protected AssertionError
createUnexpectedRequestError(ClientHttpRequest request)
Return anAssertionError
that a sub-class can raise for an unexpected request.ResponseActions
expectRequest(ExpectedCount count, RequestMatcher matcher)
Set up a new request expectation.protected List<RequestExpectation>
getExpectations()
Return a read-only list of the expectations.protected String
getRequestDetails()
Return details of executed requests.protected List<ClientHttpRequest>
getRequests()
Return a read-only list of requests executed so far.protected RequestExpectation
matchRequest(ClientHttpRequest request)
As of 5.0.3 subclasses should implement this method instead ofvalidateRequestInternal(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).void
reset()
Reset the internal state removing all expectations and recorded requests.ClientHttpResponse
validateRequest(ClientHttpRequest request)
Validate the given actual request against the declared expectations.protected ClientHttpResponse
validateRequestInternal(ClientHttpRequest request)
已过时。as of 5.0.3, subclasses should implementmatchRequest(ClientHttpRequest)
instead and return only the matched expectation, leaving the call to create the response as a separate step (to be invoked by this class).void
verify()
Verify that all expectations have been met.
构造器详细资料
AbstractRequestExpectationManager
public AbstractRequestExpectationManager()
方法详细资料
getExpectations
protected List<RequestExpectation> getExpectations()
Return a read-only list of the expectations.
getRequests
protected List<ClientHttpRequest> getRequests()
Return a read-only list of requests executed so far.
expectRequest
public ResponseActions expectRequest(ExpectedCount count, RequestMatcher matcher)
从接口复制的说明:RequestExpectationManager
Set up a new request expectation. The returnedResponseActions
is used to add more expectations and define a response.This is a delegate for
MockRestServiceServer.expect(ExpectedCount, RequestMatcher)
.- 指定者:
expectRequest
在接口中RequestExpectationManager
matcher
- a request expectation- 返回:
- for setting up further expectations and define a response
- 另请参阅:
MockRestServiceServer.expect(RequestMatcher)
,MockRestServiceServer.expect(ExpectedCount, RequestMatcher)
validateRequest
public ClientHttpResponse validateRequest(ClientHttpRequest request) throws IOException
从接口复制的说明:RequestExpectationManager
Validate the given actual request against the declared expectations. Is successful return the mock response to use or raise an error.This is used in
MockRestServiceServer
against 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.
validateRequestInternal
@Deprecated @Nullable protected ClientHttpResponse validateRequestInternal(ClientHttpRequest request) throws IOException
已过时。as of 5.0.3, subclasses should implementmatchRequest(ClientHttpRequest)
instead and return only the matched expectation, leaving the call to create the response as a separate step (to be invoked by this class).Subclasses must implement the actual validation of the request matching to declared expectations.- 抛出:
IOException
matchRequest
protected RequestExpectation matchRequest(ClientHttpRequest request) throws IOException
As of 5.0.3 subclasses should implement this method instead ofvalidateRequestInternal(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
- 从以下版本开始:
- 5.0.3
verify
public void verify()
从接口复制的说明:RequestExpectationManager
Verify that all expectations have been met.This is a delegate for
MockRestServiceServer.verify()
.
getRequestDetails
protected String getRequestDetails()
Return details of executed requests.
createUnexpectedRequestError
protected AssertionError createUnexpectedRequestError(ClientHttpRequest request)
Return anAssertionError
that a sub-class can raise for an unexpected request.
reset
public void reset()
从接口复制的说明:RequestExpectationManager
Reset the internal state removing all expectations and recorded requests.This is a delegate for
MockRestServiceServer.reset()
.- 指定者:
reset
在接口中RequestExpectationManager
- 另请参阅:
MockRestServiceServer.reset()