|
16 | 16 |
|
17 | 17 | package org.springframework.core.io.support; |
18 | 18 |
|
| 19 | +import java.io.File; |
19 | 20 | import java.io.FileNotFoundException; |
20 | 21 | import java.io.IOException; |
21 | 22 | import java.util.ArrayList; |
22 | 23 | import java.util.Arrays; |
23 | 24 | import java.util.List; |
| 25 | +import java.util.Set; |
24 | 26 |
|
25 | 27 | import org.junit.Ignore; |
| 28 | +import org.junit.Rule; |
26 | 29 | import org.junit.Test; |
27 | | - |
| 30 | +import org.junit.rules.TemporaryFolder; |
28 | 31 | import org.springframework.core.io.Resource; |
29 | 32 | import org.springframework.util.StringUtils; |
30 | 33 |
|
@@ -56,6 +59,8 @@ public class PathMatchingResourcePatternResolverTests { |
56 | 59 |
|
57 | 60 | private PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); |
58 | 61 |
|
| 62 | + @Rule |
| 63 | + public TemporaryFolder folder = new TemporaryFolder(); |
59 | 64 |
|
60 | 65 | @Test(expected = FileNotFoundException.class) |
61 | 66 | public void invalidPrefixWithPatternElementInIt() throws IOException { |
@@ -117,6 +122,27 @@ public void rootPatternRetrievalInJarFiles() throws IOException { |
117 | 122 | } |
118 | 123 | assertTrue("Could not find aspectj_1_5_0.dtd in the root of the aspectjweaver jar", found); |
119 | 124 | } |
| 125 | + |
| 126 | + |
| 127 | + @Test |
| 128 | + public void testConsistentFileOrder() throws IOException { |
| 129 | + |
| 130 | + List<String> expectedFileNames = new ArrayList<>(); |
| 131 | + |
| 132 | + expectedFileNames.add(folder.newFile("A.txt").getName()); |
| 133 | + expectedFileNames.add(folder.newFile("B.txt").getName()); |
| 134 | + expectedFileNames.add(folder.newFile("P.txt").getName()); |
| 135 | + File newFolder = folder.newFolder("message"); |
| 136 | + expectedFileNames.add(File.createTempFile("Message", ".txt", newFolder).getName()); |
| 137 | + |
| 138 | + Set<File> matchingFiles = resolver.retrieveMatchingFiles(folder.getRoot(), "**/*.txt"); |
| 139 | + assertEquals(expectedFileNames.size(), matchingFiles.size()); |
| 140 | + int i = 0; |
| 141 | + for (File file : matchingFiles) { |
| 142 | + assertEquals(expectedFileNames.get(i), file.getName()); |
| 143 | + i++; |
| 144 | + } |
| 145 | + } |
120 | 146 |
|
121 | 147 |
|
122 | 148 | private void assertProtocolAndFilenames(Resource[] resources, String protocol, String... filenames) |
|
0 commit comments