Skip to content

Commit b173a93

Browse files
committed
Verify PathMatchingResourcePatternResolver finds local files with # in name
This commit introduces a test that verifies that PathMatchingResourcePatternResolver can find files in the filesystem that contain hashtags (#) in their names. See spring-projectsgh-23532
1 parent 5af4d22 commit b173a93

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.core.io.support;
1818

19+
import java.io.File;
1920
import java.io.FileNotFoundException;
2021
import java.io.IOException;
2122
import java.util.ArrayList;
@@ -96,6 +97,13 @@ void classpathStarWithPatternOnFileSystem() throws IOException {
9697
StringUtils.concatenateStringArrays(CLASSES_IN_CORE_IO_SUPPORT, TEST_CLASSES_IN_CORE_IO_SUPPORT));
9798
}
9899

100+
@Test
101+
void getResourcesOnFileSystemContainingHashtagsInTheirFileNames() throws IOException {
102+
Resource[] resources = resolver.getResources("classpath*:org/springframework/core/io/**/resource#test*.txt");
103+
assertThat(resources).extracting(Resource::getFile).extracting(File::getName)
104+
.containsExactlyInAnyOrder("resource#test1.txt", "resource#test2.txt");
105+
}
106+
99107
@Test
100108
void classpathWithPatternInJar() throws IOException {
101109
Resource[] resources = resolver.getResources("classpath:org/reactivestreams/*.class");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test 2

0 commit comments

Comments
 (0)