类 AbstractMockMvcBuilder<B extends AbstractMockMvcBuilder<B>>
- 类型参数:
B- a self reference to the builder type
- 所有已实现的接口:
MockMvcBuilder,ConfigurableMockMvcBuilder<B>
MockMvcBuilder with common methods for
configuring filters, default request properties, global expectations and
global result actions.
Subclasses can use different strategies to prepare the Infra
WebApplicationContext that will be passed to the
DispatcherServlet.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Stephane Nicoll, Sam Brannen, Harry Yang
-
字段概要
字段修饰符和类型字段说明private final List<MockMvcConfigurer>private RequestBuilderprivate Charsetprivate final List<DispatcherServletCustomizer>private final List<jakarta.servlet.Filter>private final List<ResultHandler>private final List<ResultMatcher> -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明final <T extends B>
TA more advanced that allows customizing anyDispatcherServletproperty.final <T extends B>
TAdd a filter mapped to specific patterns.<T extends B>
TaddFilter(jakarta.servlet.Filter filter, String filterName, Map<String, String> initParams, EnumSet<jakarta.servlet.DispatcherType> dispatcherTypes, String... urlPatterns) Add a filter that will be initialized viaFilter.init(FilterConfig)with the given init parameters, and will also apply only to requests that match the given dispatcher types and URL patterns.final <T extends B>
TaddFilters(jakarta.servlet.Filter... filters) Add filters mapped to all requests.final <T extends B>
TalwaysDo(ResultHandler resultHandler) Define a global action that should always be applied to every response.final <T extends B>
TalwaysExpect(ResultMatcher resultMatcher) Define a global expectation that should always be applied to every response.final <T extends B>
Tapply(MockMvcConfigurer configurer) Add aMockMvcConfigurerthat automates MockMvc setup and configures it for some specific purpose (e.g. security).final MockMvcbuild()Build aMockMvcinstance.final <T extends B>
TdefaultRequest(RequestBuilder requestBuilder) Define default request properties that should be merged into all performed requests.final <T extends B>
TdefaultResponseCharacterEncoding(Charset defaultResponseCharacterEncoding) Define the default character encoding to be applied to every response.protected abstract cn.taketoday.web.servlet.WebApplicationContextA method to obtain theWebApplicationContextto be passed to theDispatcherServlet.protected <T extends B>
Tself()从类继承的方法 cn.taketoday.test.web.servlet.MockMvcBuilderSupport
createMockMvc, createMockMvc从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.test.web.servlet.MockMvcBuilder
perform
-
字段详细资料
-
filters
-
defaultRequestBuilder
-
defaultResponseCharacterEncoding
-
globalResultMatchers
-
globalResultHandlers
-
dispatcherServletCustomizers
-
configurers
-
-
构造器详细资料
-
AbstractMockMvcBuilder
public AbstractMockMvcBuilder()
-
-
方法详细资料
-
addFilters
从接口复制的说明:ConfigurableMockMvcBuilderAdd 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 useConfigurableMockMvcBuilder.addFilter(Filter, String, Map, EnumSet, String...)instead.- 指定者:
addFilters在接口中ConfigurableMockMvcBuilder<B extends AbstractMockMvcBuilder<B>>- 参数:
filters- the filters to add
-
addFilter
从接口复制的说明:ConfigurableMockMvcBuilderAdd a filter mapped to specific patterns.Note: if you need the filter to be initialized with
Filter.init(FilterConfig), please useConfigurableMockMvcBuilder.addFilter(Filter, String, Map, EnumSet, String...)instead.- 指定者:
addFilter在接口中ConfigurableMockMvcBuilder<B extends AbstractMockMvcBuilder<B>>- 参数:
filter- the filter to addurlPatterns- the URL patterns to map to; if empty, matches all requests
-
addFilter
public <T extends B> T addFilter(jakarta.servlet.Filter filter, @Nullable String filterName, Map<String, String> initParams, EnumSet<jakarta.servlet.DispatcherType> dispatcherTypes, String... urlPatterns) 从接口复制的说明:ConfigurableMockMvcBuilderAdd a filter that will be initialized viaFilter.init(FilterConfig)with the given init parameters, and will also apply only to requests that match the given dispatcher types and URL patterns.- 指定者:
addFilter在接口中ConfigurableMockMvcBuilder<B extends AbstractMockMvcBuilder<B>>- 参数:
filter- the filter to addfilterName- the name to use for the filter; ifnull, thenMockFilterConfigis created without a name, which defaults to an empty String for the nameinitParams- the init parameters to initialize the filter withdispatcherTypes- dispatcher types the filter applies tourlPatterns- the URL patterns to map to; if empty, matches all requests- 另请参阅:
-
defaultRequest
从接口复制的说明:ConfigurableMockMvcBuilderDefine 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.
- 指定者:
defaultRequest在接口中ConfigurableMockMvcBuilder<B extends AbstractMockMvcBuilder<B>>- 参数:
requestBuilder- a RequestBuilder; see static factory methods inMockMvcRequestBuilders
-
defaultResponseCharacterEncoding
public final <T extends B> T defaultResponseCharacterEncoding(Charset defaultResponseCharacterEncoding) Define the default character encoding to be applied to every response.- 指定者:
defaultResponseCharacterEncoding在接口中ConfigurableMockMvcBuilder<B extends AbstractMockMvcBuilder<B>>- 参数:
defaultResponseCharacterEncoding- the default response character encoding
-
alwaysExpect
从接口复制的说明:ConfigurableMockMvcBuilderDefine a global expectation that should always be applied to every response. For example, status code 200 (OK), content type"application/json", etc.- 指定者:
alwaysExpect在接口中ConfigurableMockMvcBuilder<B extends AbstractMockMvcBuilder<B>>- 参数:
resultMatcher- a ResultMatcher; see static factory methods inMockMvcResultMatchers
-
alwaysDo
从接口复制的说明:ConfigurableMockMvcBuilderDefine a global action that should always be applied to every response. For example, writing detailed information about the performed request and resulting response toSystem.out.- 指定者:
alwaysDo在接口中ConfigurableMockMvcBuilder<B extends AbstractMockMvcBuilder<B>>- 参数:
resultHandler- a ResultHandler; see static factory methods inMockMvcResultHandlers
-
addDispatcherServletCustomizer
从接口复制的说明:ConfigurableMockMvcBuilderA more advanced that allows customizing anyDispatcherServletproperty.- 指定者:
addDispatcherServletCustomizer在接口中ConfigurableMockMvcBuilder<B extends AbstractMockMvcBuilder<B>>
-
apply
从接口复制的说明:ConfigurableMockMvcBuilderAdd aMockMvcConfigurerthat automates MockMvc setup and configures it for some specific purpose (e.g. security).There is a built-in
SharedHttpSessionConfigurerthat 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.- 指定者:
apply在接口中ConfigurableMockMvcBuilder<B extends AbstractMockMvcBuilder<B>>- 另请参阅:
-
self
-
build
Build aMockMvcinstance.- 指定者:
build在接口中MockMvcBuilder
-
initWebAppContext
protected abstract cn.taketoday.web.servlet.WebApplicationContext initWebAppContext()
-