Browse Source

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 gh-23532
pull/23540/head
Sam Brannen 7 years ago
parent
commit
b173a93e72
  1. 8
      spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java
  2. 1
      spring-core/src/test/resources/org/springframework/core/io/support/resource#test1.txt
  3. 1
      spring-core/src/test/resources/org/springframework/core/io/support/resource#test2.txt

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

@ -16,6 +16,7 @@ @@ -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;
@ -96,6 +97,13 @@ class PathMatchingResourcePatternResolverTests { @@ -96,6 +97,13 @@ class PathMatchingResourcePatternResolverTests {
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");

1
spring-core/src/test/resources/org/springframework/core/io/support/resource#test1.txt

@ -0,0 +1 @@ @@ -0,0 +1 @@
test 1

1
spring-core/src/test/resources/org/springframework/core/io/support/resource#test2.txt

@ -0,0 +1 @@ @@ -0,0 +1 @@
test 2
Loading…
Cancel
Save