You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2018/10/16 23:02:52 UTC

commons-io git commit: IO-589 Some tests fail if the base path contains a space

Repository: commons-io
Updated Branches:
  refs/heads/master 1f925d7ad -> 16c983693


IO-589 Some tests fail if the base path contains a space

Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/16c98369
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/16c98369
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/16c98369

Branch: refs/heads/master
Commit: 16c983693a235bdc45c6286a1e7b01d8ef58907e
Parents: 1f925d7
Author: Sebb <se...@apache.org>
Authored: Wed Oct 17 00:02:47 2018 +0100
Committer: Sebb <se...@apache.org>
Committed: Wed Oct 17 00:02:47 2018 +0100

----------------------------------------------------------------------
 src/changes/changes.xml                             |  3 +++
 .../org/apache/commons/io/FileUtilsTestCase.java    |  6 +++---
 .../java/org/apache/commons/io/IOUtilsTestCase.java | 16 ++++++++--------
 3 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/16c98369/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index fecb959..8c1fa19 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -47,6 +47,9 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
     <!-- The release date is the date RC is cut -->
     <release version="2.7" date="tba" description="tba">
+      <action issue="IO-589" dev="sebb" type="fix">
+        Some tests fail if the base path contains a space
+      </action>
       <action dev="jochen" type="add">
         Adding the CircularBufferInputStream, and the PeekableInputStream.
       </action>

http://git-wip-us.apache.org/repos/asf/commons-io/blob/16c98369/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
index 7138491..a6d7629 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
@@ -668,17 +668,17 @@ public class FileUtilsTestCase {
 
         final URL urlCR = getClass().getResource("FileUtilsTestDataCR.dat");
         assertNotNull(urlCR);
-        final File cr = new File(urlCR.getPath());
+        final File cr = new File(urlCR.toURI());
         assertTrue(cr.exists());
 
         final URL urlCRLF = getClass().getResource("FileUtilsTestDataCRLF.dat");
         assertNotNull(urlCRLF);
-        final File crlf = new File(urlCRLF.getPath());
+        final File crlf = new File(urlCRLF.toURI());
         assertTrue(crlf.exists());
 
         final URL urlLF = getClass().getResource("FileUtilsTestDataLF.dat");
         assertNotNull(urlLF);
-        final File lf = new File(urlLF.getPath());
+        final File lf = new File(urlLF.toURI());
         assertTrue(lf.exists());
 
         assertTrue(FileUtils.contentEqualsIgnoreEOL(cr, cr, null));

http://git-wip-us.apache.org/repos/asf/commons-io/blob/16c98369/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
index b5adc04..0058133 100644
--- a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
@@ -1161,7 +1161,7 @@ public class IOUtilsTestCase {
     }
 
     @Test public void testResourceToString_ExistingResourceAtRootPackage() throws Exception {
-        final long fileSize = new File(getClass().getResource("/test-file-simple-utf8.bin").getFile()).length();
+        final long fileSize = new File(getClass().getResource("/test-file-simple-utf8.bin").toURI()).length();
         final String content = IOUtils.resourceToString("/test-file-simple-utf8.bin", StandardCharsets.UTF_8);
 
         assertNotNull(content);
@@ -1169,7 +1169,7 @@ public class IOUtilsTestCase {
     }
 
     @Test public void testResourceToString_ExistingResourceAtRootPackage_WithClassLoader() throws Exception {
-        final long fileSize = new File(getClass().getResource("/test-file-simple-utf8.bin").getFile()).length();
+        final long fileSize = new File(getClass().getResource("/test-file-simple-utf8.bin").toURI()).length();
         final String content = IOUtils.resourceToString(
                 "test-file-simple-utf8.bin",
                 StandardCharsets.UTF_8,
@@ -1181,7 +1181,7 @@ public class IOUtilsTestCase {
     }
 
     @Test public void testResourceToString_ExistingResourceAtSubPackage() throws Exception {
-        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").getFile()).length();
+        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").toURI()).length();
         final String content = IOUtils.resourceToString("/org/apache/commons/io/FileUtilsTestDataCR.dat", StandardCharsets.UTF_8);
 
         assertNotNull(content);
@@ -1189,7 +1189,7 @@ public class IOUtilsTestCase {
     }
 
     @Test public void testResourceToString_ExistingResourceAtSubPackage_WithClassLoader() throws Exception {
-        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").getFile()).length();
+        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").toURI()).length();
         final String content = IOUtils.resourceToString(
                 "org/apache/commons/io/FileUtilsTestDataCR.dat",
                 StandardCharsets.UTF_8,
@@ -1245,28 +1245,28 @@ public class IOUtilsTestCase {
     }
 
     @Test public void testResourceToByteArray_ExistingResourceAtRootPackage() throws Exception {
-        final long fileSize = new File(getClass().getResource("/test-file-utf8.bin").getFile()).length();
+        final long fileSize = new File(getClass().getResource("/test-file-utf8.bin").toURI()).length();
         final byte[] bytes = IOUtils.resourceToByteArray("/test-file-utf8.bin");
         assertNotNull(bytes);
         assertEquals(fileSize, bytes.length);
     }
 
     @Test public void testResourceToByteArray_ExistingResourceAtRootPackage_WithClassLoader() throws Exception {
-        final long fileSize = new File(getClass().getResource("/test-file-utf8.bin").getFile()).length();
+        final long fileSize = new File(getClass().getResource("/test-file-utf8.bin").toURI()).length();
         final byte[] bytes = IOUtils.resourceToByteArray("test-file-utf8.bin", ClassLoader.getSystemClassLoader());
         assertNotNull(bytes);
         assertEquals(fileSize, bytes.length);
     }
 
     @Test public void testResourceToByteArray_ExistingResourceAtSubPackage() throws Exception {
-        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").getFile()).length();
+        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").toURI()).length();
         final byte[] bytes = IOUtils.resourceToByteArray("/org/apache/commons/io/FileUtilsTestDataCR.dat");
         assertNotNull(bytes);
         assertEquals(fileSize, bytes.length);
     }
 
     @Test public void testResourceToByteArray_ExistingResourceAtSubPackage_WithClassLoader() throws Exception {
-        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").getFile()).length();
+        final long fileSize = new File(getClass().getResource("/org/apache/commons/io/FileUtilsTestDataCR.dat").toURI()).length();
         final byte[] bytes = IOUtils.resourceToByteArray("org/apache/commons/io/FileUtilsTestDataCR.dat", ClassLoader.getSystemClassLoader());
         assertNotNull(bytes);
         assertEquals(fileSize, bytes.length);