Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORE-3139] Add test case, and fix it again #767

Merged
merged 1 commit into from Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -93,6 +93,13 @@ public Set<String> list(String relativeTo, String path, boolean includeFiles, bo
if (path.startsWith("classpath*:")) {
path = path.replaceFirst("classpath\\*:", "");
}
// if path is like 'jar:<url>!/{entry}', use the last part as resource path
if (path.contains("!/")) {
String[] components = path.split("!/");
if (components.length > 1) {
path = components[components.length - 1];
}
}

// TODO:When we update to Java 7+, we can can create a FileSystem from the JAR (zip)
// file, and then use NIO's directory walking and filtering mechanisms to search through it.
Expand Down
Expand Up @@ -61,4 +61,19 @@ class ClassLoaderResourceAccessorTest extends Specification {
listedResources.contains("org/springframework/core/io/Resource.class")
!listedResources.contains("org/springframework/core/io/support/ResourcePatternUtils.class")
}

// Test case for [CORE-3139]
def "can recursively enumerate files inside JARs using JAR file URL"() {
given:
def accessor = new ClassLoaderResourceAccessor(Thread.currentThread().contextClassLoader)
def jarPkgURL = this.getClass().getClassLoader().getResource("org/springframework/core/io/").toExternalForm()

when:
def listedResources = accessor.list(null, jarPkgURL, true, false, true)

then:
listedResources.contains("org/springframework/core/io/Resource.class")
listedResources.contains("org/springframework/core/io/support/ResourcePatternUtils.class")
}

}