Skip to content

Commit 09ac085

Browse files
committed
Fix ApplicationResourceLoaderTests on Windows
1 parent dc4dbd1 commit 09ac085

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/io/ApplicationResourceLoaderTests.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ void shouldLoadAbsolutePath() throws IOException {
7373
@Test
7474
void shouldLoadAbsolutePathWithWorkingDirectory() throws IOException {
7575
ClassLoader classLoader = getClass().getClassLoader();
76+
Path workingDirectory = Path.of("/working-directory");
7677
Resource resource = ApplicationResourceLoader
77-
.get(classLoader, SpringFactoriesLoader.forDefaultResourceLocation(classLoader),
78-
Path.of("/working-directory"))
79-
.getResource("/root/file.txt");
78+
.get(classLoader, SpringFactoriesLoader.forDefaultResourceLocation(classLoader), workingDirectory)
79+
.getResource("/file.txt");
8080
assertThat(resource.isFile()).isTrue();
81-
assertThat(resource.getFile()).hasParent("/root").hasName("file.txt");
81+
assertThat(resource.getFile()).hasName("file.txt")
82+
.satisfies((file) -> assertThat(file.getParentFile()).isNotEqualTo(workingDirectory));
8283
}
8384

8485
@Test
@@ -170,12 +171,13 @@ void shouldLoadRelativeFileUrisWithWorkingDirectory() throws IOException {
170171
@Test
171172
void shouldLoadAbsoluteFileUrisWithWorkingDirectory() throws IOException {
172173
ClassLoader classLoader = getClass().getClassLoader();
174+
Path workingDirectory = Path.of("/working-directory");
173175
Resource resource = ApplicationResourceLoader
174-
.get(classLoader, SpringFactoriesLoader.forDefaultResourceLocation(classLoader),
175-
Path.of("/working-directory"))
176+
.get(classLoader, SpringFactoriesLoader.forDefaultResourceLocation(classLoader), workingDirectory)
176177
.getResource("file:/file.txt");
177178
assertThat(resource.isFile()).isTrue();
178-
assertThat(resource.getFile()).hasParent("/").hasName("file.txt");
179+
assertThat(resource.getFile()).hasName("file.txt")
180+
.satisfies((file) -> assertThat(file.getParentFile()).isNotEqualTo(workingDirectory));
179181
}
180182

181183
@Test

0 commit comments

Comments
 (0)