@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2023 the original author or authors .
* Copyright 2002 - 2024 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -19,6 +19,7 @@ package org.springframework.beans.propertyeditors;
@@ -19,6 +19,7 @@ package org.springframework.beans.propertyeditors;
import java.beans.PropertyEditor ;
import java.io.File ;
import java.nio.file.Path ;
import java.nio.file.Paths ;
import org.junit.jupiter.api.Test ;
@ -31,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
@@ -31,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Juergen Hoeller
* @since 4 . 3 . 2
* /
public class PathEditorTests {
class PathEditorTests {
@Test
public void testClasspathPathName ( ) {
void testClasspathPathName ( ) {
PropertyEditor pathEditor = new PathEditor ( ) ;
pathEditor . setAsText ( "classpath:" + ClassUtils . classPackageAsResourcePath ( getClass ( ) ) + "/" +
ClassUtils . getShortName ( getClass ( ) ) + ".class" ) ;
@ -45,14 +46,14 @@ public class PathEditorTests {
@@ -45,14 +46,14 @@ public class PathEditorTests {
}
@Test
public void testWithNonExistentResource ( ) {
PropertyEditor property Editor = new PathEditor ( ) ;
void testWithNonExistentResource ( ) {
PropertyEditor path Editor = new PathEditor ( ) ;
assertThatIllegalArgumentException ( ) . isThrownBy ( ( ) - >
property Editor . setAsText ( "classpath:/no_way_this_file_is_found.doc" ) ) ;
path Editor . setAsText ( "classpath:/no_way_this_file_is_found.doc" ) ) ;
}
@Test
public void testWithNonExistentPath ( ) {
void testWithNonExistentPath ( ) {
PropertyEditor pathEditor = new PathEditor ( ) ;
pathEditor . setAsText ( "file:/no_way_this_file_is_found.doc" ) ;
Object value = pathEditor . getValue ( ) ;
@ -62,7 +63,7 @@ public class PathEditorTests {
@@ -62,7 +63,7 @@ public class PathEditorTests {
}
@Test
public void testAbsolutePath ( ) {
void testAbsolutePath ( ) {
PropertyEditor pathEditor = new PathEditor ( ) ;
pathEditor . setAsText ( "/no_way_this_file_is_found.doc" ) ;
Object value = pathEditor . getValue ( ) ;
@ -72,7 +73,7 @@ public class PathEditorTests {
@@ -72,7 +73,7 @@ public class PathEditorTests {
}
@Test
public void testWindowsAbsolutePath ( ) {
void testWindowsAbsolutePath ( ) {
PropertyEditor pathEditor = new PathEditor ( ) ;
pathEditor . setAsText ( "C:\\no_way_this_file_is_found.doc" ) ;
Object value = pathEditor . getValue ( ) ;
@ -82,7 +83,7 @@ public class PathEditorTests {
@@ -82,7 +83,7 @@ public class PathEditorTests {
}
@Test
public void testWindowsAbsoluteFilePath ( ) {
void testWindowsAbsoluteFilePath ( ) {
PropertyEditor pathEditor = new PathEditor ( ) ;
try {
pathEditor . setAsText ( "file://C:\\no_way_this_file_is_found.doc" ) ;
@ -99,7 +100,17 @@ public class PathEditorTests {
@@ -99,7 +100,17 @@ public class PathEditorTests {
}
@Test
public void testUnqualifiedPathNameFound ( ) {
void testCurrentDirectory ( ) {
PropertyEditor pathEditor = new PathEditor ( ) ;
pathEditor . setAsText ( "file:." ) ;
Object value = pathEditor . getValue ( ) ;
assertThat ( value ) . isInstanceOf ( Path . class ) ;
Path path = ( Path ) value ;
assertThat ( path ) . isEqualTo ( Paths . get ( "." ) ) ;
}
@Test
void testUnqualifiedPathNameFound ( ) {
PropertyEditor pathEditor = new PathEditor ( ) ;
String fileName = ClassUtils . classPackageAsResourcePath ( getClass ( ) ) + "/" +
ClassUtils . getShortName ( getClass ( ) ) + ".class" ;
@ -117,7 +128,7 @@ public class PathEditorTests {
@@ -117,7 +128,7 @@ public class PathEditorTests {
}
@Test
public void testUnqualifiedPathNameNotFound ( ) {
void testUnqualifiedPathNameNotFound ( ) {
PropertyEditor pathEditor = new PathEditor ( ) ;
String fileName = ClassUtils . classPackageAsResourcePath ( getClass ( ) ) + "/" +
ClassUtils . getShortName ( getClass ( ) ) + ".clazz" ;