Search in sources :

Example 6 with DomXmpParser

use of org.apache.xmpbox.xml.DomXmpParser in project pdfbox by apache.

the class DeserializationTest method testWithRDFRootAsText.

@Test
public void testWithRDFRootAsText() throws Exception {
    InputStream fis = DomXmpParser.class.getResourceAsStream("/invalidxmp/invalidroot.xml");
    DomXmpParser xdb = new DomXmpParser();
    try {
        xdb.parse(fis);
        Assert.fail("Should fail during parse");
    } catch (XmpParsingException e) {
        Assert.assertEquals(ErrorType.Format, e.getErrorType());
    }
}
Also used : XmpParsingException(org.apache.xmpbox.xml.XmpParsingException) InputStream(java.io.InputStream) DomXmpParser(org.apache.xmpbox.xml.DomXmpParser) Test(org.junit.Test)

Example 7 with DomXmpParser

use of org.apache.xmpbox.xml.DomXmpParser in project pdfbox by apache.

the class DeserializationTest method testStructuredRecursive.

@Test
public void testStructuredRecursive() throws Exception {
    InputStream fis = DomXmpParser.class.getResourceAsStream("/org/apache/xmpbox/parser/structured_recursive.xml");
    DomXmpParser xdb = new DomXmpParser();
    xdb.parse(fis);
}
Also used : InputStream(java.io.InputStream) DomXmpParser(org.apache.xmpbox.xml.DomXmpParser) Test(org.junit.Test)

Example 8 with DomXmpParser

use of org.apache.xmpbox.xml.DomXmpParser in project pdfbox by apache.

the class DeserializationTest method testEmptyLi2.

@Test
public void testEmptyLi2() throws Exception {
    InputStream fis = DomXmpParser.class.getResourceAsStream("/validxmp/emptyli.xml");
    DomXmpParser xdb = new DomXmpParser();
    XMPMetadata meta = xdb.parse(fis);
    DublinCoreSchema dc = meta.getDublinCoreSchema();
    dc.getCreatorsProperty();
}
Also used : XMPMetadata(org.apache.xmpbox.XMPMetadata) InputStream(java.io.InputStream) DomXmpParser(org.apache.xmpbox.xml.DomXmpParser) DublinCoreSchema(org.apache.xmpbox.schema.DublinCoreSchema) Test(org.junit.Test)

Example 9 with DomXmpParser

use of org.apache.xmpbox.xml.DomXmpParser in project pdfbox by apache.

the class DeserializationTest method testRdfAboutFound.

@Test
public void testRdfAboutFound() throws Exception {
    InputStream fis = DomXmpParser.class.getResourceAsStream("/validxmp/emptyli.xml");
    DomXmpParser xdb = new DomXmpParser();
    XMPMetadata meta = xdb.parse(fis);
    List<XMPSchema> schemas = meta.getAllSchemas();
    for (XMPSchema xmpSchema : schemas) {
        Assert.assertNotNull(xmpSchema.getAboutAttribute());
    }
}
Also used : XMPMetadata(org.apache.xmpbox.XMPMetadata) XMPSchema(org.apache.xmpbox.schema.XMPSchema) InputStream(java.io.InputStream) DomXmpParser(org.apache.xmpbox.xml.DomXmpParser) Test(org.junit.Test)

Example 10 with DomXmpParser

use of org.apache.xmpbox.xml.DomXmpParser in project pdfbox by apache.

the class DeserializationTest method testWithNoRDFElement.

@Test
public void testWithNoRDFElement() throws Exception {
    InputStream fis = DomXmpParser.class.getResourceAsStream("/invalidxmp/noroot.xml");
    DomXmpParser xdb = new DomXmpParser();
    try {
        xdb.parse(fis);
        Assert.fail("Should fail during parse");
    } catch (XmpParsingException e) {
        Assert.assertEquals(ErrorType.Format, e.getErrorType());
    }
}
Also used : XmpParsingException(org.apache.xmpbox.xml.XmpParsingException) InputStream(java.io.InputStream) DomXmpParser(org.apache.xmpbox.xml.DomXmpParser) Test(org.junit.Test)

Aggregations

DomXmpParser (org.apache.xmpbox.xml.DomXmpParser)28 InputStream (java.io.InputStream)21 Test (org.junit.Test)21 XmpParsingException (org.apache.xmpbox.xml.XmpParsingException)12 XMPMetadata (org.apache.xmpbox.XMPMetadata)11 DublinCoreSchema (org.apache.xmpbox.schema.DublinCoreSchema)6 PDDocument (org.apache.pdfbox.pdmodel.PDDocument)3 PDMetadata (org.apache.pdfbox.pdmodel.common.PDMetadata)3 ValidationError (org.apache.pdfbox.preflight.ValidationResult.ValidationError)3 XMPBasicSchema (org.apache.xmpbox.schema.XMPBasicSchema)3 File (java.io.File)2 PDDocumentCatalog (org.apache.pdfbox.pdmodel.PDDocumentCatalog)2 AdobePDFSchema (org.apache.xmpbox.schema.AdobePDFSchema)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 PDDocumentInformation (org.apache.pdfbox.pdmodel.PDDocumentInformation)1 PreflightDocument (org.apache.pdfbox.preflight.PreflightDocument)1