pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1608521 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java
Date Mon, 07 Jul 2014 17:33:04 GMT
Author: tilman
Date: Mon Jul  7 17:33:03 2014
New Revision: 1608521

URL: http://svn.apache.org/r1608521
Log:
PDFBOX-1695: code cleanup

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java?rev=1608521&r1=1608520&r2=1608521&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java Mon Jul 
7 17:33:03 2014
@@ -272,44 +272,44 @@ public class TestPDFToImage extends Test
 
             File[] outFiles = new File(outDir).listFiles(new FilenameFilter()
             {
+                @Override
                 public boolean accept(File dir, String name)
                 {
                     return (name.endsWith(".png") && name.startsWith(mcurFile.getName(),
0));
                 }
             });
-            for (int n = 0; n < outFiles.length; n++)
+            for (File outFile : outFiles)
             {
-                new File(outFiles[n].getAbsolutePath() + "-diff.png").delete(); // delete
diff file from a previous run
-
-                File inFile = new File(inDir + '/' + outFiles[n].getName());
+                new File(outFile.getAbsolutePath() + "-diff.png").delete(); // delete diff
file from a previous run
+                File inFile = new File(inDir + '/' + outFile.getName());
                 if (!inFile.exists())
                 {
                     this.bFail = true;
                     LOG.warn("*** TEST FAILURE *** Input missing for file: " + inFile.getName());
                 }
-                else if (!filesAreIdentical(outFiles[n], inFile))
+                else if (!filesAreIdentical(outFile, inFile))
                 {
                     // different files might still have identical content
                     // save the difference (if any) into a diff image
-                    BufferedImage bim3 = diffImages(ImageIO.read(inFile), ImageIO.read(outFiles[n]));
+                    BufferedImage bim3 = diffImages(ImageIO.read(inFile), ImageIO.read(outFile));
                     if (bim3 != null)
                     {
                         this.bFail = true;
                         LOG.warn("*** TEST FAILURE *** Input and output not identical for
file: " + inFile.getName());
-                        ImageIO.write(bim3, "png", new File(outFiles[n].getAbsolutePath()
+ "-diff.png"));
+                        ImageIO.write(bim3, "png", new File(outFile.getAbsolutePath() + "-diff.png"));
                     }
                     else
                     {
                         LOG.info("*** TEST OK *** for file: " + inFile.getName());
-                        LOG.info("Deleting: " + outFiles[n].getName());
-                        outFiles[n].delete();
+                        LOG.info("Deleting: " + outFile.getName());
+                        outFile.delete();
                     }
                 }
                 else
                 {
                     LOG.info("*** TEST OK *** for file: " + inFile.getName());
-                    LOG.info("Deleting: " + outFiles[n].getName());
-                    outFiles[n].delete();
+                    LOG.info("Deleting: " + outFile.getName());
+                    outFile.delete();
                 }
             }
         }
@@ -427,10 +427,12 @@ public class TestPDFToImage extends Test
             {
                 byte[] lbuffer = new byte[4096];
                 byte[] rbuffer = new byte[lbuffer.length];
-                for (int lcount = 0; (lcount = lin.read(lbuffer)) > 0;)
+                int lcount;
+                while ((lcount = lin.read(lbuffer)) > 0)
                 {
                     int bytesRead = 0;
-                    for (int rcount = 0; (rcount = rin.read(rbuffer, bytesRead, lcount -
bytesRead)) > 0;)
+                    int rcount;
+                    while ((rcount = rin.read(rbuffer, bytesRead, lcount - bytesRead)) >
0)
                     {
                         bytesRead += rcount;
                     }



Mime
View raw message