PathEditor tries file system path in case of non-existing resource
Issue: SPR-14549
This commit is contained in:
@@ -28,6 +28,7 @@ import static org.junit.Assert.*;
|
||||
/**
|
||||
* @author Thomas Risberg
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class FileEditorTests {
|
||||
|
||||
@@ -78,10 +79,7 @@ public class FileEditorTests {
|
||||
assertTrue(value instanceof File);
|
||||
File file = (File) value;
|
||||
assertTrue(file.exists());
|
||||
String absolutePath = file.getAbsolutePath();
|
||||
if (File.separatorChar == '\\') {
|
||||
absolutePath = absolutePath.replace('\\', '/');
|
||||
}
|
||||
String absolutePath = file.getAbsolutePath().replace('\\', '/');
|
||||
assertTrue(absolutePath.endsWith(fileName));
|
||||
}
|
||||
|
||||
@@ -95,10 +93,7 @@ public class FileEditorTests {
|
||||
assertTrue(value instanceof File);
|
||||
File file = (File) value;
|
||||
assertFalse(file.exists());
|
||||
String absolutePath = file.getAbsolutePath();
|
||||
if (File.separatorChar == '\\') {
|
||||
absolutePath = absolutePath.replace('\\', '/');
|
||||
}
|
||||
String absolutePath = file.getAbsolutePath().replace('\\', '/');
|
||||
assertTrue(absolutePath.endsWith(fileName));
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,16 @@ public class PathEditorTests {
|
||||
assertTrue(!path.toFile().exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbsolutePath() throws Exception {
|
||||
PropertyEditor pathEditor = new PathEditor();
|
||||
pathEditor.setAsText("/no_way_this_file_is_found.doc");
|
||||
Object value = pathEditor.getValue();
|
||||
assertTrue(value instanceof Path);
|
||||
Path path = (Path) value;
|
||||
assertTrue(!path.toFile().exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnqualifiedPathNameFound() throws Exception {
|
||||
PropertyEditor pathEditor = new PathEditor();
|
||||
@@ -77,4 +87,22 @@ public class PathEditorTests {
|
||||
assertTrue(absolutePath.endsWith(fileName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnqualifiedPathNameNotFound() throws Exception {
|
||||
PropertyEditor pathEditor = new PathEditor();
|
||||
String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" +
|
||||
ClassUtils.getShortName(getClass()) + ".clazz";
|
||||
pathEditor.setAsText(fileName);
|
||||
Object value = pathEditor.getValue();
|
||||
assertTrue(value instanceof Path);
|
||||
Path path = (Path) value;
|
||||
File file = path.toFile();
|
||||
assertFalse(file.exists());
|
||||
String absolutePath = file.getAbsolutePath();
|
||||
if (File.separatorChar == '\\') {
|
||||
absolutePath = absolutePath.replace('\\', '/');
|
||||
}
|
||||
assertTrue(absolutePath.endsWith(fileName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user