@@ -0,0 +1,2467 @@
+/*%0A * Copyright 2015 Datalogics, Inc.%0A */%0A%0Apackage com.datalogics.pdf.samples.sig;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport com.adobe.pdfjt.core.exceptions.PDFIOException;%0Aimport com.adobe.pdfjt.core.exceptions.PDFInvalidDocumentException;%0Aimport com.adobe.pdfjt.core.exceptions.PDFSecurityException;%0Aimport com.adobe.pdfjt.pdf.document.PDFDocument;%0Aimport com.adobe.pdfjt.services.digsig.SignatureFieldInterface;%0Aimport com.adobe.pdfjt.services.digsig.SignatureManager;%0A%0Aimport com.datalogics.pdf.samples.SampleTest;%0A%0Aimport org.junit.Test;%0A%0Aimport java.io.File;%0Aimport java.nio.file.Files;%0Aimport java.util.Iterator;%0A%0A/**%0A * Tests the DocSigning Sample.%0A */%0Apublic class DocSigningTest extends SampleTest %7B%0A    static final String FILE_NAME = %22SignedField1.pdf%22;%0A    static final String QUALIFIED_SIGNATURE_FIELD_NAME = %22SB1_Sig1%22;%0A%0A    @Test%0A    public void testMain() throws Exception %7B%0A        final File file = newOutputFile(FILE_NAME);%0A        if (file.exists()) %7B%0A            Files.delete(file.toPath());%0A        %7D%0A        // The complete file name will be set in the DocSigning class.%0A        final String path = file.getCanonicalPath().replaceAll(%221.pdf%22, %22%22);%0A%0A        DocSigning.main(path);%0A        // Make sure the Output file exists.%0A        assertTrue(file.getPath() + %22 must exist after run%22, file.exists());%0A%0A        final PDFDocument doc = openPdfDocument(file.getCanonicalPath());%0A%0A        try %7B%0A            // Make sure that Signature field is signed.%0A            final SignatureFieldInterface sigField = getSignedSignatureField(doc);%0A            assertTrue(sigField.isSigned());%0A            assertTrue(sigField.isVisible());%0A            assertEquals(QUALIFIED_SIGNATURE_FIELD_NAME, sigField.getQualifiedName());%0A%0A        %7D finally %7B%0A            doc.close();%0A        %7D%0A    %7D%0A%0A    private static SignatureFieldInterface getSignedSignatureField(final PDFDocument doc)%0A                    throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException %7B%0A        // Set up a signature service and get the first signature field.%0A        final SignatureManager sigService = SignatureManager.newInstance(doc);%0A        if (sigService.hasSignedSignatureFields()) %7B%0A            final Iterator%3CSignatureFieldInterface%3E iter = sigService.getDocSignatureFieldIterator();%0A            if (iter.hasNext()) %7B%0A                return iter.next();%0A            %7D%0A        %7D%0A        return null;%0A    %7D%0A%7D%0A

Add Unit test for DocSigning Sample.