Introduce TestContextAnnotationUtils.hasAnnotation()
This commit is contained in:
parent
1292947f78
commit
b3a47c76f8
|
@ -179,7 +179,7 @@ abstract class BootstrapUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Class<?> resolveDefaultTestContextBootstrapper(Class<?> testClass) throws Exception {
|
private static Class<?> resolveDefaultTestContextBootstrapper(Class<?> testClass) throws Exception {
|
||||||
boolean webApp = (TestContextAnnotationUtils.findMergedAnnotation(testClass, webAppConfigurationClass) != null);
|
boolean webApp = TestContextAnnotationUtils.hasAnnotation(testClass, webAppConfigurationClass);
|
||||||
String bootstrapperClassName = (webApp ? DEFAULT_WEB_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME :
|
String bootstrapperClassName = (webApp ? DEFAULT_WEB_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME :
|
||||||
DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME);
|
DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME);
|
||||||
return ClassUtils.forName(bootstrapperClassName, BootstrapUtils.class.getClassLoader());
|
return ClassUtils.forName(bootstrapperClassName, BootstrapUtils.class.getClassLoader());
|
||||||
|
|
|
@ -78,6 +78,22 @@ public abstract class TestContextAnnotationUtils {
|
||||||
private static volatile EnclosingConfiguration defaultEnclosingConfigurationMode;
|
private static volatile EnclosingConfiguration defaultEnclosingConfigurationMode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if an annotation of the specified {@code annotationType} is
|
||||||
|
* present or meta-present on the supplied {@link Class} according to the
|
||||||
|
* search algorithm used in {@link #findMergedAnnotation(Class, Class)}.
|
||||||
|
* <p>If this method returns {@code true}, then {@code findMergedAnnotation(...)}
|
||||||
|
* will return a non-null value.
|
||||||
|
* @param clazz the class to look for annotations on
|
||||||
|
* @param annotationType the type of annotation to look for
|
||||||
|
* @return {@code true} if a matching annotation is present
|
||||||
|
* @since 5.3.3
|
||||||
|
* @see #findMergedAnnotation(Class, Class)
|
||||||
|
*/
|
||||||
|
public static boolean hasAnnotation(Class<?> clazz, Class<? extends Annotation> annotationType) {
|
||||||
|
return (findMergedAnnotation(clazz, annotationType) != null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the first annotation of the specified {@code annotationType} within
|
* Find the first annotation of the specified {@code annotationType} within
|
||||||
* the annotation hierarchy <em>above</em> the supplied class, merge that
|
* the annotation hierarchy <em>above</em> the supplied class, merge that
|
||||||
|
|
Loading…
Reference in New Issue