Browse Source

Merge branch '5.3.x'

# Conflicts:
#	spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java
pull/29282/head
Sam Brannen 3 years ago
parent
commit
c405e742f4
  1. 16
      spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java

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

@ -66,7 +66,6 @@ class PathMatchingResourcePatternResolverTests { @@ -66,7 +66,6 @@ class PathMatchingResourcePatternResolverTests {
void invalidPrefixWithPatternElementInItThrowsException() {
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() -> resolver.getResources("xx**:**/*.xy"));
}
}
@ -107,6 +106,21 @@ class PathMatchingResourcePatternResolverTests { @@ -107,6 +106,21 @@ class PathMatchingResourcePatternResolverTests {
assertExactFilenames(pattern, "resource#test1.txt", "resource#test2.txt");
assertExactSubPaths(pattern, pathPrefix, "resource#test1.txt", "resource#test2.txt");
}
@Test
void usingFileProtocolAndAssertingUrlAndUriSyntax() throws Exception {
Path testResourcesDir = Path.of("src/test/resources").toAbsolutePath();
String pattern = "file:%s/scanned-resources/**/resource#test1.txt".formatted(testResourcesDir);
Resource[] resources = resolver.getResources(pattern);
assertThat(resources).hasSize(1);
Resource resource = resources[0];
assertThat(resource.getFilename()).isEqualTo("resource#test1.txt");
// The following assertions serve as regression tests for the lack of the
// "authority component" (//) in the returned URI/URL. For example, we are
// expecting file:/my/path (or file:/C:/My/Path) instead of file:///my/path.
assertThat(resource.getURL().toString()).matches("^file:\\/[^\\/].+test1\\.txt$");
assertThat(resource.getURI().toString()).matches("^file:\\/[^\\/].+test1\\.txt$");
}
}
}

Loading…
Cancel
Save