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/22 18:32:58 UTC
svn commit: r1589200 - in /pdfbox/trunk/pdfbox/src/test:
java/org/apache/pdfbox/filter/TestFilters.java
resources/org/apache/pdfbox/filter/
resources/org/apache/pdfbox/filter/PDFBOX-1777.bin
Author: tilman
Date: Tue Apr 22 16:32:58 2014
New Revision: 1589200
URL: http://svn.apache.org/r1589200
Log:
PDFBOX-2036: Add test with LZW fail sequence
Added:
pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/filter/
pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/filter/PDFBOX-1777.bin (with props)
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=1589200&r1=1589199&r2=1589200&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 Tue Apr 22 16:32:58 2014
@@ -19,12 +19,14 @@ package org.apache.pdfbox.filter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.Arrays;
import java.util.Random;
import junit.framework.TestCase;
import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
/**
* This will test all of the filters in the PDFBox system.
@@ -109,5 +111,35 @@ public class TestFilters extends TestCas
}
}
}
+
+ /**
+ * This will test the LZW filter with the sequence that failed in PDFBOX-1777.
+ * To check that the test itself is legit, revert LZWFilter.java to rev 1571801,
+ * which should fail this test.
+ *
+ * @throws IOException
+ */
+ public void testPDFBOX1777() throws IOException
+ {
+ Filter lzwFilter = FilterFactory.INSTANCE.getFilter(COSName.LZW_DECODE);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ InputStream is = this.getClass().getResourceAsStream("PDFBOX-1777.bin");
+ int by;
+ while ((by = is.read()) != -1)
+ {
+ baos.write(by);
+ }
+ is.close();
+ ByteArrayOutputStream encoded = new ByteArrayOutputStream();
+ lzwFilter.encode(new ByteArrayInputStream(baos.toByteArray()),
+ encoded, new COSDictionary());
+ ByteArrayOutputStream decoded = new ByteArrayOutputStream();
+ lzwFilter.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()));
+ }
}
Added: pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/filter/PDFBOX-1777.bin
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/filter/PDFBOX-1777.bin?rev=1589200&view=auto
==============================================================================
Binary file - no diff available.
Propchange: pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/filter/PDFBOX-1777.bin
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream