类 RootUriRequestExpectationManager
java.lang.Object
org.springframework.boot.test.web.client.RootUriRequestExpectationManager
- 所有已实现的接口:
RequestExpectationManager
RequestExpectationManager
that strips the specified root URI from the request
before verification. Can be used to simply test declarations when all REST calls start
the same way. For example: RestTemplate restTemplate = new RestTemplateBuilder().rootUri("https://example.com").build(); MockRestServiceServer server = RootUriRequestExpectationManager.bindTo(restTemplate); server.expect(requestTo("/hello")).andRespond(withSuccess()); restTemplate.getForEntity("/hello", String.class);
- 从以下版本开始:
- 1.4.0
- 作者:
- Phillip Webb
- 另请参阅:
-
构造器概要
构造器构造器说明RootUriRequestExpectationManager
(String rootUri, RequestExpectationManager expectationManager) -
方法概要
修饰符和类型方法说明static MockRestServiceServer
bindTo
(RestTemplate restTemplate) Return a boundMockRestServiceServer
for the givenRestTemplate
, configured withRootUriRequestExpectationManager
when possible.static MockRestServiceServer
bindTo
(RestTemplate restTemplate, RequestExpectationManager expectationManager) Return a boundMockRestServiceServer
for the givenRestTemplate
, configured withRootUriRequestExpectationManager
when possible.expectRequest
(ExpectedCount count, RequestMatcher requestMatcher) static RequestExpectationManager
forRestTemplate
(RestTemplate restTemplate, RequestExpectationManager expectationManager) ReturnRequestExpectationManager
to be used for binding with the specifiedRestTemplate
.void
reset()
validateRequest
(ClientHttpRequest request) void
verify()
void
-
构造器详细资料
-
RootUriRequestExpectationManager
public RootUriRequestExpectationManager(String rootUri, RequestExpectationManager expectationManager)
-
-
方法详细资料
-
expectRequest
- 指定者:
expectRequest
在接口中RequestExpectationManager
-
validateRequest
- 指定者:
validateRequest
在接口中RequestExpectationManager
- 抛出:
IOException
-
verify
public void verify()- 指定者:
verify
在接口中RequestExpectationManager
-
verify
- 指定者:
verify
在接口中RequestExpectationManager
-
reset
public void reset()- 指定者:
reset
在接口中RequestExpectationManager
-
bindTo
Return a boundMockRestServiceServer
for the givenRestTemplate
, configured withRootUriRequestExpectationManager
when possible.- 参数:
restTemplate
- the source REST template- 返回:
- a configured
MockRestServiceServer
-
bindTo
public static MockRestServiceServer bindTo(RestTemplate restTemplate, RequestExpectationManager expectationManager) Return a boundMockRestServiceServer
for the givenRestTemplate
, configured withRootUriRequestExpectationManager
when possible.- 参数:
restTemplate
- the source REST templateexpectationManager
- the sourceRequestExpectationManager
- 返回:
- a configured
MockRestServiceServer
-
forRestTemplate
public static RequestExpectationManager forRestTemplate(RestTemplate restTemplate, RequestExpectationManager expectationManager) ReturnRequestExpectationManager
to be used for binding with the specifiedRestTemplate
. If theRestTemplate
is using aRootUriTemplateHandler
then aRootUriRequestExpectationManager
is returned, otherwise the source manager is returned unchanged.- 参数:
restTemplate
- the source REST templateexpectationManager
- the sourceRequestExpectationManager
- 返回:
- a
RequestExpectationManager
to be bound to the template
-