1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
34
34
public class PathEditorTests {
35
35
36
36
@ Test
37
- public void testClasspathPathName () throws Exception {
37
+ public void testClasspathPathName () {
38
38
PropertyEditor pathEditor = new PathEditor ();
39
39
pathEditor .setAsText ("classpath:" + ClassUtils .classPackageAsResourcePath (getClass ()) + "/" +
40
40
ClassUtils .getShortName (getClass ()) + ".class" );
@@ -46,14 +46,14 @@ public void testClasspathPathName() throws Exception {
46
46
}
47
47
48
48
@ Test
49
- public void testWithNonExistentResource () throws Exception {
49
+ public void testWithNonExistentResource () {
50
50
PropertyEditor propertyEditor = new PathEditor ();
51
51
assertThatIllegalArgumentException ().isThrownBy (() ->
52
52
propertyEditor .setAsText ("classpath:/no_way_this_file_is_found.doc" ));
53
53
}
54
54
55
55
@ Test
56
- public void testWithNonExistentPath () throws Exception {
56
+ public void testWithNonExistentPath () {
57
57
PropertyEditor pathEditor = new PathEditor ();
58
58
pathEditor .setAsText ("file:/no_way_this_file_is_found.doc" );
59
59
Object value = pathEditor .getValue ();
@@ -65,7 +65,7 @@ public void testWithNonExistentPath() throws Exception {
65
65
}
66
66
67
67
@ Test
68
- public void testAbsolutePath () throws Exception {
68
+ public void testAbsolutePath () {
69
69
PropertyEditor pathEditor = new PathEditor ();
70
70
pathEditor .setAsText ("/no_way_this_file_is_found.doc" );
71
71
Object value = pathEditor .getValue ();
@@ -77,7 +77,31 @@ public void testAbsolutePath() throws Exception {
77
77
}
78
78
79
79
@ Test
80
- public void testUnqualifiedPathNameFound () throws Exception {
80
+ public void testWindowsAbsolutePath () {
81
+ PropertyEditor pathEditor = new PathEditor ();
82
+ pathEditor .setAsText ("C:\\ no_way_this_file_is_found.doc" );
83
+ Object value = pathEditor .getValue ();
84
+ boolean condition1 = value instanceof Path ;
85
+ assertThat (condition1 ).isTrue ();
86
+ Path path = (Path ) value ;
87
+ boolean condition = !path .toFile ().exists ();
88
+ assertThat (condition ).isTrue ();
89
+ }
90
+
91
+ @ Test
92
+ public void testWindowsAbsoluteFilePath () {
93
+ 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 ();
101
+ }
102
+
103
+ @ Test
104
+ public void testUnqualifiedPathNameFound () {
81
105
PropertyEditor pathEditor = new PathEditor ();
82
106
String fileName = ClassUtils .classPackageAsResourcePath (getClass ()) + "/" +
83
107
ClassUtils .getShortName (getClass ()) + ".class" ;
@@ -96,7 +120,7 @@ public void testUnqualifiedPathNameFound() throws Exception {
96
120
}
97
121
98
122
@ Test
99
- public void testUnqualifiedPathNameNotFound () throws Exception {
123
+ public void testUnqualifiedPathNameNotFound () {
100
124
PropertyEditor pathEditor = new PathEditor ();
101
125
String fileName = ClassUtils .classPackageAsResourcePath (getClass ()) + "/" +
102
126
ClassUtils .getShortName (getClass ()) + ".clazz" ;
0 commit comments