package io.github.classgraph.issues.issue352;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.File;
import java.io.IOException;

import org.junit.Test;
import org.ops4j.pax.url.mvn.MavenResolvers;

import io.github.classgraph.ClassGraph;
import io.github.classgraph.ScanResult;

/**
 * Unit test.
 */
public class Issue352 {
    /** Test that module-info.class is not included in results if the root package ("") is not whitelisted. */
    @Test
    public void test() throws IOException {
        final File resolvedFile = MavenResolvers.createMavenResolver(null, null).resolve("com.sun.istack",
                "istack-commons-runtime", null, null, "3.0.7");
        assertThat(resolvedFile).isFile();

        try (ScanResult scanResult = new ClassGraph().overrideClasspath(resolvedFile)
                .whitelistPackages("com.sun.istack").enableClassInfo().scan()) {
            assertThat(scanResult.getAllResources().getPaths()).doesNotContain("module-info.class");
        }
    }
}

@@ -297,16 +297,74 @@
 nResult;
+%0Aimport io.github.classgraph.issues.issue107.Issue107Test;
 %0A%0A/**%0A *
@@ -420,103 +420,9 @@
 est 
-that module-info.class is not included in results if the root package (%22%22) is not whitelisted. 
+*
 */%0A 
@@ -701,265 +701,1404 @@
     
-try (ScanResult scanResult = new ClassGraph().overrideClasspath(resolvedFile)%0A                .whitelistPackages(%22com.sun.istack%22).enableClassInfo().scan()) %7B%0A            assertThat(scanResult.getAllResources().getPaths()).doesNotContain(%22module-info.class%22
+// Test that module-info.class is not included in resource list if the root package (%22%22) is not whitelisted%0A        try (ScanResult scanResult = new ClassGraph().overrideClasspath(resolvedFile)%0A                .whitelistPackagesNonRecursive(%22%22).enableClassInfo().scan()) %7B%0A            assertThat(scanResult.getAllResources().getPaths()).contains(%22module-info.class%22);%0A        %7D%0A        try (ScanResult scanResult = new ClassGraph().overrideClasspath(resolvedFile)%0A                .whitelistPackages(%22com.sun.istack%22).enableClassInfo().scan()) %7B%0A            assertThat(scanResult.getAllResources().getPaths()).doesNotContain(%22module-info.class%22);%0A        %7D%0A%0A        // Test that package-info.class is only included in resource list for whitelisted packages %0A        final String pkgInfoPath = Issue107Test.class.getPackage().getName().replace('.', '/')%0A                + %22/package-info.class%22;%0A        try (ScanResult scanResult = new ClassGraph().whitelistPackages(Issue107Test.class.getPackage().getName())%0A                .enableClassInfo().scan()) %7B%0A            assertThat(scanResult.getAllResources().getPaths()).contains(pkgInfoPath);%0A        %7D%0A        try (ScanResult scanResult = new ClassGraph().whitelistPackages(Issue352.class.getPackage().getName())%0A                .enableClassInfo().scan()) %7B%0A            assertThat(scanResult.getAllResources().getPaths()).doesNotContain(pkgInfoPath
 );%0A 

Improve unit test