use of org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder in project spring-boot by spring-projects.
the class MvcEndpointIntegrationTests method doCreateMockMvc.
private MockMvc doCreateMockMvc(MockMvcConfigurer... configurers) {
this.context.setServletContext(new MockServletContext());
this.context.refresh();
DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(this.context);
for (MockMvcConfigurer configurer : configurers) {
builder.apply(configurer);
}
return builder.build();
}
use of org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder in project spring-cloud-sleuth by spring-cloud.
the class AbstractMvcIntegrationTest method setup.
@Before
public void setup() {
DefaultMockMvcBuilder mockMvcBuilder = MockMvcBuilders.webAppContextSetup(this.webApplicationContext);
configureMockMvcBuilder(mockMvcBuilder);
this.mockMvc = mockMvcBuilder.build();
}
use of org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder in project spring-boot by spring-projects.
the class SpringBootMockMvcBuilderCustomizerTests method customizeShouldAddFilters.
@Test
@SuppressWarnings("unchecked")
void customizeShouldAddFilters() {
AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext();
MockServletContext servletContext = new MockServletContext();
context.setServletContext(servletContext);
context.register(ServletConfiguration.class, FilterConfiguration.class);
context.refresh();
DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(context);
this.customizer = new SpringBootMockMvcBuilderCustomizer(context);
this.customizer.customize(builder);
FilterRegistrationBean<?> registrationBean = (FilterRegistrationBean<?>) context.getBean("filterRegistrationBean");
Filter testFilter = (Filter) context.getBean("testFilter");
Filter otherTestFilter = registrationBean.getFilter();
List<Filter> filters = (List<Filter>) ReflectionTestUtils.getField(builder, "filters");
assertThat(filters).containsExactlyInAnyOrder(testFilter, otherTestFilter);
}
use of org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder in project spring-boot by spring-projects.
the class WebMvcEndpointIntegrationTests method doCreateMockMvc.
private MockMvc doCreateMockMvc(MockMvcConfigurer... configurers) {
this.context.setServletContext(new MockServletContext());
this.context.refresh();
DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(this.context);
for (MockMvcConfigurer configurer : configurers) {
builder.apply(configurer);
}
return builder.build();
}
Aggregations