File tree Expand file tree Collapse file tree
spring-test/src/main/java/org/springframework/test/context Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ private static Class<?> resolveExplicitTestContextBootstrapper(Class<?> testClas
179179 }
180180
181181 private static Class <?> resolveDefaultTestContextBootstrapper (Class <?> testClass ) throws Exception {
182- boolean webApp = ( TestContextAnnotationUtils .findMergedAnnotation (testClass , webAppConfigurationClass ) != null );
182+ boolean webApp = TestContextAnnotationUtils .hasAnnotation (testClass , webAppConfigurationClass );
183183 String bootstrapperClassName = (webApp ? DEFAULT_WEB_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME :
184184 DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME );
185185 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 {
7878 private static volatile EnclosingConfiguration defaultEnclosingConfigurationMode ;
7979
8080
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+
8197 /**
8298 * Find the first annotation of the specified {@code annotationType} within
8399 * the annotation hierarchy <em>above</em> the supplied class, merge that
You can’t perform that action at this time.
0 commit comments