Search in sources :

Example 21 with DomXmpParser

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

the class DeserializationTest method testGetTitle.

@Test
public void testGetTitle() throws Exception {
    InputStream fis = DomXmpParser.class.getResourceAsStream("/validxmp/emptyli.xml");
    DomXmpParser xdb = new DomXmpParser();
    XMPMetadata meta = xdb.parse(fis);
    DublinCoreSchema dc = meta.getDublinCoreSchema();
    String s = dc.getTitle(null);
    Assert.assertEquals("title value", s);
}
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 22 with DomXmpParser

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

the class DeserializationTest method testAltBagSeq.

@Test
public void testAltBagSeq() throws Exception {
    InputStream fis = DomXmpParser.class.getResourceAsStream("/org/apache/xmpbox/parser/AltBagSeqTest.xml");
    DomXmpParser xdb = new DomXmpParser();
    xdb.parse(fis);
// XMPMetadata metadata=xdb.parse(fis);
// SaveMetadataHelper.serialize(metadata, true, System.out);
}
Also used : InputStream(java.io.InputStream) DomXmpParser(org.apache.xmpbox.xml.DomXmpParser) Test(org.junit.Test)

Example 23 with DomXmpParser

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

the class DeserializationTest method testUndefinedSchema.

@Test
public void testUndefinedSchema() throws Exception {
    InputStream fis = DomXmpParser.class.getResourceAsStream("/invalidxmp/undefinedschema.xml");
    DomXmpParser xdb = new DomXmpParser();
    try {
        xdb.parse(fis);
        Assert.fail("Should fail during parse");
    } catch (XmpParsingException e) {
        Assert.assertEquals(ErrorType.NoSchema, 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 24 with DomXmpParser

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

the class DeserializationTest method testUndefinedStructuredWithDefinedSchema.

@Test
public void testUndefinedStructuredWithDefinedSchema() throws Exception {
    InputStream fis = DomXmpParser.class.getResourceAsStream("/invalidxmp/undefinedstructuredindefinedschema.xml");
    DomXmpParser xdb = new DomXmpParser();
    try {
        xdb.parse(fis);
        Assert.fail("Should fail during parse");
    } catch (XmpParsingException e) {
        Assert.assertEquals(ErrorType.NoValueType, 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 25 with DomXmpParser

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

the class DeserializationTest method testWithNoXPacketEnd.

@Test
public void testWithNoXPacketEnd() throws Exception {
    InputStream fis = DomXmpParser.class.getResourceAsStream("/invalidxmp/noxpacketend.xml");
    DomXmpParser xdb = new DomXmpParser();
    try {
        xdb.parse(fis);
        Assert.fail("Should fail during parse");
    } catch (XmpParsingException e) {
        Assert.assertEquals(ErrorType.XpacketBadEnd, 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