@Bean @ConditionalOnMissingBean(MockMvcBuilder.class) public DefaultMockMvcBuilder mockMvcBuilder( List<MockMvcBuilderCustomizer> customizers) { DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(this.context); for (MockMvcBuilderCustomizer customizer : customizers) { customizer.customize(builder); } return builder; }
@Bean @ConditionalOnMissingBean public MockMvc mockMvc(MockMvcBuilder builder) { return builder.build(); }
public static MockMvcBuilder mockServer(Object... controllers) { TestWebMvcConfigurationSupport configuration = new TestWebMvcConfigurationSupport(new DesignerConfig()); return standaloneSetup(controllers) .setMessageConverters(configuration.createMessageConverters()) .setHandlerExceptionResolvers(configuration.handlerExceptionResolver()); }