Un-deprecate PathResource (for NIO Path resolution in createRelative)

Includes aligned createRelative signature and dedicated java.io.File test.

Closes gh-24211
This commit is contained in:
Juergen Hoeller
2019-12-16 16:50:04 +01:00
parent f353bc0c25
commit 0711e58a5f
3 changed files with 25 additions and 5 deletions

View File

@@ -17,6 +17,7 @@
package org.springframework.core.io;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -130,6 +131,14 @@ class ResourceTests {
assertThat(resource).isEqualTo(new FileSystemResource(file));
}
@Test
void fileSystemResourceWithFile() throws IOException {
File file = new File(getClass().getResource("Resource.class").getFile());
Resource resource = new FileSystemResource(file);
doTestResource(resource);
assertThat(resource).isEqualTo(new FileSystemResource(file));
}
@Test
void fileSystemResourceWithFilePath() throws Exception {
Path filePath = Paths.get(getClass().getResource("Resource.class").toURI());