Skip to content

Commit 67998e9

Browse files
committed
Revert "Include WebSecurityConfigurer beans in @WebMvcTest"
This reverts commit eef6fdb.
1 parent 6f06422 commit 67998e9

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@
3333
import org.springframework.core.convert.converter.GenericConverter;
3434
import org.springframework.http.converter.HttpMessageConverter;
3535
import org.springframework.stereotype.Controller;
36-
import org.springframework.util.ClassUtils;
3736
import org.springframework.util.ObjectUtils;
3837
import org.springframework.web.bind.annotation.ControllerAdvice;
3938
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
@@ -46,9 +45,6 @@
4645
*/
4746
class WebMvcTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
4847

49-
private static final String[] OPTIONAL_INCLUDES = {
50-
"org.springframework.security.config.annotation.web.WebSecurityConfigurer" };
51-
5248
private static final Set<Class<?>> DEFAULT_INCLUDES;
5349

5450
static {
@@ -64,13 +60,6 @@ class WebMvcTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
6460
includes.add(ErrorAttributes.class);
6561
includes.add(Converter.class);
6662
includes.add(GenericConverter.class);
67-
for (String optionalInclude : OPTIONAL_INCLUDES) {
68-
try {
69-
includes.add(ClassUtils.forName(optionalInclude, null));
70-
}
71-
catch (Exception ex) {
72-
}
73-
}
7463
DEFAULT_INCLUDES = Collections.unmodifiableSet(includes);
7564
}
7665

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
2626
import org.springframework.core.type.classreading.MetadataReaderFactory;
2727
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
2828
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
29-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
3029
import org.springframework.stereotype.Controller;
3130
import org.springframework.stereotype.Repository;
3231
import org.springframework.stereotype.Service;
@@ -55,7 +54,6 @@ public void matchWhenHasNoControllers() throws Exception {
5554
assertThat(excludes(filter, ExampleMessageConverter.class)).isFalse();
5655
assertThat(excludes(filter, ExampleService.class)).isTrue();
5756
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
58-
assertThat(excludes(filter, ExampleWebSecurityConfigurer.class)).isFalse();
5957
}
6058

6159
@Test
@@ -69,7 +67,6 @@ public void matchWhenHasController() throws Exception {
6967
assertThat(excludes(filter, ExampleMessageConverter.class)).isFalse();
7068
assertThat(excludes(filter, ExampleService.class)).isTrue();
7169
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
72-
assertThat(excludes(filter, ExampleWebSecurityConfigurer.class)).isFalse();
7370
}
7471

7572
@Test
@@ -83,7 +80,6 @@ public void matchNotUsingDefaultFilters() throws Exception {
8380
assertThat(excludes(filter, ExampleMessageConverter.class)).isTrue();
8481
assertThat(excludes(filter, ExampleService.class)).isTrue();
8582
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
86-
assertThat(excludes(filter, ExampleWebSecurityConfigurer.class)).isTrue();
8783
}
8884

8985
@Test
@@ -110,7 +106,6 @@ public void matchWithExcludeFilter() throws Exception {
110106
assertThat(excludes(filter, ExampleMessageConverter.class)).isFalse();
111107
assertThat(excludes(filter, ExampleService.class)).isTrue();
112108
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
113-
assertThat(excludes(filter, ExampleWebSecurityConfigurer.class)).isFalse();
114109
}
115110

116111
private boolean excludes(WebMvcTypeExcludeFilter filter, Class<?> type)
@@ -178,8 +173,4 @@ static class ExampleRepository {
178173

179174
}
180175

181-
static class ExampleWebSecurityConfigurer extends WebSecurityConfigurerAdapter {
182-
183-
}
184-
185176
}

0 commit comments

Comments
 (0)