类 MockServerRestTemplateCustomizer
- java.lang.Object
 - org.springframework.boot.test.web.client.MockServerRestTemplateCustomizer
 
- 所有已实现的接口:
 org.springframework.boot.web.client.RestTemplateCustomizer
public class MockServerRestTemplateCustomizer extends Object implements org.springframework.boot.web.client.RestTemplateCustomizer
RestTemplateCustomizerthat can be applied to aRestTemplateBuilderinstances to addMockRestServiceServersupport.Typically applied to an existing builder before it is used, for example:
MockServerRestTemplateCustomizer customizer = new MockServerRestTemplateCustomizer(); MyBean bean = new MyBean(new RestTemplateBuilder(customizer)); customizer.getServer().expect(requestTo("/hello")).andRespond(withSuccess()); bean.makeRestCall();If the customizer is only used once, the
getServer()method can be used to obtain the mock server. If the customizer has been used more than once thegetServer(RestTemplate)orgetServers()method must be used to access the related server.- 从以下版本开始:
 - 1.4.0
 - 另请参阅:
 getServer(),getServer(RestTemplate)
构造器概要
构造器 构造器 说明 MockServerRestTemplateCustomizer()MockServerRestTemplateCustomizer(Class<? extends org.springframework.test.web.client.RequestExpectationManager> expectationManager)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected org.springframework.test.web.client.RequestExpectationManagercreateExpectationManager()voidcustomize(org.springframework.web.client.RestTemplate restTemplate)Map<org.springframework.web.client.RestTemplate,org.springframework.test.web.client.RequestExpectationManager>getExpectationManagers()org.springframework.test.web.client.MockRestServiceServergetServer()org.springframework.test.web.client.MockRestServiceServergetServer(org.springframework.web.client.RestTemplate restTemplate)Map<org.springframework.web.client.RestTemplate,org.springframework.test.web.client.MockRestServiceServer>getServers()voidsetDetectRootUri(boolean detectRootUri)Set if root URIs fromRootUriRequestExpectationManagershould be detected and applied to theMockRestServiceServer.
构造器详细资料
MockServerRestTemplateCustomizer
public MockServerRestTemplateCustomizer()
MockServerRestTemplateCustomizer
public MockServerRestTemplateCustomizer(Class<? extends org.springframework.test.web.client.RequestExpectationManager> expectationManager)
方法详细资料
setDetectRootUri
public void setDetectRootUri(boolean detectRootUri)
Set if root URIs fromRootUriRequestExpectationManagershould be detected and applied to theMockRestServiceServer.- 参数:
 detectRootUri- if root URIs should be detected
customize
public void customize(org.springframework.web.client.RestTemplate restTemplate)
- 指定者:
 customize在接口中org.springframework.boot.web.client.RestTemplateCustomizer
createExpectationManager
protected org.springframework.test.web.client.RequestExpectationManager createExpectationManager()
getServer
public org.springframework.test.web.client.MockRestServiceServer getServer()
getExpectationManagers
public Map<org.springframework.web.client.RestTemplate,org.springframework.test.web.client.RequestExpectationManager> getExpectationManagers()
getServer
public org.springframework.test.web.client.MockRestServiceServer getServer(org.springframework.web.client.RestTemplate restTemplate)
getServers
public Map<org.springframework.web.client.RestTemplate,org.springframework.test.web.client.MockRestServiceServer> getServers()