From d92441e53f78068e4f975d4d680eef6760375f1f Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 3 Aug 2018 04:27:49 +0900 Subject: [PATCH] Update assertion message in AnnotatedClassFinder.scanPackage() Closes gh-13989 --- .../boot/test/context/AnnotatedClassFinder.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java index 2e86dfa669..e7330e7a36 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java @@ -41,6 +41,8 @@ public final class AnnotatedClassFinder { private static final Map> cache = Collections .synchronizedMap(new Cache(40)); + private final Class annotationType; + private final ClassPathScanningCandidateComponentProvider scanner; /** @@ -49,6 +51,7 @@ public final class AnnotatedClassFinder { */ public AnnotatedClassFinder(Class annotationType) { Assert.notNull(annotationType, "AnnotationType must not be null"); + this.annotationType = annotationType; this.scanner = new ClassPathScanningCandidateComponentProvider(false); this.scanner.addIncludeFilter(new AnnotationTypeFilter(annotationType)); this.scanner.setResourcePattern("*.class"); @@ -88,8 +91,8 @@ public final class AnnotatedClassFinder { Set components = this.scanner.findCandidateComponents(source); if (!components.isEmpty()) { Assert.state(components.size() == 1, - () -> "Found multiple @SpringBootConfiguration annotated classes " - + components); + () -> "Found multiple @" + this.annotationType.getSimpleName() + + " annotated classes " + components); return ClassUtils.resolveClassName( components.iterator().next().getBeanClassName(), null); }