类 SharedHttpSessionConfigurer
- java.lang.Object
- org.springframework.test.web.servlet.setup.SharedHttpSessionConfigurer
- 所有已实现的接口:
MockMvcConfigurer
public class SharedHttpSessionConfigurer extends Object implements MockMvcConfigurer
MockMvcConfigurer
that stores and re-uses the HTTP session across multiple requests performed through the sameMockMvc
instance.Example use:
import static org.springframework.test.web.servlet.setup.SharedHttpSessionConfigurer.sharedHttpSession; // ... MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new TestController()) .apply(sharedHttpSession()) .build(); // Use mockMvc to perform requests ...
- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 SharedHttpSessionConfigurer()
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterConfigurerAdded(ConfigurableMockMvcBuilder<?> builder)
Invoked immediately when thisMockMvcConfigurer
is added viaConfigurableMockMvcBuilder.apply(org.springframework.test.web.servlet.setup.MockMvcConfigurer)
.RequestPostProcessor
beforeMockMvcCreated(ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context)
Invoked when the MockMvc instance is about to be created with the MockMvc builder and the Spring WebApplicationContext that will be passed to theDispatcherServlet
.static SharedHttpSessionConfigurer
sharedHttpSession()
构造器详细资料
SharedHttpSessionConfigurer
public SharedHttpSessionConfigurer()
方法详细资料
afterConfigurerAdded
public void afterConfigurerAdded(ConfigurableMockMvcBuilder<?> builder)
从接口复制的说明:MockMvcConfigurer
Invoked immediately when thisMockMvcConfigurer
is added viaConfigurableMockMvcBuilder.apply(org.springframework.test.web.servlet.setup.MockMvcConfigurer)
.- 指定者:
afterConfigurerAdded
在接口中MockMvcConfigurer
- 参数:
builder
- the builder for the MockMvc
beforeMockMvcCreated
public RequestPostProcessor beforeMockMvcCreated(ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context)
从接口复制的说明:MockMvcConfigurer
Invoked when the MockMvc instance is about to be created with the MockMvc builder and the Spring WebApplicationContext that will be passed to theDispatcherServlet
.- 指定者:
beforeMockMvcCreated
在接口中MockMvcConfigurer
- 参数:
builder
- the builder for the MockMvccontext
- the Spring configuration- 返回:
- a post processor to be applied to every request performed through the
MockMvc
instance.
sharedHttpSession
public static SharedHttpSessionConfigurer sharedHttpSession()