[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-dev
Subject:    (commons-io) branch master updated: Uncomment and update null tests for FileUtils.toURLs(File...) (#
From:       ggregory () apache ! org
Date:       2023-12-31 15:17:09
Message-ID: 170403582963.1555737.16248504231280847772 () gitbox2-he-fi ! apache ! org
[Download RAW message or body]

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 a229f90c Uncomment and update null tests for FileUtils.toURLs(File...) \
(#546) a229f90c is described below

commit a229f90c3fd9ff814827821a5b234a57bc4570e6
Author: Elliotte Rusty Harold <elharo@users.noreply.github.com>
AuthorDate: Sun Dec 31 15:17:05 2023 +0000

    Uncomment and update null tests for FileUtils.toURLs(File...) (#546)
    
    * uncomment and update null tests for toURLs
    
    * javadoc
---
 src/main/java/org/apache/commons/io/FileUtils.java |  4 +--
 .../java/org/apache/commons/io/FileUtilsTest.java  | 35 ++++++++++------------
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/FileUtils.java \
b/src/main/java/org/apache/commons/io/FileUtils.java index 5fe5e5a6..ce7ddc85 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -3054,7 +3054,7 @@ public class FileUtils {
     }
 
     /**
-     * Converts each of an array of {@link File} to a {@link URL}.
+     * Converts each element of an array of {@link File} to a {@link URL}.
      * <p>
      * Returns an array of the same size as the input.
      * </p>
@@ -3062,7 +3062,7 @@ public class FileUtils {
      * @param files the files to convert, must not be {@code null}
      * @return an array of URLs matching the input
      * @throws IOException          if a file cannot be converted
-     * @throws NullPointerException if the parameter is null
+     * @throws NullPointerException if any argument is null
      */
     public static URL[] toURLs(final File... files) throws IOException {
         Objects.requireNonNull(files, "files");
diff --git a/src/test/java/org/apache/commons/io/FileUtilsTest.java \
b/src/test/java/org/apache/commons/io/FileUtilsTest.java index 921ba307..a1305135 \
                100644
--- a/src/test/java/org/apache/commons/io/FileUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsTest.java
@@ -791,25 +791,22 @@ public class FileUtilsTest extends AbstractTempDirTest {
         assertEquals("file3.txt", files.get(2).getName());
     }
 
-//   @Test public void testToURLs2() throws Exception {
-//        File[] files = new File[] {
-//            new File(temporaryFolder, "file1.txt"),
-//            null,
-//        };
-//        URL[] urls = FileUtils.toURLs(files);
-//
-//        assertEquals(files.length, urls.length);
-//        assertTrue(urls[0].toExternalForm().startsWith("file:"));
-//        assertTrue(urls[0].toExternalForm().indexOf("file1.txt") > 0);
-//        assertEquals(null, urls[1]);
-//    }
-//
-//   @Test public void testToURLs3() throws Exception {
-//        File[] files = null;
-//        URL[] urls = FileUtils.toURLs(files);
-//
-//        assertEquals(0, urls.length);
-//    }
+    @Test
+    public void testToURLs2() {
+        final File[] files = new File[] {
+            new File(tempDirFile, "file1.txt"),
+            null,
+        };
+        assertThrows(NullPointerException.class, () -> FileUtils.toURLs(files),
+                "Can't convert null URL");
+    }
+
+    @Test
+    public void testToURLs3() {
+        final File[] files = null;
+        assertThrows(NullPointerException.class, () -> FileUtils.toURLs(files),
+                "Can't convert null list");
+    }
 
     @Test
     public void testCopyDirectoryPreserveDates() throws Exception {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic