Skip to content

Commit f9dcdaf

Browse files
committed
Bug in test code: Tried to use /C: as a Path, while it must be just C:
This proofs that it is a very bad idea to fiddle with Strings when you actually should use Path instead. This is why Path was invented in Java 7.
1 parent 4d9daf9 commit f9dcdaf

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/test/java/org/codehaus/plexus/util/FileUtilsTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.io.Writer;
3434
import java.net.URL;
3535
import java.nio.file.Files;
36+
import java.nio.file.Paths;
3637
import java.util.Properties;
3738

3839
import org.junit.Before;
@@ -885,14 +886,12 @@ public void testFileUtils()
885886
final URL url = this.getClass().getResource( path );
886887
assertNotNull( path + " was not found.", url );
887888

888-
String filename = url.getFile();
889-
// The following line applies a fix for spaces in a path
890-
filename = replaceAll( filename, "%20", " " );
889+
final String filename = Paths.get(url.toURI()).toString();
891890
final String filename2 = "test2.txt";
892891

893892
assertTrue( "test.txt extension == \"txt\"", FileUtils.getExtension( filename ).equals( "txt" ) );
894893

895-
assertTrue( "Test file does not exist: " + filename, FileUtils.fileExists( filename ) );
894+
assertTrue( "Test file does exist: " + filename, FileUtils.fileExists( filename ) );
896895

897896
assertTrue( "Second test file does not exist", !FileUtils.fileExists( filename2 ) );
898897

0 commit comments

Comments
 (0)