From e05b5846239fcd7a119a8ac884f5527b9bc24263 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 12 Apr 2021 23:46:27 +0200 Subject: [PATCH] Ignore testWindowsAbsoluteFilePath exception if not on Windows See gh-26702 --- .../beans/propertyeditors/PathEditorTests.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java index 9005c96a6c67..f0c659bcbdb7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java @@ -84,11 +84,18 @@ public void testWindowsAbsolutePath() { @Test public void testWindowsAbsoluteFilePath() { PropertyEditor pathEditor = new PathEditor(); - pathEditor.setAsText("file://C:\\no_way_this_file_is_found.doc"); - Object value = pathEditor.getValue(); - assertThat(value instanceof Path).isTrue(); - Path path = (Path) value; - assertThat(!path.toFile().exists()).isTrue(); + try { + pathEditor.setAsText("file://C:\\no_way_this_file_is_found.doc"); + Object value = pathEditor.getValue(); + assertThat(value instanceof Path).isTrue(); + Path path = (Path) value; + assertThat(!path.toFile().exists()).isTrue(); + } + catch (IllegalArgumentException ex) { + if (File.separatorChar == '\\') { // on Windows, otherwise silently ignore + throw ex; + } + } } @Test