pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1823699 - in /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos: TestCOSInteger.java TestCOSName.java
Date Fri, 09 Feb 2018 20:52:34 GMT
Author: msahyoun
Date: Fri Feb  9 20:52:34 2018
New Revision: 1823699

URL: http://svn.apache.org/viewvc?rev=1823699&view=rev
Log:
PDFBOX-4071: add @Override annotation; use try-with

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSInteger.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSName.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSInteger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSInteger.java?rev=1823699&r1=1823698&r2=1823699&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSInteger.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSInteger.java Fri Feb  9
20:52:34 2018
@@ -31,6 +31,7 @@ import org.apache.pdfbox.pdfwriter.COSWr
  */
 public class TestCOSInteger extends TestCOSNumber
 {
+    @Override
     public void setUp()
     {
         try

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSName.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSName.java?rev=1823699&r1=1823698&r2=1823699&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSName.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSName.java Fri Feb  9 20:52:34
2018
@@ -34,17 +34,21 @@ public class TestCOSName
     public void PDFBox4076() throws IOException
     {
         String special = "中国你好!";
-        PDDocument document = new PDDocument();
-        PDPage page = new PDPage();
-        document.addPage(page);
-        document.getDocumentCatalog().getCOSObject().setString(COSName.getPDFName(special),
special);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        document.save(baos);
-        document.close();
-        document = PDDocument.load(baos.toByteArray());
-        COSDictionary catalogDict = document.getDocumentCatalog().getCOSObject();
-        Assert.assertTrue(catalogDict.containsKey(special));
-        Assert.assertEquals(special, catalogDict.getString(special));
-        document.close();
+
+        try (PDDocument document = new PDDocument())
+        {
+            PDPage page = new PDPage();
+            document.addPage(page);
+            document.getDocumentCatalog().getCOSObject().setString(COSName.getPDFName(special),
special);
+            
+            document.save(baos);
+        }
+        try (PDDocument document = PDDocument.load(baos.toByteArray()))
+        {
+            COSDictionary catalogDict = document.getDocumentCatalog().getCOSObject();
+            Assert.assertTrue(catalogDict.containsKey(special));
+            Assert.assertEquals(special, catalogDict.getString(special));
+        }
     }
 }



Mime
View raw message