类 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 MockRestServiceServerbindTo(RestTemplate restTemplate) Return a boundMockRestServiceServerfor the givenRestTemplate, configured withRootUriRequestExpectationManagerwhen possible.static MockRestServiceServerbindTo(RestTemplate restTemplate, RequestExpectationManager expectationManager) Return a boundMockRestServiceServerfor the givenRestTemplate, configured withRootUriRequestExpectationManagerwhen possible.expectRequest(ExpectedCount count, RequestMatcher requestMatcher) static RequestExpectationManagerforRestTemplate(RestTemplate restTemplate, RequestExpectationManager expectationManager) ReturnRequestExpectationManagerto be used for binding with the specifiedRestTemplate.voidreset()validateRequest(ClientHttpRequest request) voidverify()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 boundMockRestServiceServerfor the givenRestTemplate, configured withRootUriRequestExpectationManagerwhen possible.- 参数:
restTemplate- the source REST template- 返回:
- a configured
MockRestServiceServer
-
bindTo
public static MockRestServiceServer bindTo(RestTemplate restTemplate, RequestExpectationManager expectationManager) Return a boundMockRestServiceServerfor the givenRestTemplate, configured withRootUriRequestExpectationManagerwhen possible.- 参数:
restTemplate- the source REST templateexpectationManager- the sourceRequestExpectationManager- 返回:
- a configured
MockRestServiceServer
-
forRestTemplate
public static RequestExpectationManager forRestTemplate(RestTemplate restTemplate, RequestExpectationManager expectationManager) ReturnRequestExpectationManagerto be used for binding with the specifiedRestTemplate. If theRestTemplateis using aRootUriTemplateHandlerthen aRootUriRequestExpectationManageris returned, otherwise the source manager is returned unchanged.- 参数:
restTemplate- the source REST templateexpectationManager- the sourceRequestExpectationManager- 返回:
- a
RequestExpectationManagerto be bound to the template
-