public class SharedHttpSessionConfigurer extends java.lang.Object implements MockMvcConfigurer
MockMvcConfigurer
that stores and re-uses the HTTP session across
multiple requests performed through the same MockMvc
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 ...
Constructor and Description |
---|
SharedHttpSessionConfigurer() |
Modifier and Type | Method and Description |
---|---|
void |
afterConfigurerAdded(ConfigurableMockMvcBuilder<?> builder)
Invoked immediately when this
MockMvcConfigurer is added via
ConfigurableMockMvcBuilder.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 the
DispatcherServlet . |
static SharedHttpSessionConfigurer |
sharedHttpSession() |
public void afterConfigurerAdded(ConfigurableMockMvcBuilder<?> builder)
MockMvcConfigurer
MockMvcConfigurer
is added via
ConfigurableMockMvcBuilder.apply(org.springframework.test.web.servlet.setup.MockMvcConfigurer)
.afterConfigurerAdded
in interface MockMvcConfigurer
builder
- the builder for the MockMvcpublic RequestPostProcessor beforeMockMvcCreated(ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context)
MockMvcConfigurer
DispatcherServlet
.beforeMockMvcCreated
in interface MockMvcConfigurer
builder
- the builder for the MockMvccontext
- the Spring configurationMockMvc
instance.public static SharedHttpSessionConfigurer sharedHttpSession()