Browse Source

Merge branch '5.3.x'

pull/29282/head
Sam Brannen 2 years ago
parent
commit
5b08bc29b1
  1. 26
      spring-core/src/test/java/example/japanese/バリューオブジェクト/バリューオブジェクト.java
  2. 47
      spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java
  3. 1
      spring-core/src/test/resources/japanese-resources/バリューオブジェクト/バリューオブジェクト.text
  4. 2
      src/checkstyle/checkstyle-suppressions.xml

26
spring-core/src/test/java/example/japanese/バリューオブジェクト/バリューオブジェクト.java

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
/*
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package example.japanese.バリューオブジェクト;
/**
* This class and its package exist in order to test encoding and Unicode
* normalization for resource paths discovered via classpath scanning.
*
* <p>"バリューオブジェクト" is Japanese for "value object".
*/
public class バリューオブジェクト {
}

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

@ -103,6 +103,30 @@ class PathMatchingResourcePatternResolverTests { @@ -103,6 +103,30 @@ class PathMatchingResourcePatternResolverTests {
}
@Nested
class ContainingJapaneseCharactersInTheirPathsAndFileNames {
@Test
void usingClasspathStarProtocol() {
String pattern = "classpath*:example/japanese/バリューオブジェクト/**/*.class";
String pathPrefix = ".+example/japanese/";
assertExactFilenames(pattern, "バリューオブジェクト.class");
assertExactSubPaths(pattern, pathPrefix, "バリューオブジェクト/バリューオブジェクト.class");
}
@Test
void usingFilePrototol() {
Path testResourcesDir = Paths.get("src/test/resources").toAbsolutePath();
String pattern = String.format("file:%s/japanese-resources/バリューオブジェクト/**/*.text", testResourcesDir);
String pathPrefix = ".+japanese-resources/";
assertExactFilenames(pattern, "バリューオブジェクト.text");
assertExactSubPaths(pattern, pathPrefix, "バリューオブジェクト/バリューオブジェクト.text");
}
}
}
@ -179,4 +203,27 @@ class PathMatchingResourcePatternResolverTests { @@ -179,4 +203,27 @@ class PathMatchingResourcePatternResolverTests {
}
}
private void assertExactSubPaths(String pattern, String pathPrefix, String... subPaths) {
try {
Resource[] resources = resolver.getResources(pattern);
List<String> actualSubPaths = Arrays.stream(resources)
.map(resource -> getPath(resource).replaceFirst(pathPrefix, ""))
.sorted()
.collect(Collectors.toList());
assertThat(actualSubPaths).containsExactlyInAnyOrder(subPaths);
}
catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}
private String getPath(Resource resource) {
try {
return resource.getURL().getPath();
}
catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}
}

1
spring-core/src/test/resources/japanese-resources/バリューオブジェクト/バリューオブジェクト.text

@ -0,0 +1 @@ @@ -0,0 +1 @@
value object

2
src/checkstyle/checkstyle-suppressions.xml

@ -43,6 +43,8 @@ @@ -43,6 +43,8 @@
<suppress files="CompileWithForkedClassLoader" checks="IllegalImport" id="bannedJUnitJupiterImports" />
<suppress files="org[\\/]springframework[\\/]aot[\\/]test[\\/]agent[\\/].+" checks="IllegalImport" id="bannedJUnitJupiterImports" />
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]example[\\/]japanese[\\/].+" checks="TypeName" />
<!-- spring-expression -->
<suppress files="ExpressionException" checks="MutableException"/>
<suppress files="SpelMessage" checks="JavadocVariable|JavadocStyle"/>

Loading…
Cancel
Save