Skip to content

Commit 2ce314d

Browse files
committed
Modify PathMatchingResourcePatternResolverTests so that it passes on main
See gh-29243
1 parent 5b08bc2 commit 2ce314d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import java.io.FileNotFoundException;
2020
import java.io.IOException;
2121
import java.io.UncheckedIOException;
22+
import java.net.URLDecoder;
2223
import java.nio.file.Path;
24+
import java.text.Normalizer;
2325
import java.util.Arrays;
2426
import java.util.List;
2527

@@ -29,6 +31,8 @@
2931
import org.springframework.core.io.Resource;
3032
import org.springframework.util.StringUtils;
3133

34+
import static java.nio.charset.StandardCharsets.UTF_8;
35+
import static java.text.Normalizer.Form.NFC;
3236
import static org.assertj.core.api.Assertions.assertThat;
3337
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3438

@@ -117,7 +121,7 @@ void usingClasspathStarProtocol() {
117121

118122
@Test
119123
void usingFilePrototol() {
120-
Path testResourcesDir = Paths.get("src/test/resources").toAbsolutePath();
124+
Path testResourcesDir = Path.of("src/test/resources").toAbsolutePath();
121125
String pattern = String.format("file:%s/japanese-resources/バリューオブジェクト/**/*.text", testResourcesDir);
122126
String pathPrefix = ".+japanese-resources/";
123127

@@ -208,8 +212,12 @@ private void assertExactSubPaths(String pattern, String pathPrefix, String... su
208212
Resource[] resources = resolver.getResources(pattern);
209213
List<String> actualSubPaths = Arrays.stream(resources)
210214
.map(resource -> getPath(resource).replaceFirst(pathPrefix, ""))
215+
// TODO Remove URL-decoding and Unicode normalization.
216+
// https://github.com/spring-projects/spring-framework/issues/29243
217+
.map(path -> URLDecoder.decode(path, UTF_8))
218+
.map(path -> Normalizer.normalize(path, NFC))
211219
.sorted()
212-
.collect(Collectors.toList());
220+
.toList();
213221
assertThat(actualSubPaths).containsExactlyInAnyOrder(subPaths);
214222
}
215223
catch (IOException ex) {

0 commit comments

Comments
 (0)