|
|
|
|
@ -19,7 +19,9 @@ package org.springframework.core.io.support;
@@ -19,7 +19,9 @@ package org.springframework.core.io.support;
|
|
|
|
|
import java.io.FileNotFoundException; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.UncheckedIOException; |
|
|
|
|
import java.net.URLDecoder; |
|
|
|
|
import java.nio.file.Path; |
|
|
|
|
import java.text.Normalizer; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
@ -29,6 +31,8 @@ import org.junit.jupiter.api.Test;
@@ -29,6 +31,8 @@ import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.springframework.core.io.Resource; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
import static java.nio.charset.StandardCharsets.UTF_8; |
|
|
|
|
import static java.text.Normalizer.Form.NFC; |
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
|
|
|
|
|
|
|
|
|
@ -117,7 +121,7 @@ class PathMatchingResourcePatternResolverTests {
@@ -117,7 +121,7 @@ class PathMatchingResourcePatternResolverTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void usingFilePrototol() { |
|
|
|
|
Path testResourcesDir = Paths.get("src/test/resources").toAbsolutePath(); |
|
|
|
|
Path testResourcesDir = Path.of("src/test/resources").toAbsolutePath(); |
|
|
|
|
String pattern = String.format("file:%s/japanese-resources/バリューオブジェクト/**/*.text", testResourcesDir); |
|
|
|
|
String pathPrefix = ".+japanese-resources/"; |
|
|
|
|
|
|
|
|
|
@ -208,8 +212,12 @@ class PathMatchingResourcePatternResolverTests {
@@ -208,8 +212,12 @@ class PathMatchingResourcePatternResolverTests {
|
|
|
|
|
Resource[] resources = resolver.getResources(pattern); |
|
|
|
|
List<String> actualSubPaths = Arrays.stream(resources) |
|
|
|
|
.map(resource -> getPath(resource).replaceFirst(pathPrefix, "")) |
|
|
|
|
// TODO Remove URL-decoding and Unicode normalization.
|
|
|
|
|
// https://github.com/spring-projects/spring-framework/issues/29243
|
|
|
|
|
.map(path -> URLDecoder.decode(path, UTF_8)) |
|
|
|
|
.map(path -> Normalizer.normalize(path, NFC)) |
|
|
|
|
.sorted() |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
.toList(); |
|
|
|
|
assertThat(actualSubPaths).containsExactlyInAnyOrder(subPaths); |
|
|
|
|
} |
|
|
|
|
catch (IOException ex) { |
|
|
|
|
|