@@ -39,8 +39,7 @@ public void testClasspathPathName() {
39
39
pathEditor .setAsText ("classpath:" + ClassUtils .classPackageAsResourcePath (getClass ()) + "/" +
40
40
ClassUtils .getShortName (getClass ()) + ".class" );
41
41
Object value = pathEditor .getValue ();
42
- boolean condition = value instanceof Path ;
43
- assertThat (condition ).isTrue ();
42
+ assertThat (value instanceof Path ).isTrue ();
44
43
Path path = (Path ) value ;
45
44
assertThat (path .toFile ().exists ()).isTrue ();
46
45
}
@@ -57,47 +56,46 @@ public void testWithNonExistentPath() {
57
56
PropertyEditor pathEditor = new PathEditor ();
58
57
pathEditor .setAsText ("file:/no_way_this_file_is_found.doc" );
59
58
Object value = pathEditor .getValue ();
60
- boolean condition1 = value instanceof Path ;
61
- assertThat (condition1 ).isTrue ();
59
+ assertThat (value instanceof Path ).isTrue ();
62
60
Path path = (Path ) value ;
63
- boolean condition = !path .toFile ().exists ();
64
- assertThat (condition ).isTrue ();
61
+ assertThat (!path .toFile ().exists ()).isTrue ();
65
62
}
66
63
67
64
@ Test
68
65
public void testAbsolutePath () {
69
66
PropertyEditor pathEditor = new PathEditor ();
70
67
pathEditor .setAsText ("/no_way_this_file_is_found.doc" );
71
68
Object value = pathEditor .getValue ();
72
- boolean condition1 = value instanceof Path ;
73
- assertThat (condition1 ).isTrue ();
69
+ assertThat (value instanceof Path ).isTrue ();
74
70
Path path = (Path ) value ;
75
- boolean condition = !path .toFile ().exists ();
76
- assertThat (condition ).isTrue ();
71
+ assertThat (!path .toFile ().exists ()).isTrue ();
77
72
}
78
73
79
74
@ Test
80
75
public void testWindowsAbsolutePath () {
81
76
PropertyEditor pathEditor = new PathEditor ();
82
77
pathEditor .setAsText ("C:\\ no_way_this_file_is_found.doc" );
83
78
Object value = pathEditor .getValue ();
84
- boolean condition1 = value instanceof Path ;
85
- assertThat (condition1 ).isTrue ();
79
+ assertThat (value instanceof Path ).isTrue ();
86
80
Path path = (Path ) value ;
87
- boolean condition = !path .toFile ().exists ();
88
- assertThat (condition ).isTrue ();
81
+ assertThat (!path .toFile ().exists ()).isTrue ();
89
82
}
90
83
91
84
@ Test
92
85
public void testWindowsAbsoluteFilePath () {
93
86
PropertyEditor pathEditor = new PathEditor ();
94
- pathEditor .setAsText ("file://C:\\ no_way_this_file_is_found.doc" );
95
- Object value = pathEditor .getValue ();
96
- boolean condition1 = value instanceof Path ;
97
- assertThat (condition1 ).isTrue ();
98
- Path path = (Path ) value ;
99
- boolean condition = !path .toFile ().exists ();
100
- assertThat (condition ).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
+ }
101
99
}
102
100
103
101
@ Test
@@ -107,8 +105,7 @@ public void testUnqualifiedPathNameFound() {
107
105
ClassUtils .getShortName (getClass ()) + ".class" ;
108
106
pathEditor .setAsText (fileName );
109
107
Object value = pathEditor .getValue ();
110
- boolean condition = value instanceof Path ;
111
- assertThat (condition ).isTrue ();
108
+ assertThat (value instanceof Path ).isTrue ();
112
109
Path path = (Path ) value ;
113
110
File file = path .toFile ();
114
111
assertThat (file .exists ()).isTrue ();
@@ -126,8 +123,7 @@ public void testUnqualifiedPathNameNotFound() {
126
123
ClassUtils .getShortName (getClass ()) + ".clazz" ;
127
124
pathEditor .setAsText (fileName );
128
125
Object value = pathEditor .getValue ();
129
- boolean condition = value instanceof Path ;
130
- assertThat (condition ).isTrue ();
126
+ assertThat (value instanceof Path ).isTrue ();
131
127
Path path = (Path ) value ;
132
128
File file = path .toFile ();
133
129
assertThat (file .exists ()).isFalse ();
0 commit comments