@@ -0,0 +1,2449 @@
+/*%0A * Copyright 2017 Datalogics, Inc.%0A */%0A%0Apackage com.datalogics.pdf.samples.manipulation;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertNull;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport com.adobe.internal.xmp.XMPException;%0Aimport com.adobe.pdfjt.core.exceptions.PDFException;%0Aimport com.adobe.pdfjt.pdf.document.PDFDocument;%0Aimport com.adobe.pdfjt.pdf.document.PDFDocumentInfo;%0Aimport com.adobe.pdfjt.services.xmp.DocumentMetadata;%0Aimport com.adobe.pdfjt.services.xmp.XMPService;%0A%0Aimport com.datalogics.pdf.samples.SampleTest;%0Aimport com.datalogics.pdf.samples.util.DocumentUtils;%0A%0Aimport org.junit.Test;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.net.URL;%0A%0A/**%0A * This tests the RemoveMetadata sample.%0A */%0Apublic class RemoveMetadataTest extends SampleTest %7B%0A%0A    private static final String FILE_NAME = %22MetadataRemoved.pdf%22;%0A    private static final String PRODUCER = %22Datalogics PDF Java Toolkit%22;%0A%0A    @Test%0A    public void testRemovingMetadataFromPdf()%0A                    throws IOException, XMPException,%0A                    PDFException %7B%0A        final URL inputUrl = RemoveMetadata.class.getResource(RemoveMetadata.INPUT_PDF_PATH);%0A        final File outputFile = newOutputFileWithDelete(FILE_NAME);%0A        final URL outputUrl = outputFile.toURI().toURL();%0A%0A        RemoveMetadata.removeMetadata(inputUrl, outputUrl);%0A%0A        // Make sure the Output file exists.%0A        assertTrue(outputFile.getPath() + %22 must exist after run%22, outputFile.exists());%0A%0A        // Verify metadata is removed.%0A        final PDFDocument removedMetadataDoc = DocumentUtils.openPdfDocument(outputUrl);%0A        final DocumentMetadata newMetadata = XMPService.getDocumentMetadata(removedMetadataDoc);%0A        final PDFDocumentInfo newInfo = removedMetadataDoc.getDocumentInfo();%0A        assertEquals(PRODUCER, newMetadata.getProducer());%0A        assertNotNull(newMetadata.getCreationDate());%0A        assertNotNull(newMetadata.getModificationDate());%0A        assertNotNull(newMetadata.getMetadataASDate());%0A        assertNull(newMetadata.getCreator());%0A        assertNull(newMetadata.getTrapped());%0A        assertEquals(PRODUCER, newInfo.getProducer());%0A        assertNotNull(newInfo.getCreationDate());%0A        assertNotNull(newInfo.getModificationDate());%0A        assertNull(newInfo.getCreator());%0A        assertNull(newInfo.getTrapped());%0A    %7D%0A%7D%0A

Test the RemoveMetadata sample