pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1867523 - in /pdfbox/branches/issue4569: pdfbox/src/test/java/org/apache/pdfbox/rendering/TestRendering.java tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java
Date Wed, 25 Sep 2019 17:54:23 GMT
Author: tilman
Date: Wed Sep 25 17:54:23 2019
New Revision: 1867523

URL: http://svn.apache.org/viewvc?rev=1867523&view=rev
Log:
PDFBOX-4071: use jdk8 lambda expressions and streams

Modified:
    pdfbox/branches/issue4569/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestRendering.java
    pdfbox/branches/issue4569/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java

Modified: pdfbox/branches/issue4569/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestRendering.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestRendering.java?rev=1867523&r1=1867522&r2=1867523&view=diff
==============================================================================
--- pdfbox/branches/issue4569/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestRendering.java
(original)
+++ pdfbox/branches/issue4569/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestRendering.java
Wed Sep 25 17:54:23 2019
@@ -24,11 +24,10 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized.Parameters;
 
 import java.io.File;
-import java.io.FilenameFilter;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * Functional test for PDF rendering. This test simply tries to render
@@ -46,21 +45,9 @@ public class TestRendering
     @Parameters(name = "{0}")
     public static Collection<Object[]> data()
     {
-        File[] testFiles = new File(INPUT_DIR).listFiles(new FilenameFilter()
-        {
-            @Override
-            public boolean accept(File dir, String name)
-            {
-                return (name.endsWith(".pdf") || name.endsWith(".ai"));
-            }
-        });
-
-        List<Object[]> params = new ArrayList<>();
-        for (File file : testFiles)
-        {
-            params.add(new Object[] { file.getName() });
-        }
-        return params;
+        File[] testFiles = new File(INPUT_DIR).listFiles(
+                (dir, name) -> (name.endsWith(".pdf") || name.endsWith(".ai")));
+        return Stream.of(testFiles).map(file -> new Object[] { file.getName() }).collect(Collectors.toList());
     }
 
     private final String fileName;

Modified: pdfbox/branches/issue4569/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java?rev=1867523&r1=1867522&r2=1867523&view=diff
==============================================================================
--- pdfbox/branches/issue4569/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java
(original)
+++ pdfbox/branches/issue4569/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java
Wed Sep 25 17:54:23 2019
@@ -25,7 +25,6 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.HashSet;
@@ -292,14 +291,8 @@ public class TestImageIOUtils extends Te
             throw new IOException("could not create output directory");
         }
 
-        File[] testFiles = new File(inDir).listFiles(new FilenameFilter()
-        {
-            @Override
-            public boolean accept(File dir, String name)
-            {
-                return (name.endsWith(".pdf") || name.endsWith(".ai"));
-            }
-        });
+        File[] testFiles = new File(inDir).listFiles(
+                (dir, name) -> (name.endsWith(".pdf") || name.endsWith(".ai")));
 
         for (File file : testFiles)
         {



Mime
View raw message