pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1826159 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java
Date Wed, 07 Mar 2018 21:19:42 GMT
Author: tilman
Date: Wed Mar  7 21:19:42 2018
New Revision: 1826159

URL: http://svn.apache.org/viewvc?rev=1826159&view=rev
Log:
PDFBOX-4071: use jdk7 try-with-resources

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java?rev=1826159&r1=1826158&r2=1826159&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java Wed
Mar  7 21:19:42 2018
@@ -38,22 +38,22 @@ public class PDStreamTest
     @Test
     public void testCreateInputStreamNullFilters() throws Exception
     {
-        PDDocument doc = new PDDocument();
-        InputStream is = new ByteArrayInputStream(new byte[] { 12, 34, 56, 78 });
-        PDStream pdStream = new PDStream(doc, is, (COSArray) null);
-        Assert.assertNull(pdStream.getFilters());
-        List<String> stopFilters = new ArrayList<>();
-        stopFilters.add(COSName.DCT_DECODE.toString());
-        stopFilters.add(COSName.DCT_DECODE_ABBREVIATION.toString());
-        
-        is = pdStream.createInputStream(stopFilters);
-        Assert.assertEquals(12,is.read());
-        Assert.assertEquals(34,is.read());
-        Assert.assertEquals(56,is.read());
-        Assert.assertEquals(78,is.read());
-        Assert.assertEquals(-1,is.read());
-        
-        doc.close();
+        try (PDDocument doc = new PDDocument())
+        {
+            InputStream is = new ByteArrayInputStream(new byte[] { 12, 34, 56, 78 });
+            PDStream pdStream = new PDStream(doc, is, (COSArray) null);
+            Assert.assertNull(pdStream.getFilters());
+            List<String> stopFilters = new ArrayList<>();
+            stopFilters.add(COSName.DCT_DECODE.toString());
+            stopFilters.add(COSName.DCT_DECODE_ABBREVIATION.toString());
+            
+            is = pdStream.createInputStream(stopFilters);
+            Assert.assertEquals(12,is.read());
+            Assert.assertEquals(34,is.read());
+            Assert.assertEquals(56,is.read());
+            Assert.assertEquals(78,is.read());
+            Assert.assertEquals(-1,is.read());
+        }
     } 
     
     /**
@@ -62,22 +62,22 @@ public class PDStreamTest
     @Test
     public void testCreateInputStreamEmptyFilters() throws Exception
     {
-        PDDocument doc = new PDDocument();
-        InputStream is = new ByteArrayInputStream(new byte[] { 12, 34, 56, 78 });
-        PDStream pdStream = new PDStream(doc, is, new COSArray());
-        Assert.assertEquals(0,pdStream.getFilters().size());
-        List<String> stopFilters = new ArrayList<>();
-        stopFilters.add(COSName.DCT_DECODE.toString());
-        stopFilters.add(COSName.DCT_DECODE_ABBREVIATION.toString());
-        
-        is = pdStream.createInputStream(stopFilters);
-        Assert.assertEquals(12,is.read());
-        Assert.assertEquals(34,is.read());
-        Assert.assertEquals(56,is.read());
-        Assert.assertEquals(78,is.read());
-        Assert.assertEquals(-1,is.read());
-        
-        doc.close();
+        try (PDDocument doc = new PDDocument())
+        {
+            InputStream is = new ByteArrayInputStream(new byte[] { 12, 34, 56, 78 });
+            PDStream pdStream = new PDStream(doc, is, new COSArray());
+            Assert.assertEquals(0,pdStream.getFilters().size());
+            List<String> stopFilters = new ArrayList<>();
+            stopFilters.add(COSName.DCT_DECODE.toString());
+            stopFilters.add(COSName.DCT_DECODE_ABBREVIATION.toString());
+            
+            is = pdStream.createInputStream(stopFilters);
+            Assert.assertEquals(12,is.read());
+            Assert.assertEquals(34,is.read());
+            Assert.assertEquals(56,is.read());
+            Assert.assertEquals(78,is.read());
+            Assert.assertEquals(-1,is.read());
+        }
     }
     
     /**
@@ -86,19 +86,19 @@ public class PDStreamTest
     @Test
     public void testCreateInputStreamNullStopFilters() throws Exception
     {
-        PDDocument doc = new PDDocument();
-        InputStream is = new ByteArrayInputStream(new byte[] { 12, 34, 56, 78 });
-        PDStream pdStream = new PDStream(doc, is, new COSArray());
-        Assert.assertEquals(0, pdStream.getFilters().size());
-
-        is = pdStream.createInputStream(null);
-        Assert.assertEquals(12, is.read());
-        Assert.assertEquals(34, is.read());
-        Assert.assertEquals(56, is.read());
-        Assert.assertEquals(78,is.read());
-        Assert.assertEquals(-1,is.read());
-        
-        doc.close();
+        try (PDDocument doc = new PDDocument())
+        {
+            InputStream is = new ByteArrayInputStream(new byte[] { 12, 34, 56, 78 });
+            PDStream pdStream = new PDStream(doc, is, new COSArray());
+            Assert.assertEquals(0, pdStream.getFilters().size());
+            
+            is = pdStream.createInputStream(null);
+            Assert.assertEquals(12, is.read());
+            Assert.assertEquals(34, is.read());
+            Assert.assertEquals(56, is.read());
+            Assert.assertEquals(78,is.read());
+            Assert.assertEquals(-1,is.read());
+        }
     }
 
 }



Mime
View raw message