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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<
|
||||
DEFAULT_INCLUDES = Collections.unmodifiableSet(includes);
|
||||
}
|
||||
|
||||
JsonExcludeFilter(Class<?> testClass) {
|
||||
JsonTypeExcludeFilter(Class<?> testClass) {
|
||||
super(testClass);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
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
|
||||
|
||||
private final Class<?>[] components;
|
||||
|
||||
RestClientExcludeFilter(Class<?> testClass) {
|
||||
RestClientTypeExcludeFilter(Class<?> testClass) {
|
||||
super(testClass);
|
||||
this.components = getAnnotation().getValue("components", Class[].class).orElse(NO_COMPONENTS);
|
||||
}
|
||||
@@ -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 = {};
|
||||
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user