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 2020/05/01 07:55:48 UTC
svn commit: r1877246 -
/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureFieldTest.java
Author: tilman
Date: Fri May 1 07:55:48 2020
New Revision: 1877246
URL: http://svn.apache.org/viewvc?rev=1877246&view=rev
Log:
PDFBOX-4822: add test
Modified:
pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureFieldTest.java
Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureFieldTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureFieldTest.java?rev=1877246&r1=1877245&r2=1877246&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureFieldTest.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDSignatureFieldTest.java Fri May 1 07:55:48 2020
@@ -16,9 +16,7 @@
*/
package org.apache.pdfbox.pdmodel.interactive.form;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -26,7 +24,11 @@ import java.util.List;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget;
+import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
+import org.apache.pdfbox.util.Charsets;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import org.junit.Before;
import org.junit.Test;
@@ -74,4 +76,20 @@ public class PDSignatureFieldTest
((PDField) sigField).setValue("Can't set value using String");
}
+
+ /**
+ * PDFBOX-4822: test get the signature contents.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testGetContents() throws IOException
+ {
+ // Normally, range0 + range1 = position of "<", and range2 = position after ">"
+ PDSignature signature = new PDSignature();
+ signature.setByteRange(new int[]{ 0, 10, 30, 10});
+ byte[] by = "AAAAAAAAAA<313233343536373839>BBBBBBBBBB".getBytes(Charsets.ISO_8859_1);
+ assertEquals("123456789", new String(signature.getContents(by)));
+ assertEquals("123456789", new String(signature.getContents(new ByteArrayInputStream(by))));
+ }
}