ClasspathScanUtil { public static Optional<Map<Class<? extends Annotation>, Set<Class<?>>>> readClassMap(String resourceName, ClassLoader classLoader) { return readClasses( resourceName, classLoader, ClasspathScanUtil::readClassMap ); }  static Optional<Set<Class<?>>> readClassSet(String resourceName, ClassLoader classLoader); static Optional<Map<Class<? extends Annotation>, Set<Class<?>>>> readClassMap(String resourceName, ClassLoader classLoader);  }
@Test void readClassMap() { Optional<Map<Class<? extends Annotation>, Set<Class<?>>>> classes = ClasspathScanUtil.readClassMap("META-INF/joinfaces/test-map.classes", getClass().getClassLoader()); assertThat(classes).isPresent(); assertThat(classes.get()).containsKeys(Autowired.class, Qualifier.class); }
@Test void readAnnotationClassMap() { String sb = "org.junit.jupiter.api.Test=org.joinfaces.autoconfigure.ClasspathScanUtil,org.joinfaces.autoconfigure.ClasspathScanUtilTest\n"; sb += "non.loadable.Annotation=org.joinfaces.autoconfigure.ClasspathScanUtil\n"; sb += "org.junit.jupiter.api.BeforeEach=\n"; sb += "org.junit.jupiter.api.BeforeAll=non.loadable.Class,org.joinfaces.autoconfigure.ClasspathScanUtil\n"; BufferedReader in = new BufferedReader(new StringReader(sb)); Map<Class<? extends Annotation>, Set<Class<?>>> map = ClasspathScanUtil.readClassMap(in, this.getClass().getClassLoader()); assertThat(map).containsKey(Test.class); assertThat(map).containsKey(BeforeEach.class); assertThat(map).containsKey(BeforeAll.class); assertThat(map).hasSize(3); assertThat(map.get(Test.class)).contains(ClasspathScanUtil.class, ClasspathScanUtilTest.class); assertThat(map.get(BeforeEach.class)).isEmpty(); assertThat(map.get(BeforeAll.class)).containsExactly(ClasspathScanUtil.class); }