mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Permit use of @JsonTest without Jackson
See gh-16070
This commit is contained in:
parent
6ffa80870d
commit
36f7188334
@ -20,13 +20,12 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.Module;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.TypeExcludeFilter;
|
import org.springframework.boot.context.TypeExcludeFilter;
|
||||||
import org.springframework.boot.jackson.JsonComponent;
|
import org.springframework.boot.jackson.JsonComponent;
|
||||||
import org.springframework.boot.test.autoconfigure.filter.AnnotationCustomizableTypeExcludeFilter;
|
import org.springframework.boot.test.autoconfigure.filter.AnnotationCustomizableTypeExcludeFilter;
|
||||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||||
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link TypeExcludeFilter} for {@link JsonTest @JsonTest}.
|
* {@link TypeExcludeFilter} for {@link JsonTest @JsonTest}.
|
||||||
@ -39,8 +38,12 @@ class JsonExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
Set<Class<?>> includes = new LinkedHashSet<Class<?>>();
|
Set<Class<?>> includes = new LinkedHashSet<Class<?>>();
|
||||||
includes.add(Module.class);
|
|
||||||
includes.add(JsonComponent.class);
|
includes.add(JsonComponent.class);
|
||||||
|
try {
|
||||||
|
includes.add(ClassUtils.forName("com.fasterxml.jackson.databind.Module", null));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
DEFAULT_INCLUDES = Collections.unmodifiableSet(includes);
|
DEFAULT_INCLUDES = Collections.unmodifiableSet(includes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user