接口 ConfigurableMockMvcBuilder<B extends ConfigurableMockMvcBuilder<B>>

类型参数:
B - a self reference to the builder type
所有超级接口:
MockMvcBuilder
所有已知实现类:
AbstractMockMvcBuilder, DefaultMockMvcBuilder, StandaloneMockMvcBuilder

public interface ConfigurableMockMvcBuilder<B extends ConfigurableMockMvcBuilder<B>> extends MockMvcBuilder
Defines common methods for building a MockMvc.
从以下版本开始:
4.0
作者:
Rossen Stoyanchev, Sam Brannen, Harry Yang
  • 方法概要

    修饰符和类型
    方法
    说明
    <T extends B>
    T
    A more advanced that allows customizing any DispatcherServlet property.
    <T extends B>
    T
    addFilter(jakarta.servlet.Filter filter, String... urlPatterns)
    Add a filter mapped to specific patterns.
    <T extends B>
    T
    addFilter(jakarta.servlet.Filter filter, String filterName, Map<String,String> initParams, EnumSet<jakarta.servlet.DispatcherType> dispatcherTypes, String... urlPatterns)
    Add a filter that will be initialized via Filter.init(FilterConfig) with the given init parameters, and will also apply only to requests that match the given dispatcher types and URL patterns.
    <T extends B>
    T
    addFilters(jakarta.servlet.Filter... filters)
    Add filters mapped to all requests.
    <T extends B>
    T
    alwaysDo(ResultHandler resultHandler)
    Define a global action that should always be applied to every response.
    <T extends B>
    T
    alwaysExpect(ResultMatcher resultMatcher)
    Define a global expectation that should always be applied to every response.
    <T extends B>
    T
    Add a MockMvcConfigurer that automates MockMvc setup and configures it for some specific purpose (e.g. security).
    <T extends B>
    T
    Define default request properties that should be merged into all performed requests.
    default <T extends B>
    T
    defaultResponseCharacterEncoding(Charset defaultResponseCharacterEncoding)
    Define the default character encoding to be applied to every response.

    从接口继承的方法 cn.taketoday.test.web.servlet.MockMvcBuilder

    build, perform
  • 方法详细资料

    • addFilters

      <T extends B> T addFilters(jakarta.servlet.Filter... filters)
      Add filters mapped to all requests. Filters are invoked in the same order.

      Note: if you need the filter to be initialized with Filter.init(FilterConfig), please use addFilter(Filter, String, Map, EnumSet, String...) instead.

      参数:
      filters - the filters to add
    • addFilter

      <T extends B> T addFilter(jakarta.servlet.Filter filter, String... urlPatterns)
      Add a filter mapped to specific patterns.

      Note: if you need the filter to be initialized with Filter.init(FilterConfig), please use addFilter(Filter, String, Map, EnumSet, String...) instead.

      参数:
      filter - the filter to add
      urlPatterns - the URL patterns to map to; if empty, matches all requests
    • addFilter

      <T extends B> T addFilter(jakarta.servlet.Filter filter, @Nullable String filterName, Map<String,String> initParams, EnumSet<jakarta.servlet.DispatcherType> dispatcherTypes, String... urlPatterns)
      Add a filter that will be initialized via Filter.init(FilterConfig) with the given init parameters, and will also apply only to requests that match the given dispatcher types and URL patterns.
      参数:
      filter - the filter to add
      filterName - the name to use for the filter; if null, then MockFilterConfig is created without a name, which defaults to an empty String for the name
      initParams - the init parameters to initialize the filter with
      dispatcherTypes - dispatcher types the filter applies to
      urlPatterns - the URL patterns to map to; if empty, matches all requests
      另请参阅:
    • defaultRequest

      <T extends B> T defaultRequest(RequestBuilder requestBuilder)
      Define default request properties that should be merged into all performed requests. In effect this provides a mechanism for defining common initialization for all requests such as the content type, request parameters, session attributes, and any other request property.

      Properties specified at the time of performing a request override the default properties defined here.

      参数:
      requestBuilder - a RequestBuilder; see static factory methods in MockMvcRequestBuilders
    • defaultResponseCharacterEncoding

      default <T extends B> T defaultResponseCharacterEncoding(Charset defaultResponseCharacterEncoding)
      Define the default character encoding to be applied to every response.

      The default implementation of this method throws an UnsupportedOperationException. Concrete implementations are therefore encouraged to override this method.

      参数:
      defaultResponseCharacterEncoding - the default response character encoding
      从以下版本开始:
      5.3.10
    • alwaysExpect

      <T extends B> T alwaysExpect(ResultMatcher resultMatcher)
      Define a global expectation that should always be applied to every response. For example, status code 200 (OK), content type "application/json", etc.
      参数:
      resultMatcher - a ResultMatcher; see static factory methods in MockMvcResultMatchers
    • alwaysDo

      <T extends B> T alwaysDo(ResultHandler resultHandler)
      Define a global action that should always be applied to every response. For example, writing detailed information about the performed request and resulting response to System.out.
      参数:
      resultHandler - a ResultHandler; see static factory methods in MockMvcResultHandlers
    • addDispatcherServletCustomizer

      <T extends B> T addDispatcherServletCustomizer(DispatcherServletCustomizer customizer)
      A more advanced that allows customizing any DispatcherServlet property.
    • apply

      <T extends B> T apply(MockMvcConfigurer configurer)
      Add a MockMvcConfigurer that automates MockMvc setup and configures it for some specific purpose (e.g. security).

      There is a built-in SharedHttpSessionConfigurer that can be used to re-use the HTTP session across requests. 3rd party frameworks like Infra Security also use this mechanism to provide configuration shortcuts.

      另请参阅: