Interface MockMvcConfigurer
- All Known Implementing Classes:
MockMvcConfigurerAdapter, SharedHttpSessionConfigurer
public interface MockMvcConfigurer
Contract for customizing a
ConfigurableMockMvcBuilder in some
specific way, for example, a 3rd party library that wants to provide shortcuts for
setting up a MockMvc.
An implementation of this interface can be plugged in via
ConfigurableMockMvcBuilder.apply(MockMvcConfigurer) with instances of this type likely
created via static methods, for example:
import static org.example.ExampleSetup.mySetup;
// ...
MockMvcBuilders.webAppContextSetup(context).apply(mySetup("foo","bar")).build();
- Since:
- 4.1
- Author:
- Rossen Stoyanchev
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidafterConfigurerAdded(ConfigurableMockMvcBuilder<?> builder) Invoked immediately when thisMockMvcConfigureris added viaConfigurableMockMvcBuilder.apply(MockMvcConfigurer).default @Nullable 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.
-
Method Details
-
afterConfigurerAdded
Invoked immediately when thisMockMvcConfigureris added viaConfigurableMockMvcBuilder.apply(MockMvcConfigurer).- Parameters:
builder- the builder for the MockMvc
-
beforeMockMvcCreated
default @Nullable 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.- Parameters:
builder- the builder for the MockMvccontext- the Spring configuration- Returns:
- a post processor to be applied to every request performed
through the
MockMvcinstance.
-