11/*
2- * Copyright 2002-2019 the original author or authors.
2+ * Copyright 2002-2021 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
3434public class PathEditorTests {
3535
3636 @ Test
37- public void testClasspathPathName () throws Exception {
37+ public void testClasspathPathName () {
3838 PropertyEditor pathEditor = new PathEditor ();
3939 pathEditor .setAsText ("classpath:" + ClassUtils .classPackageAsResourcePath (getClass ()) + "/" +
4040 ClassUtils .getShortName (getClass ()) + ".class" );
@@ -46,14 +46,14 @@ public void testClasspathPathName() throws Exception {
4646 }
4747
4848 @ Test
49- public void testWithNonExistentResource () throws Exception {
49+ public void testWithNonExistentResource () {
5050 PropertyEditor propertyEditor = new PathEditor ();
5151 assertThatIllegalArgumentException ().isThrownBy (() ->
5252 propertyEditor .setAsText ("classpath:/no_way_this_file_is_found.doc" ));
5353 }
5454
5555 @ Test
56- public void testWithNonExistentPath () throws Exception {
56+ public void testWithNonExistentPath () {
5757 PropertyEditor pathEditor = new PathEditor ();
5858 pathEditor .setAsText ("file:/no_way_this_file_is_found.doc" );
5959 Object value = pathEditor .getValue ();
@@ -65,7 +65,7 @@ public void testWithNonExistentPath() throws Exception {
6565 }
6666
6767 @ Test
68- public void testAbsolutePath () throws Exception {
68+ public void testAbsolutePath () {
6969 PropertyEditor pathEditor = new PathEditor ();
7070 pathEditor .setAsText ("/no_way_this_file_is_found.doc" );
7171 Object value = pathEditor .getValue ();
@@ -77,7 +77,31 @@ public void testAbsolutePath() throws Exception {
7777 }
7878
7979 @ 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 () {
81105 PropertyEditor pathEditor = new PathEditor ();
82106 String fileName = ClassUtils .classPackageAsResourcePath (getClass ()) + "/" +
83107 ClassUtils .getShortName (getClass ()) + ".class" ;
@@ -96,7 +120,7 @@ public void testUnqualifiedPathNameFound() throws Exception {
96120 }
97121
98122 @ Test
99- public void testUnqualifiedPathNameNotFound () throws Exception {
123+ public void testUnqualifiedPathNameNotFound () {
100124 PropertyEditor pathEditor = new PathEditor ();
101125 String fileName = ClassUtils .classPackageAsResourcePath (getClass ()) + "/" +
102126 ClassUtils .getShortName (getClass ()) + ".clazz" ;
0 commit comments