You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2014/04/30 18:08:16 UTC
svn commit: r1591376 -
/pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java
Author: tilman
Date: Wed Apr 30 16:08:16 2014
New Revision: 1591376
URL: http://svn.apache.org/r1591376
Log:
PDFBOX-2034: refactoring per DRY
Modified:
pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java
Modified: pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java?rev=1591376&r1=1591375&r2=1591376&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java Wed Apr 30 16:08:16 2014
@@ -104,20 +104,7 @@ public class TestFilters extends TestCas
continue;
}
- ByteArrayOutputStream encoded = new ByteArrayOutputStream();
- filter.encode(
- new ByteArrayInputStream( original ),
- encoded, new COSDictionary(), 0 );
-
- ByteArrayOutputStream decoded = new ByteArrayOutputStream();
- filter.decode(
- new ByteArrayInputStream( encoded.toByteArray() ),
- decoded, new COSDictionary(), 0 );
-
- 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;
}
@@ -150,15 +137,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(), 0);
+ filter.encode(new ByteArrayInputStream(original), encoded, new COSDictionary(), 0);
ByteArrayOutputStream decoded = new ByteArrayOutputStream();
- lzwFilter.decode(new ByteArrayInputStream(encoded.toByteArray()),
+ filter.decode(new ByteArrayInputStream(encoded.toByteArray()),
decoded, new COSDictionary(), 0);
+
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()));
}
}