Skip to content

Commit e05b584

Browse files
committed
Ignore testWindowsAbsoluteFilePath exception if not on Windows
See gh-26702
1 parent 29955a2 commit e05b584

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,18 @@ public void testWindowsAbsolutePath() {
8484
@Test
8585
public void testWindowsAbsoluteFilePath() {
8686
PropertyEditor pathEditor = new PathEditor();
87-
pathEditor.setAsText("file://C:\\no_way_this_file_is_found.doc");
88-
Object value = pathEditor.getValue();
89-
assertThat(value instanceof Path).isTrue();
90-
Path path = (Path) value;
91-
assertThat(!path.toFile().exists()).isTrue();
87+
try {
88+
pathEditor.setAsText("file://C:\\no_way_this_file_is_found.doc");
89+
Object value = pathEditor.getValue();
90+
assertThat(value instanceof Path).isTrue();
91+
Path path = (Path) value;
92+
assertThat(!path.toFile().exists()).isTrue();
93+
}
94+
catch (IllegalArgumentException ex) {
95+
if (File.separatorChar == '\\') { // on Windows, otherwise silently ignore
96+
throw ex;
97+
}
98+
}
9299
}
93100

94101
@Test

0 commit comments

Comments
 (0)