Skip to content

Commit cd8d36b

Browse files
committed
Add WebMvcRegistrations to WebMvcTypeExcludeFilter
as well as WebMvcConfigurer
1 parent 2095991 commit cd8d36b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.LinkedHashSet;
2222
import java.util.Set;
2323

24+
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
2425
import org.springframework.boot.context.TypeExcludeFilter;
2526
import org.springframework.boot.jackson.JsonComponent;
2627
import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter;
@@ -60,6 +61,7 @@ public final class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizabl
6061
includes.add(ControllerAdvice.class);
6162
includes.add(JsonComponent.class);
6263
includes.add(WebMvcConfigurer.class);
64+
includes.add(WebMvcRegistrations.class);
6365
includes.add(javax.servlet.Filter.class);
6466
includes.add(FilterRegistrationBean.class);
6567
includes.add(DelegatingFilterProxyRegistrationBean.class);

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.jupiter.api.Test;
2323
import org.thymeleaf.dialect.IDialect;
2424

25+
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
2526
import org.springframework.context.annotation.ComponentScan.Filter;
2627
import org.springframework.context.annotation.FilterType;
2728
import org.springframework.core.type.classreading.MetadataReader;
@@ -55,6 +56,7 @@ void matchWhenHasNoControllers() throws Exception {
5556
assertThat(excludes(filter, Controller2.class)).isFalse();
5657
assertThat(excludes(filter, ExampleControllerAdvice.class)).isFalse();
5758
assertThat(excludes(filter, ExampleWeb.class)).isFalse();
59+
assertThat(excludes(filter, ExampleWebMvcRegistrations.class)).isFalse();
5860
assertThat(excludes(filter, ExampleMessageConverter.class)).isFalse();
5961
assertThat(excludes(filter, ExampleService.class)).isTrue();
6062
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
@@ -72,6 +74,7 @@ void matchWhenHasController() throws Exception {
7274
assertThat(excludes(filter, Controller2.class)).isTrue();
7375
assertThat(excludes(filter, ExampleControllerAdvice.class)).isFalse();
7476
assertThat(excludes(filter, ExampleWeb.class)).isFalse();
77+
assertThat(excludes(filter, ExampleWebMvcRegistrations.class)).isFalse();
7578
assertThat(excludes(filter, ExampleMessageConverter.class)).isFalse();
7679
assertThat(excludes(filter, ExampleService.class)).isTrue();
7780
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
@@ -89,6 +92,7 @@ void matchNotUsingDefaultFilters() throws Exception {
8992
assertThat(excludes(filter, Controller2.class)).isTrue();
9093
assertThat(excludes(filter, ExampleControllerAdvice.class)).isTrue();
9194
assertThat(excludes(filter, ExampleWeb.class)).isTrue();
95+
assertThat(excludes(filter, ExampleWebMvcRegistrations.class)).isTrue();
9296
assertThat(excludes(filter, ExampleMessageConverter.class)).isTrue();
9397
assertThat(excludes(filter, ExampleService.class)).isTrue();
9498
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
@@ -106,6 +110,7 @@ void matchWithIncludeFilter() throws Exception {
106110
assertThat(excludes(filter, Controller2.class)).isFalse();
107111
assertThat(excludes(filter, ExampleControllerAdvice.class)).isFalse();
108112
assertThat(excludes(filter, ExampleWeb.class)).isFalse();
113+
assertThat(excludes(filter, ExampleWebMvcRegistrations.class)).isFalse();
109114
assertThat(excludes(filter, ExampleMessageConverter.class)).isFalse();
110115
assertThat(excludes(filter, ExampleService.class)).isTrue();
111116
assertThat(excludes(filter, ExampleRepository.class)).isFalse();
@@ -121,6 +126,7 @@ void matchWithExcludeFilter() throws Exception {
121126
assertThat(excludes(filter, Controller2.class)).isFalse();
122127
assertThat(excludes(filter, ExampleControllerAdvice.class)).isFalse();
123128
assertThat(excludes(filter, ExampleWeb.class)).isFalse();
129+
assertThat(excludes(filter, ExampleWebMvcRegistrations.class)).isFalse();
124130
assertThat(excludes(filter, ExampleMessageConverter.class)).isFalse();
125131
assertThat(excludes(filter, ExampleService.class)).isTrue();
126132
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
@@ -180,6 +186,10 @@ static class ExampleWeb implements WebMvcConfigurer {
180186

181187
}
182188

189+
static class ExampleWebMvcRegistrations implements WebMvcRegistrations {
190+
191+
}
192+
183193
static class ExampleMessageConverter extends MappingJackson2HttpMessageConverter {
184194

185195
}

0 commit comments

Comments
 (0)