From cfbd5f9d8af638aa830aa535feadb094109e6455 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 15 Oct 2014 14:23:04 +0200 Subject: Rebuild API to support Java DataSource and Streams for in and output --- .../java/at/gv/egiz/pdfas/cli/test/SignaturProfileTest.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'pdf-as-cli/src/test/java/at/gv') diff --git a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturProfileTest.java b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturProfileTest.java index e14b8ca0..6b1eeaa9 100644 --- a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturProfileTest.java +++ b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturProfileTest.java @@ -30,13 +30,13 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import javax.activation.DataSource; + import org.apache.commons.io.IOUtils; import at.gv.egiz.pdfas.common.settings.ISettings; -import at.gv.egiz.pdfas.lib.api.ByteArrayDataSink; import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource; import at.gv.egiz.pdfas.lib.api.Configuration; -import at.gv.egiz.pdfas.lib.api.DataSource; import at.gv.egiz.pdfas.lib.api.PdfAs; import at.gv.egiz.pdfas.lib.api.PdfAsFactory; import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner; @@ -98,19 +98,17 @@ public class SignaturProfileTest { System.out.println("Testing " + profile); DataSource source = new ByteArrayDataSource(input); - ByteArrayDataSink sink = new ByteArrayDataSink(); SignParameter signParameter = PdfAsFactory.createSignParameter( config, source); signParameter.setPlainSigner(signer); - signParameter.setOutput(sink); signParameter.setSignatureProfileId(profile); SignResult result = pdfas.sign(signParameter); FileOutputStream fos = new FileOutputStream(targetFolder + profile + ".pdf"); - fos.write(sink.getData()); + IOUtils.copy(result.getOutputDocument(), fos); fos.close(); } @@ -122,19 +120,17 @@ public class SignaturProfileTest { System.out.println("Testing " + profile); DataSource source = new ByteArrayDataSource(inputPDFA); - ByteArrayDataSink sink = new ByteArrayDataSink(); SignParameter signParameter = PdfAsFactory.createSignParameter( config, source); signParameter.setPlainSigner(signer); - signParameter.setOutput(sink); signParameter.setSignatureProfileId(profile); SignResult result = pdfas.sign(signParameter); FileOutputStream fos = new FileOutputStream(targetFolder + "PDFA_" + profile + ".pdf"); - fos.write(sink.getData()); + IOUtils.copy(result.getOutputDocument(), fos); fos.close(); } } catch (Throwable e) { -- cgit v1.2.3