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 2018/07/07 18:45:29 UTC
svn commit: r1835327 -
/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java
Author: tilman
Date: Sat Jul 7 18:45:29 2018
New Revision: 1835327
URL: http://svn.apache.org/viewvc?rev=1835327&view=rev
Log:
PDFBOX-4260: add test for double closing
Modified:
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java?rev=1835327&r1=1835326&r2=1835327&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java Sat Jul 7 18:45:29 2018
@@ -40,10 +40,9 @@ public class TestPDPageContentStream ext
{
// pass a non-stroking color in CMYK color space
contentStream.setNonStrokingColor(0.1f, 0.2f, 0.3f, 0.4f);
- contentStream.close();
}
- // now read the PDF stream and verify that the CMYK values are correct
+ // now read the PDF stream and verify that the CMYK values are correct
PDFStreamParser parser = new PDFStreamParser(page.getContents());
parser.parse();
java.util.List<Object> pageTokens = parser.getTokens();
@@ -67,7 +66,6 @@ public class TestPDPageContentStream ext
{
// pass a non-stroking color in CMYK color space
contentStream.setStrokingColor(0.5f, 0.6f, 0.7f, 0.8f);
- contentStream.close();
}
// now read the PDF stream and verify that the CMYK values are correct
@@ -101,4 +99,21 @@ public class TestPDPageContentStream ext
List<Object> tokens = parser.getTokens();
assertEquals(0, tokens.size());
}
+
+ /**
+ * Check that close() can be called twice.
+ *
+ * @throws IOException
+ */
+ public void testCloseContract() throws IOException
+ {
+ try (PDDocument doc = new PDDocument())
+ {
+ PDPage page = new PDPage();
+ doc.addPage(page);
+ PDPageContentStream contentStream = new PDPageContentStream(doc, page, AppendMode.OVERWRITE, true);
+ contentStream.close();
+ contentStream.close();
+ }
+ }
}