pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1591375 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java
Date Wed, 30 Apr 2014 16:07:57 GMT
Author: tilman
Date: Wed Apr 30 16:07:57 2014
New Revision: 1591375

URL: http://svn.apache.org/r1591375
Log:
PDFBOX-2034: refactoring per DRY

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java?rev=1591375&r1=1591374&r2=1591375&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java Wed Apr 30
16:07:57 2014
@@ -101,18 +101,7 @@ public class TestFilters extends TestCas
                             continue;
                         }
 
-                    ByteArrayOutputStream encoded = new ByteArrayOutputStream();
-                    filter.encode(new ByteArrayInputStream( original ),
-                                  encoded, new COSDictionary() );
-
-                    ByteArrayOutputStream decoded = new ByteArrayOutputStream();
-                    filter.decode(new ByteArrayInputStream( encoded.toByteArray() ),
-                                  decoded, new COSDictionary() );
-
-                    assertTrue(
-                               "Data that is encoded and then decoded through "
-                               + filter.getClass() + " does not match the original data",
-                               Arrays.equals( original, decoded.toByteArray() ) );
+                    checkEncodeDecode(filter, original);
                 }
                 success = true;
             } 
@@ -145,15 +134,21 @@ public class TestFilters extends TestCas
             baos.write(by);
         }
         is.close();
+        
+        checkEncodeDecode(lzwFilter, baos.toByteArray());
+    }
+
+    private void checkEncodeDecode(Filter filter, byte[] original) throws IOException
+    {
         ByteArrayOutputStream encoded = new ByteArrayOutputStream();
-        lzwFilter.encode(new ByteArrayInputStream(baos.toByteArray()),
-                encoded, new COSDictionary());
+        filter.encode(new ByteArrayInputStream(original), encoded, new COSDictionary());
         ByteArrayOutputStream decoded = new ByteArrayOutputStream();
-        lzwFilter.decode(new ByteArrayInputStream(encoded.toByteArray()),
+        filter.decode(new ByteArrayInputStream(encoded.toByteArray()),
                 decoded, new COSDictionary());
+
         assertTrue(
-                "PDFBOX-1777 data that is encoded and then decoded through "
-                + lzwFilter.getClass() + " does not match the original data",
-                Arrays.equals(baos.toByteArray(), decoded.toByteArray()));
+                "Data that is encoded and then decoded through "
+                + filter.getClass() + " does not match the original data",
+                Arrays.equals(original, decoded.toByteArray()));
     }
 }



Mime
View raw message