You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/02/13 15:09:30 UTC

[commons-io] branch master updated: Use NIO to test NIO.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
     new f739c1c  Use NIO to test NIO.
f739c1c is described below

commit f739c1c0d81fe396fa5b39418b0ff8e115d8f8d2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Feb 13 10:09:27 2022 -0500

    Use NIO to test NIO.
---
 src/test/java/org/apache/commons/io/file/PathUtilsTest.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/file/PathUtilsTest.java b/src/test/java/org/apache/commons/io/file/PathUtilsTest.java
index 244f86a..bf95a36 100644
--- a/src/test/java/org/apache/commons/io/file/PathUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/file/PathUtilsTest.java
@@ -20,6 +20,7 @@ package org.apache.commons.io.file;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assumptions.assumeFalse;
@@ -176,11 +177,13 @@ public class PathUtilsTest extends AbstractTempDirTest {
         assertEquals(tempDirPath.getParent(), PathUtils.createParentDirectories(tempDirPath));
     }
 
+    @SuppressWarnings("resource") // FileSystems.getDefault() is a singleton
     @Test
     public void testCreateDirectoriesForRoots() throws IOException {
-        for (final File f : File.listRoots()) {
-            final Path path = f.toPath();
-            assertEquals(path.getParent(), PathUtils.createParentDirectories(path));
+        for (final Path path : FileSystems.getDefault().getRootDirectories()) {
+            final Path parent = path.getParent();
+            assertNull(parent);
+            assertEquals(parent, PathUtils.createParentDirectories(path));
         }
     }