use of org.springframework.test.web.servlet.request.ConfigurableSmartRequestBuilder in project spring-framework by spring-projects.
the class AbstractMockMvcBuilder method build.
/**
* Build a {@link org.springframework.test.web.servlet.MockMvc} instance.
*/
@Override
@SuppressWarnings("rawtypes")
public final MockMvc build() {
WebApplicationContext wac = initWebAppContext();
ServletContext servletContext = wac.getServletContext();
MockServletConfig mockServletConfig = new MockServletConfig(servletContext);
for (MockMvcConfigurer configurer : this.configurers) {
RequestPostProcessor processor = configurer.beforeMockMvcCreated(this, wac);
if (processor != null) {
if (this.defaultRequestBuilder == null) {
this.defaultRequestBuilder = MockMvcRequestBuilders.get("/");
}
if (this.defaultRequestBuilder instanceof ConfigurableSmartRequestBuilder) {
((ConfigurableSmartRequestBuilder) this.defaultRequestBuilder).with(processor);
}
}
}
Filter[] filterArray = this.filters.toArray(new Filter[this.filters.size()]);
return super.createMockMvc(filterArray, mockServletConfig, wac, this.defaultRequestBuilder, this.globalResultMatchers, this.globalResultHandlers, this.dispatcherServletCustomizers);
}
Aggregations