@Before public void setup() { DefaultMockMvcBuilder mockMvcBuilder = MockMvcBuilders.webAppContextSetup(wac); WithSpringSecurity withSpringSecurityAnnotation = this.getClass().getAnnotation(WithSpringSecurity.class); if (withSpringSecurityAnnotation != null) { mockMvcBuilder.apply(springSecurity()); } initialiseMockMvcBuilder(mockMvcBuilder); mockMvc = mockMvcBuilder.build(); }
@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; }
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(); }
@Before public void setup() { ExceptionUtils.setFail(true); DefaultMockMvcBuilder mockMvcBuilder = MockMvcBuilders.webAppContextSetup(this.webApplicationContext); configureMockMvcBuilder(mockMvcBuilder); this.mockMvc = mockMvcBuilder.build(); }
@Override protected DefaultMockMvcBuilder createMvcWebAppContext(final WebApplicationContext context) { return MockMvcBuilders.webAppContextSetup(context) .addFilter(new DosFilter(null, 10, 10, "127\\.0\\.0\\.1|\\[0:0:0:0:0:0:0:1\\]", "(^192\\.168\\.)", "X-Forwarded-For")) .addFilter(new ExcludePathAwareShallowETagFilter( "/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", "/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/**", "/api/v1/downloadserver/**")); }
@Before public void setup() { ExceptionUtils.setFail(true); TestSpanContextHolder.removeCurrentSpan(); DefaultMockMvcBuilder mockMvcBuilder = MockMvcBuilders.webAppContextSetup(this.webApplicationContext); configureMockMvcBuilder(mockMvcBuilder); this.mockMvc = mockMvcBuilder.build(); }
protected void initialiseMockMvcBuilder(DefaultMockMvcBuilder mockMvcBuilder) { // hook to allow clients to perform any custom setup on the mockMvcBuilder }
@Bean public MockMvc mockMvc() { DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(wac); return builder.addFilters(filter) .build(); }
protected MockMvc getMockMvc() { DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(applicationContext); return builder.build(); }
@Override protected void configureMockMvcBuilder(DefaultMockMvcBuilder mockMvcBuilder) { mockMvcBuilder.addFilters(this.traceFilter); }
@Override protected void configureMockMvcBuilder(DefaultMockMvcBuilder mockMvcBuilder) { mockMvcBuilder.addFilters(new TraceFilter(this.tracer, this.traceKeys, new NoOpSpanReporter(), this.spanExtractor, this.spanInjector, this.httpTraceKeysInjector)); }
@Override protected void configureMockMvcBuilder(DefaultMockMvcBuilder mockMvcBuilder) { BeanFactory beanFactory = beanFactory(); mockMvcBuilder.addFilters(new TraceFilter(beanFactory)); }
/** * Override in a subclass to modify mockMvcBuilder configuration (e.g. add filter). * <p> * The method from super class should be called. */ protected void configureMockMvcBuilder(DefaultMockMvcBuilder mockMvcBuilder) { }