Class SharedHttpSessionConfigurer
- java.lang.Object
- org.springframework.test.web.servlet.setup.SharedHttpSessionConfigurer
- All Implemented Interfaces:
MockMvcConfigurer
public class SharedHttpSessionConfigurer extends Object implements MockMvcConfigurer
MockMvcConfigurerthat stores and re-uses the HTTP session across multiple requests performed through the sameMockMvcinstance.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 ...- Since:
- 5.0
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description SharedHttpSessionConfigurer()
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterConfigurerAdded(ConfigurableMockMvcBuilder<?> builder)Invoked immediately when thisMockMvcConfigureris added viaConfigurableMockMvcBuilder.apply(org.springframework.test.web.servlet.setup.MockMvcConfigurer).RequestPostProcessorbeforeMockMvcCreated(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 SharedHttpSessionConfigurersharedHttpSession()
Constructor Detail
SharedHttpSessionConfigurer
public SharedHttpSessionConfigurer()
Method Detail
afterConfigurerAdded
public void afterConfigurerAdded(ConfigurableMockMvcBuilder<?> builder)
Description copied from interface:MockMvcConfigurerInvoked immediately when thisMockMvcConfigureris added viaConfigurableMockMvcBuilder.apply(org.springframework.test.web.servlet.setup.MockMvcConfigurer).- Specified by:
afterConfigurerAddedin interfaceMockMvcConfigurer- Parameters:
builder- the builder for the MockMvc
beforeMockMvcCreated
public RequestPostProcessor beforeMockMvcCreated(ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context)
Description copied from interface:MockMvcConfigurerInvoked when the MockMvc instance is about to be created with the MockMvc builder and the Spring WebApplicationContext that will be passed to theDispatcherServlet.- Specified by:
beforeMockMvcCreatedin interfaceMockMvcConfigurer- Parameters:
builder- the builder for the MockMvccontext- the Spring configuration- Returns:
- a post processor to be applied to every request performed through the
MockMvcinstance.
sharedHttpSession
public static SharedHttpSessionConfigurer sharedHttpSession()