FilterRegistrationIntegrationTests Class — spring-boot Architecture
Architecture documentation for the FilterRegistrationIntegrationTests class in FilterRegistrationIntegrationTests.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/test/java/org/springframework/boot/web/servlet/FilterRegistrationIntegrationTests.java lines 47–110
class FilterRegistrationIntegrationTests {
private @Nullable AnnotationConfigServletWebApplicationContext context;
@AfterEach
void cleanUp() {
if (this.context != null) {
this.context.close();
}
}
@Test
void normalFiltersAreRegistered() {
load(FilterConfiguration.class);
assertThat(this.context).isNotNull();
then(this.context.getServletContext()).should()
.addFilter("myFilter", this.context.getBean("myFilter", MockFilter.class));
}
@Test
void scopedTargetFiltersAreNotRegistered() {
load(ScopedTargetFilterConfiguration.class);
assertThat(this.context).isNotNull();
then(this.context.getServletContext()).should(times(0)).addFilter(any(String.class), any(Filter.class));
}
private void load(Class<?> configuration) {
ServletContext servletContext = mock(ServletContext.class);
given(servletContext.addFilter(any(), any(Filter.class))).willReturn(mock(Dynamic.class));
given(servletContext.getInitParameterNames()).willReturn(Collections.emptyEnumeration());
given(servletContext.getAttributeNames()).willReturn(Collections.emptyEnumeration());
this.context = new AnnotationConfigServletWebApplicationContext();
this.context.setServletContext(servletContext);
this.context.register(configuration);
this.context.refresh();
try {
new WebApplicationContextInitializer(this.context).initialize(servletContext);
}
catch (ServletException ex) {
throw new RuntimeException(ex);
}
}
@Configuration(proxyBeanMethods = false)
static class ScopedTargetFilterConfiguration {
@Bean(name = "scopedTarget.myFilter")
Filter myFilter() {
return new MockFilter();
}
}
@Configuration(proxyBeanMethods = false)
static class FilterConfiguration {
@Bean
Filter myFilter() {
return new MockFilter();
}
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free