类 MockMvcWebConnectionBuilderSupport<T extends MockMvcWebConnectionBuilderSupport<T>>

java.lang.Object
cn.taketoday.test.web.servlet.htmlunit.MockMvcWebConnectionBuilderSupport<T>
类型参数:
T - a self reference to the builder type
直接已知子类:
MockMvcHtmlUnitDriverBuilder, MockMvcWebClientBuilder

public abstract class MockMvcWebConnectionBuilderSupport<T extends MockMvcWebConnectionBuilderSupport<T>> extends Object
Support class that simplifies the creation of a WebConnection that uses MockMvc and optionally delegates to a real WebConnection for specific requests.

The default is to use MockMvc for requests to localhost and otherwise use a real WebConnection.

从以下版本开始:
4.0
作者:
Rob Winch, Sam Brannen
  • 字段详细资料

    • mockMvc

      private final MockMvc mockMvc
    • requestMatchers

      private final List<WebRequestMatcher> requestMatchers
    • contextPath

      private String contextPath
    • alwaysUseMockMvc

      private boolean alwaysUseMockMvc
  • 构造器详细资料

    • MockMvcWebConnectionBuilderSupport

      protected MockMvcWebConnectionBuilderSupport(MockMvc mockMvc)
      Create a new instance using the supplied MockMvc instance.
      参数:
      mockMvc - the MockMvc instance to use; never null
    • MockMvcWebConnectionBuilderSupport

      protected MockMvcWebConnectionBuilderSupport(cn.taketoday.web.servlet.WebApplicationContext context)
      Create a new instance using the supplied WebApplicationContext.
      参数:
      context - the WebApplicationContext to create a MockMvc instance from; never null
    • MockMvcWebConnectionBuilderSupport

      protected MockMvcWebConnectionBuilderSupport(cn.taketoday.web.servlet.WebApplicationContext context, MockMvcConfigurer configurer)
      Create a new instance using the supplied WebApplicationContext and MockMvcConfigurer.
      参数:
      context - the WebApplicationContext to create a MockMvc instance from; never null
      configurer - the MockMvcConfigurer to apply; never null
  • 方法详细资料

    • contextPath

      public T contextPath(String contextPath)
      Set the context path to use.

      If the supplied value is null or empty, the first path segment of the request URL is assumed to be the context path.

      Default is "".

      参数:
      contextPath - the context path to use
      返回:
      this builder for further customization
    • alwaysUseMockMvc

      public T alwaysUseMockMvc()
      Specify that MockMvc should always be used regardless of what the request looks like.
      返回:
      this builder for further customization
    • useMockMvc

      public T useMockMvc(WebRequestMatcher... matchers)
      Add additional WebRequestMatcher instances that will ensure that MockMvc is used to process the request, if such a matcher matches against the web request.
      参数:
      matchers - additional WebRequestMatcher instances
      返回:
      this builder for further customization
    • useMockMvcForHosts

      public T useMockMvcForHosts(String... hosts)
      Add additional WebRequestMatcher instances that return true if a supplied host matches — for example, "example.com" or "example.com:8080".
      参数:
      hosts - additional hosts that ensure MockMvc gets invoked
      返回:
      this builder for further customization
    • createConnection

      protected final org.htmlunit.WebConnection createConnection(org.htmlunit.WebClient webClient)
      Create a new WebConnection that will use a MockMvc instance if one of the specified WebRequestMatcher instances matches.
      参数:
      webClient - the WebClient to use if none of the specified WebRequestMatcher instances matches (never null)
      返回:
      a new WebConnection that will use a MockMvc instance if one of the specified WebRequestMatcher matches
      另请参阅:
    • createConnection

      private org.htmlunit.WebConnection createConnection(org.htmlunit.WebClient webClient, org.htmlunit.WebConnection defaultConnection)