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 2019/05/31 09:02:49 UTC
svn commit: r1860439 -
/pdfbox/branches/issue45/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
Author: tilman
Date: Fri May 31 09:02:49 2019
New Revision: 1860439
URL: http://svn.apache.org/viewvc?rev=1860439&view=rev
Log:
PDFBOX-3017: add tests of getContents() and getSignedContent()
Modified:
pdfbox/branches/issue45/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
Modified: pdfbox/branches/issue45/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java?rev=1860439&r1=1860438&r2=1860439&view=diff
==============================================================================
--- pdfbox/branches/issue45/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java (original)
+++ pdfbox/branches/issue45/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java Fri May 31 09:02:49 2019
@@ -314,6 +314,21 @@ public class TestCreateSignature
byte[] buf = sig.getSignedContent(new FileInputStream(signedFile));
+ // verify that getSignedContent() brings the same content
+ // regardless whether from an InputStream or from a byte array
+ FileInputStream fis2 = new FileInputStream(signedFile);
+ byte[] buf2 = sig.getSignedContent(IOUtils.toByteArray(fis2));
+ Assert.assertArrayEquals(buf, buf2);
+ fis2.close();
+
+ // verify that all getContents() methods returns the same content
+ FileInputStream fis3 = new FileInputStream(signedFile);
+ byte[] contents2 = sig.getContents(IOUtils.toByteArray(fis3));
+ Assert.assertArrayEquals(contents.getBytes(), contents2);
+ fis3.close();
+ byte[] contents3 = sig.getContents(new FileInputStream(signedFile));
+ Assert.assertArrayEquals(contents.getBytes(), contents3);
+
// inspiration:
// http://stackoverflow.com/a/26702631/535646
// http://stackoverflow.com/a/9261365/535646