pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1692165 - /pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java
Date Tue, 21 Jul 2015 16:30:05 GMT
Author: tilman
Date: Tue Jul 21 16:30:05 2015
New Revision: 1692165

URL: http://svn.apache.org/r1692165
Log:
PDFBOX-2896: check XMP title in test

Modified:
    pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java

Modified: pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java?rev=1692165&r1=1692164&r2=1692165&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java
(original)
+++ pdfbox/trunk/examples/src/test/java/org/apache/pdfbox/examples/pdfa/CreatePDFATest.java
Tue Jul 21 16:30:05 2015
@@ -19,10 +19,16 @@ import junit.framework.TestCase;
 
 import java.io.File;
 import org.apache.pdfbox.examples.pdmodel.CreatePDFA;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
+import org.apache.pdfbox.pdmodel.common.PDMetadata;
 import org.apache.pdfbox.preflight.PreflightDocument;
 import org.apache.pdfbox.preflight.ValidationResult;
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 import org.apache.pdfbox.preflight.parser.PreflightParser;
+import org.apache.xmpbox.XMPMetadata;
+import org.apache.xmpbox.schema.DublinCoreSchema;
+import org.apache.xmpbox.xml.DomXmpParser;
 
 /**
  *
@@ -30,7 +36,7 @@ import org.apache.pdfbox.preflight.parse
  */
 public class CreatePDFATest extends TestCase
 {
-    private final String outDir = "target/test-output/";
+    private final String outDir = "target/test-output";
 
     @Override
     protected void setUp() throws Exception
@@ -62,6 +68,16 @@ public class CreatePDFATest extends Test
         }
         assertTrue("PDF file created with CreatePDFA is not valid PDF/A-1b", result.isValid());
         preflightDocument.close();
+        
+        // check the XMP metadata
+        PDDocument document = PDDocument.load(new File(pdfaFilename));
+        PDDocumentCatalog catalog = document.getDocumentCatalog();
+        PDMetadata meta = catalog.getMetadata();
+        DomXmpParser xmpParser = new DomXmpParser();
+        XMPMetadata metadata = xmpParser.parse(meta.createInputStream());
+        DublinCoreSchema dc = metadata.getDublinCoreSchema();
+        assertEquals(pdfaFilename, dc.getTitle());
+        document.close();
     }
     
 }



Mime
View raw message