ClasspathScanner { @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", justification = "https: public void scanClasses() throws IOException { ClassGraph classGraph = new ClassGraph() .enableAllInfo() .enableExternalClasses() .enableSystemJarsAndModules(); classGraph = getClassGraphConfigurer().apply(classGraph); try (ScanResult scanResult = classGraph.scan()) { for (ScanResultHandler scanResultHandler : ServiceLoader.load(ScanResultHandler.class)) { scanResultHandler.handle(scanResult, getClasspathRoot()); } } }  @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", justification = "https://github.com/spotbugs/spotbugs/issues/756") void scanClasses();  }
@Test void scanClasses_noHandlers() throws IOException { this.classpathScanner.scanClasses(); }
@Test void scanClasses_myfaces_sci() throws IOException { this.classpathScanner.scanClasses(); File classesFile = new File(this.file, "META-INF/joinfaces/org.apache.myfaces.ee.MyFacesContainerInitializer.classes"); assertThat(classesFile).isFile(); List<String> classNames = Files.lines(classesFile.toPath(), StandardCharsets.UTF_8) .peek(log::debug) .collect(Collectors.toList()); assertThat(classNames).isNotEmpty(); }
@Test void scanClasses_mojarra_sci() throws IOException { this.classpathScanner.scanClasses(); File classesFile = new File(this.file, "META-INF/joinfaces/com.sun.faces.config.FacesInitializer.classes"); assertThat(classesFile).isFile(); List<String> classNames = Files.lines(classesFile.toPath(), StandardCharsets.UTF_8) .peek(log::debug) .collect(Collectors.toList()); assertThat(classNames).isNotEmpty(); }
@Test void scanClasses_myFacesAnnotations() throws IOException { this.classpathScanner.scanClasses(); File classesFile = new File(this.file, "META-INF/joinfaces/org.apache.myfaces.spi.AnnotationProvider.classes"); assertThat(classesFile).isFile(); List<String> mapEntries = Files.lines(classesFile.toPath(), StandardCharsets.UTF_8) .peek(log::debug) .collect(Collectors.toList()); assertThat(mapEntries).isNotEmpty(); Pattern pattern = Pattern.compile(".+=.?"); mapEntries.forEach(mapEntry -> assertThat(mapEntry).matches(pattern)); }
@Test void scanClasses_rewriteAnnotations() throws IOException { this.classpathScanner.scanClasses(); File classesFile = new File(this.file, "META-INF/joinfaces/" + RewriteAnnotationProviderHandler.REWRITE_ANNOTATION_HANDLER + ".classes"); assertThat(classesFile).isFile(); List<String> mapEntries = Files.lines(classesFile.toPath(), StandardCharsets.UTF_8) .peek(log::debug) .collect(Collectors.toList()); assertThat(mapEntries.size()).isEqualTo(1); assertThat(mapEntries.get(0)).isEqualTo(AnnotatedComponent.class.getName()); }