package io.github.lukehutch.fastclasspathscanner.issues.issue171;

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

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import org.junit.Test;

import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
import io.github.lukehutch.fastclasspathscanner.matchprocessor.FilenameMatchProcessor;

public class Issue171Test {
    @Test
    public void springBootFullyExecutableJar() throws IOException {
        final URL jarURL = Issue171Test.class.getClassLoader().getResource("spring-boot-fully-executable-jar.jar");
        final String childPath = "BOOT-INF/classes";

        final File parentJarfile = new File(jarURL.getFile());
        try (ZipFile zipFile = new ZipFile(new File(jarURL.getFile()))) {
            final ZipEntry ent = zipFile.getEntry(childPath);
            System.out.println("Child path component " + childPath + " in jarfile " + parentJarfile
                    + " is a directory: " + ent.isDirectory());
        } catch (final IOException e) {
            e.printStackTrace();
        }
        final List<String> paths = new ArrayList<>();
        new FastClasspathScanner().overrideClasspath(jarURL + "!/" + childPath)
                .matchFilenamePattern(".*", (FilenameMatchProcessor) (classpathElt, relativePath) -> {
                    paths.add(relativePath);
                }).scan();
        assertThat(paths).containsOnly("hello/HelloController.class", "hello/Application.class");
    }
}

@@ -123,29 +123,8 @@
 t;%0A%0A
-import java.io.File;%0A
 impo
@@ -147,16 +147,16 @@
 eption;%0A
+
 import j
@@ -222,69 +222,8 @@
 ist;
-%0Aimport java.util.zip.ZipEntry;%0Aimport java.util.zip.ZipFile;
 %0A%0Aim
@@ -678,16 +678,26 @@
 sses%22;%0A%0A
+        //
         
@@ -747,24 +747,34 @@
 getFile());%0A
+        //
         try 
@@ -831,24 +831,34 @@
 File()))) %7B%0A
+        //
             
@@ -903,24 +903,34 @@
 childPath);%0A
+        //
             
@@ -1017,16 +1017,26 @@
 Jarfile%0A
+        //
         
@@ -1087,24 +1087,34 @@
 rectory());%0A
+        //
         %7D ca
@@ -1137,24 +1137,34 @@
 eption e) %7B%0A
+        //
             
@@ -1180,24 +1180,34 @@
 ackTrace();%0A
+        //
         %7D%0A  

Comment out print statement