类 MockServerRestTemplateCustomizer

java.lang.Object
cn.taketoday.framework.test.web.client.MockServerRestTemplateCustomizer
所有已实现的接口:
cn.taketoday.web.client.config.RestTemplateCustomizer

public class MockServerRestTemplateCustomizer extends Object implements cn.taketoday.web.client.config.RestTemplateCustomizer
RestTemplateCustomizer that can be applied to a RestTemplateBuilder instances to add MockRestServiceServer support.

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 the getServer(RestTemplate) or getServers() method must be used to access the related server.

从以下版本开始:
4.0
作者:
Phillip Webb, Harry Yang
另请参阅:
  • 字段详细资料

    • expectationManagers

      private final Map<cn.taketoday.web.client.RestTemplate,RequestExpectationManager> expectationManagers
    • servers

      private final Map<cn.taketoday.web.client.RestTemplate,MockRestServiceServer> servers
    • expectationManagerSupplier

      private final Supplier<? extends RequestExpectationManager> expectationManagerSupplier
    • detectRootUri

      private boolean detectRootUri
    • bufferContent

      private boolean bufferContent
  • 构造器详细资料

  • 方法详细资料

    • setDetectRootUri

      public void setDetectRootUri(boolean detectRootUri)
      Set if root URIs from RootUriRequestExpectationManager should be detected and applied to the MockRestServiceServer.
      参数:
      detectRootUri - if root URIs should be detected
    • setBufferContent

      public void setBufferContent(boolean bufferContent)
      Set if the BufferingClientHttpRequestFactory wrapper should be used to buffer the input and output streams, and for example, allow multiple reads of the response body.
      参数:
      bufferContent - if request and response content should be buffered
    • customize

      public void customize(cn.taketoday.web.client.RestTemplate restTemplate)
      指定者:
      customize 在接口中 cn.taketoday.web.client.config.RestTemplateCustomizer
    • createExpectationManager

      protected RequestExpectationManager createExpectationManager()
    • getServer

      public MockRestServiceServer getServer()
    • getExpectationManagers

      public Map<cn.taketoday.web.client.RestTemplate,RequestExpectationManager> getExpectationManagers()
    • getServer

      public MockRestServiceServer getServer(cn.taketoday.web.client.RestTemplate restTemplate)
    • getServers

      public Map<cn.taketoday.web.client.RestTemplate,MockRestServiceServer> getServers()