Ignore testWindowsAbsoluteFilePath exception if not on Windows

See gh-26702
This commit is contained in:
Juergen Hoeller 2021-04-12 23:46:27 +02:00
parent 29955a2898
commit e05b584623
1 changed files with 12 additions and 5 deletions

View File

@ -84,12 +84,19 @@ public class PathEditorTests {
@Test @Test
public void testWindowsAbsoluteFilePath() { public void testWindowsAbsoluteFilePath() {
PropertyEditor pathEditor = new PathEditor(); PropertyEditor pathEditor = new PathEditor();
try {
pathEditor.setAsText("file://C:\\no_way_this_file_is_found.doc"); pathEditor.setAsText("file://C:\\no_way_this_file_is_found.doc");
Object value = pathEditor.getValue(); Object value = pathEditor.getValue();
assertThat(value instanceof Path).isTrue(); assertThat(value instanceof Path).isTrue();
Path path = (Path) value; Path path = (Path) value;
assertThat(!path.toFile().exists()).isTrue(); assertThat(!path.toFile().exists()).isTrue();
} }
catch (IllegalArgumentException ex) {
if (File.separatorChar == '\\') { // on Windows, otherwise silently ignore
throw ex;
}
}
}
@Test @Test
public void testUnqualifiedPathNameFound() { public void testUnqualifiedPathNameFound() {