Skip to content

Commit 9ed4207

Browse files
committed
Make TypeExcludeFilters public so they can be composed with user's own
Previously, all of the type exclude filters in spring-boot-test-autoconfigure were package-private. This prevent a user who was creating their own test slice from composing their own TypeExcludeFilter with one of Boot's. This commit updates all of the TypeExcludeFilters in the test-autoconfigure module to make them public. The intention is only to allow them to be composed with other type exclude filters when referenced in a @TypeExcludeFilters annotation. Therefore, each filter class is declared final and their constructors remain package-private. Closes gh-18746
1 parent 1c25b58 commit 9ed4207

File tree

14 files changed

+30
-18
lines changed

14 files changed

+30
-18
lines changed

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTypeExcludeFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
* {@link TypeExcludeFilter} for {@link DataJdbcTest @DataJdbcTest}.
2424
*
2525
* @author Andy Wilkinson
26+
* @since 2.2.1
2627
*/
27-
class DataJdbcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataJdbcTest> {
28+
public final class DataJdbcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataJdbcTest> {
2829

2930
DataJdbcTypeExcludeFilter(Class<?> testClass) {
3031
super(testClass);

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTypeExcludeFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
* {@link TypeExcludeFilter} for {@link DataLdapTest @DataLdapTest}.
2424
*
2525
* @author Eddú Meléndez
26+
* @since 2.2.1
2627
*/
27-
class DataLdapTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataLdapTest> {
28+
public final class DataLdapTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataLdapTest> {
2829

2930
DataLdapTypeExcludeFilter(Class<?> testClass) {
3031
super(testClass);

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTypeExcludeFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
* {@link TypeExcludeFilter} for {@link DataMongoTest @DataMongoTest}.
2424
*
2525
* @author Michael Simons
26+
* @since 2.2.1
2627
*/
27-
class DataMongoTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataMongoTest> {
28+
public final class DataMongoTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataMongoTest> {
2829

2930
DataMongoTypeExcludeFilter(Class<?> testClass) {
3031
super(testClass);

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTypeExcludeFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
* {@link TypeExcludeFilter} for {@link DataNeo4jTest @DataNeo4jTest}.
2424
*
2525
* @author Eddú Meléndez
26+
* @since 2.2.1
2627
*/
27-
class DataNeo4jTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataNeo4jTest> {
28+
public final class DataNeo4jTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataNeo4jTest> {
2829

2930
DataNeo4jTypeExcludeFilter(Class<?> testClass) {
3031
super(testClass);

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTypeExcludeFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
* {@link TypeExcludeFilter} for {@link DataRedisTest @DataRedisTest}.
2424
*
2525
* @author Jayaram Pradhan
26+
* @since 2.2.1
2627
*/
27-
class DataRedisTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataRedisTest> {
28+
public final class DataRedisTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataRedisTest> {
2829

2930
DataRedisTypeExcludeFilter(Class<?> testClass) {
3031
super(testClass);

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTypeExcludeFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
* {@link TypeExcludeFilter} for {@link JdbcTest @JdbcTest}.
2424
*
2525
* @author Stephane Nicoll
26+
* @since 2.2.1
2627
*/
27-
class JdbcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JdbcTest> {
28+
public final class JdbcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JdbcTest> {
2829

2930
JdbcTypeExcludeFilter(Class<?> testClass) {
3031
super(testClass);

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTypeExcludeFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
* {@link TypeExcludeFilter} for {@link JooqTest @JooqTest}.
2424
*
2525
* @author Michael Simons
26+
* @since 2.2.1
2627
*/
27-
class JooqTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JooqTest> {
28+
public final class JooqTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JooqTest> {
2829

2930
JooqTypeExcludeFilter(Class<?> testClass) {
3031
super(testClass);

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
@BootstrapWith(JsonTestContextBootstrapper.class)
6969
@ExtendWith(SpringExtension.class)
7070
@OverrideAutoConfiguration(enabled = false)
71-
@TypeExcludeFilters(JsonExcludeFilter.class)
71+
@TypeExcludeFilters(JsonTypeExcludeFilter.class)
7272
@AutoConfigureCache
7373
@AutoConfigureJson
7474
@AutoConfigureJsonTesters
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
* {@link TypeExcludeFilter} for {@link JsonTest @JsonTest}.
3030
*
3131
* @author Phillip Webb
32+
* @since 2.2.1
3233
*/
33-
class JsonExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JsonTest> {
34+
public final class JsonTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JsonTest> {
3435

3536
private static final String JACKSON_MODULE = "com.fasterxml.jackson.databind.Module";
3637

@@ -47,7 +48,7 @@ class JsonExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<
4748
DEFAULT_INCLUDES = Collections.unmodifiableSet(includes);
4849
}
4950

50-
JsonExcludeFilter(Class<?> testClass) {
51+
JsonTypeExcludeFilter(Class<?> testClass) {
5152
super(testClass);
5253
}
5354

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTypeExcludeFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
* {@link TypeExcludeFilter} for {@link DataJpaTest @DataJpaTest}.
2424
*
2525
* @author Phillip Webb
26+
* @since 2.2.1
2627
*/
27-
class DataJpaTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataJpaTest> {
28+
public final class DataJpaTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataJpaTest> {
2829

2930
DataJpaTypeExcludeFilter(Class<?> testClass) {
3031
super(testClass);

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
@BootstrapWith(RestClientTestContextBootstrapper.class)
7373
@ExtendWith(SpringExtension.class)
7474
@OverrideAutoConfiguration(enabled = false)
75-
@TypeExcludeFilters(RestClientExcludeFilter.class)
75+
@TypeExcludeFilters(RestClientTypeExcludeFilter.class)
7676
@AutoConfigureCache
7777
@AutoConfigureWebClient
7878
@AutoConfigureMockRestServiceServer
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
* {@link TypeExcludeFilter} for {@link RestClientTest @RestClientTest}.
3131
*
3232
* @author Stephane Nicoll
33+
* @since 2.2.1
3334
*/
34-
class RestClientExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<RestClientTest> {
35+
public final class RestClientTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<RestClientTest> {
3536

3637
private static final Class<?>[] NO_COMPONENTS = {};
3738

@@ -41,10 +42,10 @@ class RestClientExcludeFilter extends StandardAnnotationCustomizableTypeExcludeF
4142

4243
static {
4344
Set<Class<?>> includes = new LinkedHashSet<>();
44-
if (ClassUtils.isPresent(DATABIND_MODULE_CLASS_NAME, RestClientExcludeFilter.class.getClassLoader())) {
45+
if (ClassUtils.isPresent(DATABIND_MODULE_CLASS_NAME, RestClientTypeExcludeFilter.class.getClassLoader())) {
4546
try {
4647
includes.add(Class.forName(DATABIND_MODULE_CLASS_NAME, true,
47-
RestClientExcludeFilter.class.getClassLoader()));
48+
RestClientTypeExcludeFilter.class.getClassLoader()));
4849
}
4950
catch (ClassNotFoundException ex) {
5051
throw new IllegalStateException("Failed to load " + DATABIND_MODULE_CLASS_NAME, ex);
@@ -56,7 +57,7 @@ class RestClientExcludeFilter extends StandardAnnotationCustomizableTypeExcludeF
5657

5758
private final Class<?>[] components;
5859

59-
RestClientExcludeFilter(Class<?> testClass) {
60+
RestClientTypeExcludeFilter(Class<?> testClass) {
6061
super(testClass);
6162
this.components = getAnnotation().getValue("components", Class[].class).orElse(NO_COMPONENTS);
6263
}

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
* {@link TypeExcludeFilter} for {@link WebFluxTest @WebFluxTest}.
3838
*
3939
* @author Stephane Nicoll
40+
* @since 2.2.1
4041
*/
41-
class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<WebFluxTest> {
42+
public final class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<WebFluxTest> {
4243

4344
private static final Class<?>[] NO_CONTROLLERS = {};
4445

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
*
4444
* @author Phillip Webb
4545
* @author Madhura Bhave
46+
* @since 2.2.1
4647
*/
47-
class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<WebMvcTest> {
48+
public final class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<WebMvcTest> {
4849

4950
private static final Class<?>[] NO_CONTROLLERS = {};
5051

0 commit comments

Comments
 (0)