Skip to content

Commit

Permalink
Verify PathMatchingResourcePatternResolver finds local files with # i…
Browse files Browse the repository at this point in the history
…n name

This commit introduces a test that verifies that
PathMatchingResourcePatternResolver can find files in the filesystem
that contain hashtags (#) in their names.

See gh-23532
  • Loading branch information
sbrannen committed Aug 28, 2019
1 parent 5af4d22 commit b173a93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Expand Up @@ -16,6 +16,7 @@

package org.springframework.core.io.support;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -96,6 +97,13 @@ void classpathStarWithPatternOnFileSystem() throws IOException {
StringUtils.concatenateStringArrays(CLASSES_IN_CORE_IO_SUPPORT, TEST_CLASSES_IN_CORE_IO_SUPPORT));
}

@Test
void getResourcesOnFileSystemContainingHashtagsInTheirFileNames() throws IOException {
Resource[] resources = resolver.getResources("classpath*:org/springframework/core/io/**/resource#test*.txt");
assertThat(resources).extracting(Resource::getFile).extracting(File::getName)
.containsExactlyInAnyOrder("resource#test1.txt", "resource#test2.txt");
}

@Test
void classpathWithPatternInJar() throws IOException {
Resource[] resources = resolver.getResources("classpath:org/reactivestreams/*.class");
Expand Down
@@ -0,0 +1 @@
test 1
@@ -0,0 +1 @@
test 2

0 comments on commit b173a93

Please sign in to comment.