|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
20 | 20 | import java.io.IOException;
|
21 | 21 | import java.io.UncheckedIOException;
|
22 | 22 | import java.net.URL;
|
| 23 | +import java.net.URLClassLoader; |
23 | 24 | import java.nio.file.Path;
|
24 | 25 | import java.nio.file.Paths;
|
25 | 26 | import java.util.Arrays;
|
|
29 | 30 | import org.junit.jupiter.api.Nested;
|
30 | 31 | import org.junit.jupiter.api.Test;
|
31 | 32 |
|
| 33 | +import org.springframework.core.io.DefaultResourceLoader; |
32 | 34 | import org.springframework.core.io.FileSystemResource;
|
33 | 35 | import org.springframework.core.io.Resource;
|
34 | 36 | import org.springframework.util.StringUtils;
|
@@ -59,7 +61,7 @@ class PathMatchingResourcePatternResolverTests {
|
59 | 61 | private static final String[] CLASSES_IN_REACTOR_UTIL_ANNOTATION = { "NonNull.class", "NonNullApi.class", "Nullable.class" };
|
60 | 62 |
|
61 | 63 |
|
62 |
| - private final PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); |
| 64 | + private PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); |
63 | 65 |
|
64 | 66 |
|
65 | 67 | @Nested
|
@@ -88,8 +90,16 @@ void classpathStarWithPatternOnFileSystem() {
|
88 | 90 | assertFilenames(pattern, expectedFilenames);
|
89 | 91 | }
|
90 | 92 |
|
| 93 | + @Test |
| 94 | + void encodedHashtagInPath() throws IOException { |
| 95 | + Path rootDir = Paths.get("src/test/resources/custom%23root").toAbsolutePath(); |
| 96 | + URL root = new URL("file:" + rootDir + "/"); |
| 97 | + resolver = new PathMatchingResourcePatternResolver(new DefaultResourceLoader(new URLClassLoader(new URL[] {root}))); |
| 98 | + assertExactFilenames("classpath*:scanned/*.txt", "resource#test1.txt", "resource#test2.txt"); |
| 99 | + } |
| 100 | + |
91 | 101 | @Nested
|
92 |
| - class WithHashtagsInTheirFileNames { |
| 102 | + class WithHashtagsInTheirFilenames { |
93 | 103 |
|
94 | 104 | @Test
|
95 | 105 | void usingClasspathStarProtocol() {
|
|
0 commit comments