Return-Path: X-Original-To: apmail-pdfbox-commits-archive@www.apache.org Delivered-To: apmail-pdfbox-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4276111BB8 for ; Tue, 22 Apr 2014 16:33:24 +0000 (UTC) Received: (qmail 55158 invoked by uid 500); 22 Apr 2014 16:33:24 -0000 Delivered-To: apmail-pdfbox-commits-archive@pdfbox.apache.org Received: (qmail 55102 invoked by uid 500); 22 Apr 2014 16:33:23 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 55094 invoked by uid 99); 22 Apr 2014 16:33:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Apr 2014 16:33:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Apr 2014 16:33:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D330F23888E4; Tue, 22 Apr 2014 16:32:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Tue, 22 Apr 2014 16:32:58 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140422163258.D330F23888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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