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 2017/03/27 16:31:04 UTC
svn commit: r1788979 -
/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/filter/TestFilters.java
Author: tilman
Date: Mon Mar 27 16:31:04 2017
New Revision: 1788979
URL: http://svn.apache.org/viewvc?rev=1788979&view=rev
Log:
PDFBOX-2852: simplify and optimize code
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=1788979&r1=1788978&r2=1788979&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 Mon Mar 27 16:31:04 2017
@@ -19,7 +19,6 @@ 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;
@@ -27,6 +26,7 @@ import junit.framework.TestCase;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.io.IOUtils;
/**
* This will test all of the filters in the PDFBox system.
@@ -126,16 +126,8 @@ public class TestFilters extends TestCas
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();
-
- checkEncodeDecode(lzwFilter, baos.toByteArray());
+ byte[] byteArray = IOUtils.toByteArray(this.getClass().getResourceAsStream("PDFBOX-1777.bin"));
+ checkEncodeDecode(lzwFilter, byteArray);
}
private void checkEncodeDecode(Filter filter, byte[] original) throws IOException