File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
spring-test/src/main/java/org/springframework/test/context Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ private static Class<?> resolveExplicitTestContextBootstrapper(Class<?> testClas
179
179
}
180
180
181
181
private static Class <?> resolveDefaultTestContextBootstrapper (Class <?> testClass ) throws Exception {
182
- boolean webApp = ( TestContextAnnotationUtils .findMergedAnnotation (testClass , webAppConfigurationClass ) != null );
182
+ boolean webApp = TestContextAnnotationUtils .hasAnnotation (testClass , webAppConfigurationClass );
183
183
String bootstrapperClassName = (webApp ? DEFAULT_WEB_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME :
184
184
DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME );
185
185
return ClassUtils .forName (bootstrapperClassName , BootstrapUtils .class .getClassLoader ());
Original file line number Diff line number Diff line change @@ -78,6 +78,22 @@ public abstract class TestContextAnnotationUtils {
78
78
private static volatile EnclosingConfiguration defaultEnclosingConfigurationMode ;
79
79
80
80
81
+ /**
82
+ * Determine if an annotation of the specified {@code annotationType} is
83
+ * present or meta-present on the supplied {@link Class} according to the
84
+ * search algorithm used in {@link #findMergedAnnotation(Class, Class)}.
85
+ * <p>If this method returns {@code true}, then {@code findMergedAnnotation(...)}
86
+ * will return a non-null value.
87
+ * @param clazz the class to look for annotations on
88
+ * @param annotationType the type of annotation to look for
89
+ * @return {@code true} if a matching annotation is present
90
+ * @since 5.3.3
91
+ * @see #findMergedAnnotation(Class, Class)
92
+ */
93
+ public static boolean hasAnnotation (Class <?> clazz , Class <? extends Annotation > annotationType ) {
94
+ return (findMergedAnnotation (clazz , annotationType ) != null );
95
+ }
96
+
81
97
/**
82
98
* Find the first annotation of the specified {@code annotationType} within
83
99
* the annotation hierarchy <em>above</em> the supplied class, merge that
You can’t perform that action at this time.
0 commit comments