Browse Source

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
pull/18854/head
Andy Wilkinson 6 years ago
parent
commit
9ed4207f0c
  1. 3
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTypeExcludeFilter.java
  2. 3
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTypeExcludeFilter.java
  3. 3
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTypeExcludeFilter.java
  4. 3
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTypeExcludeFilter.java
  5. 3
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTypeExcludeFilter.java
  6. 3
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTypeExcludeFilter.java
  7. 3
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTypeExcludeFilter.java
  8. 2
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java
  9. 5
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTypeExcludeFilter.java
  10. 3
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTypeExcludeFilter.java
  11. 2
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java
  12. 9
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTypeExcludeFilter.java
  13. 3
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java
  14. 3
      spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilter.java

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

@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust @@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust
* {@link TypeExcludeFilter} for {@link DataJdbcTest @DataJdbcTest}.
*
* @author Andy Wilkinson
* @since 2.2.1
*/
class DataJdbcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataJdbcTest> {
public final class DataJdbcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataJdbcTest> {
DataJdbcTypeExcludeFilter(Class<?> testClass) {
super(testClass);

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

@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust @@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust
* {@link TypeExcludeFilter} for {@link DataLdapTest @DataLdapTest}.
*
* @author Eddú Meléndez
* @since 2.2.1
*/
class DataLdapTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataLdapTest> {
public final class DataLdapTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataLdapTest> {
DataLdapTypeExcludeFilter(Class<?> testClass) {
super(testClass);

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

@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust @@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust
* {@link TypeExcludeFilter} for {@link DataMongoTest @DataMongoTest}.
*
* @author Michael Simons
* @since 2.2.1
*/
class DataMongoTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataMongoTest> {
public final class DataMongoTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataMongoTest> {
DataMongoTypeExcludeFilter(Class<?> testClass) {
super(testClass);

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

@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust @@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust
* {@link TypeExcludeFilter} for {@link DataNeo4jTest @DataNeo4jTest}.
*
* @author Eddú Meléndez
* @since 2.2.1
*/
class DataNeo4jTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataNeo4jTest> {
public final class DataNeo4jTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataNeo4jTest> {
DataNeo4jTypeExcludeFilter(Class<?> testClass) {
super(testClass);

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

@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust @@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust
* {@link TypeExcludeFilter} for {@link DataRedisTest @DataRedisTest}.
*
* @author Jayaram Pradhan
* @since 2.2.1
*/
class DataRedisTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataRedisTest> {
public final class DataRedisTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataRedisTest> {
DataRedisTypeExcludeFilter(Class<?> testClass) {
super(testClass);

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

@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust @@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust
* {@link TypeExcludeFilter} for {@link JdbcTest @JdbcTest}.
*
* @author Stephane Nicoll
* @since 2.2.1
*/
class JdbcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JdbcTest> {
public final class JdbcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JdbcTest> {
JdbcTypeExcludeFilter(Class<?> testClass) {
super(testClass);

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

@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust @@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust
* {@link TypeExcludeFilter} for {@link JooqTest @JooqTest}.
*
* @author Michael Simons
* @since 2.2.1
*/
class JooqTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JooqTest> {
public final class JooqTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JooqTest> {
JooqTypeExcludeFilter(Class<?> testClass) {
super(testClass);

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

@ -68,7 +68,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -68,7 +68,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@BootstrapWith(JsonTestContextBootstrapper.class)
@ExtendWith(SpringExtension.class)
@OverrideAutoConfiguration(enabled = false)
@TypeExcludeFilters(JsonExcludeFilter.class)
@TypeExcludeFilters(JsonTypeExcludeFilter.class)
@AutoConfigureCache
@AutoConfigureJson
@AutoConfigureJsonTesters

5
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonExcludeFilter.java → spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTypeExcludeFilter.java

@ -29,8 +29,9 @@ import org.springframework.util.ClassUtils; @@ -29,8 +29,9 @@ import org.springframework.util.ClassUtils;
* {@link TypeExcludeFilter} for {@link JsonTest @JsonTest}.
*
* @author Phillip Webb
* @since 2.2.1
*/
class JsonExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JsonTest> {
public final class JsonTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<JsonTest> {
private static final String JACKSON_MODULE = "com.fasterxml.jackson.databind.Module";
@ -47,7 +48,7 @@ class JsonExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter< @@ -47,7 +48,7 @@ class JsonExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<
DEFAULT_INCLUDES = Collections.unmodifiableSet(includes);
}
JsonExcludeFilter(Class<?> testClass) {
JsonTypeExcludeFilter(Class<?> testClass) {
super(testClass);
}

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

@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust @@ -23,8 +23,9 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust
* {@link TypeExcludeFilter} for {@link DataJpaTest @DataJpaTest}.
*
* @author Phillip Webb
* @since 2.2.1
*/
class DataJpaTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataJpaTest> {
public final class DataJpaTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataJpaTest> {
DataJpaTypeExcludeFilter(Class<?> testClass) {
super(testClass);

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

@ -72,7 +72,7 @@ import org.springframework.web.client.RestTemplate; @@ -72,7 +72,7 @@ import org.springframework.web.client.RestTemplate;
@BootstrapWith(RestClientTestContextBootstrapper.class)
@ExtendWith(SpringExtension.class)
@OverrideAutoConfiguration(enabled = false)
@TypeExcludeFilters(RestClientExcludeFilter.class)
@TypeExcludeFilters(RestClientTypeExcludeFilter.class)
@AutoConfigureCache
@AutoConfigureWebClient
@AutoConfigureMockRestServiceServer

9
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientExcludeFilter.java → spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTypeExcludeFilter.java

@ -30,8 +30,9 @@ import org.springframework.util.ClassUtils; @@ -30,8 +30,9 @@ import org.springframework.util.ClassUtils;
* {@link TypeExcludeFilter} for {@link RestClientTest @RestClientTest}.
*
* @author Stephane Nicoll
* @since 2.2.1
*/
class RestClientExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<RestClientTest> {
public final class RestClientTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<RestClientTest> {
private static final Class<?>[] NO_COMPONENTS = {};
@ -41,10 +42,10 @@ class RestClientExcludeFilter extends StandardAnnotationCustomizableTypeExcludeF @@ -41,10 +42,10 @@ class RestClientExcludeFilter extends StandardAnnotationCustomizableTypeExcludeF
static {
Set<Class<?>> includes = new LinkedHashSet<>();
if (ClassUtils.isPresent(DATABIND_MODULE_CLASS_NAME, RestClientExcludeFilter.class.getClassLoader())) {
if (ClassUtils.isPresent(DATABIND_MODULE_CLASS_NAME, RestClientTypeExcludeFilter.class.getClassLoader())) {
try {
includes.add(Class.forName(DATABIND_MODULE_CLASS_NAME, true,
RestClientExcludeFilter.class.getClassLoader()));
RestClientTypeExcludeFilter.class.getClassLoader()));
}
catch (ClassNotFoundException ex) {
throw new IllegalStateException("Failed to load " + DATABIND_MODULE_CLASS_NAME, ex);
@ -56,7 +57,7 @@ class RestClientExcludeFilter extends StandardAnnotationCustomizableTypeExcludeF @@ -56,7 +57,7 @@ class RestClientExcludeFilter extends StandardAnnotationCustomizableTypeExcludeF
private final Class<?>[] components;
RestClientExcludeFilter(Class<?> testClass) {
RestClientTypeExcludeFilter(Class<?> testClass) {
super(testClass);
this.components = getAnnotation().getValue("components", Class[].class).orElse(NO_COMPONENTS);
}

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

@ -37,8 +37,9 @@ import org.springframework.web.server.WebFilter; @@ -37,8 +37,9 @@ import org.springframework.web.server.WebFilter;
* {@link TypeExcludeFilter} for {@link WebFluxTest @WebFluxTest}.
*
* @author Stephane Nicoll
* @since 2.2.1
*/
class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<WebFluxTest> {
public final class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<WebFluxTest> {
private static final Class<?>[] NO_CONTROLLERS = {};

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

@ -43,8 +43,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -43,8 +43,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
*
* @author Phillip Webb
* @author Madhura Bhave
* @since 2.2.1
*/
class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<WebMvcTest> {
public final class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<WebMvcTest> {
private static final Class<?>[] NO_CONTROLLERS = {};

Loading…
Cancel
Save