aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-cli/src/test
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-06-23 14:51:45 +0200
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-06-23 16:23:18 +0200
commitc6bc4b4960fce3dbca9db119c583712a13731b6e (patch)
tree7961035e32a64976c2c06974280dcead930c3c86 /pdf-as-cli/src/test
parent262a0691d871882ff5b68afeb198b6e91293e704 (diff)
downloadpdf-as-4-c6bc4b4960fce3dbca9db119c583712a13731b6e.tar.gz
pdf-as-4-c6bc4b4960fce3dbca9db119c583712a13731b6e.tar.bz2
pdf-as-4-c6bc4b4960fce3dbca9db119c583712a13731b6e.zip
more tests
Diffstat (limited to 'pdf-as-cli/src/test')
-rw-r--r--pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java36
1 files changed, 35 insertions, 1 deletions
diff --git a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java
index 7b29b535..5689b080 100644
--- a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java
+++ b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java
@@ -106,7 +106,6 @@ public class SignaturBlockParameterTest {
PdfAs pdfas = PdfAsFactory.createPdfAs(new File(getPath("pdfas-config")));
Configuration config = pdfas.getConfiguration();
-
byte[] input = IOUtils.toByteArray(new FileInputStream(getPath("simple_rotated_0.pdf")));
IPlainSigner signer = new PAdESSignerKeystore(getPath("test.p12"), KS_ALIAS, KS_PASS, KS_KEY_PASS, KS_TYPE);
@@ -197,6 +196,41 @@ public class SignaturBlockParameterTest {
}
+ @Test
+ public void testWithUmlaute() throws IOException, PDFASError, PdfAsException {
+
+ PdfAs pdfas = PdfAsFactory.createPdfAs(new File(getPath("pdfas-config")));
+ Configuration config = pdfas.getConfiguration();
+
+
+ byte[] input = IOUtils.toByteArray(new FileInputStream(getPath("simple_rotated_0.pdf")));
+
+ IPlainSigner signer = new PAdESSignerKeystore(getPath("test.p12"), KS_ALIAS, KS_PASS, KS_KEY_PASS, KS_TYPE);
+
+ String profile = "SIGNATURBLOCK_DE_NOTE_DYNAMIC";
+ System.out.println("Testing " + profile);
+
+ DataSource source = new ByteArrayDataSource(input);
+ String outFile = getPath("out") + "/" + profile + "-umlaute.pdf";
+ FileOutputStream fos = new FileOutputStream(outFile);
+ SignParameter signParameter = PdfAsFactory.createSignParameter(
+ config, source, fos);
+
+ Map<String, String> map = new HashMap<>();
+ map.put("subject", "TEST123");
+ map.put("foo", "baräöÜ");
+ signParameter.setDynamicSignatureBlockArguments(map);
+ signParameter.setPlainSigner(signer);
+ signParameter.setSignatureProfileId(profile);
+
+ SignResult result = pdfas.sign(signParameter);
+
+ fos.close();
+ String name = getName(outFile, "PDF-AS Signatur1");
+ Assert.assertEquals("TEST123 test baräöÜ 123 c TEST123 Andreas Fitzek ECC", name);
+ //expected:<TEST123 test bar[] 123 c TEST123 Andre...> but was:<TEST123 test bar[äöÜ] 123 c TEST123 Andre...>
+ }
+
private String getName(String fileName, String sigFieldName) throws IOException {
PDDocument pdDoc = PDDocument.load(new File(fileName));
PDSignature signature = null;