Skip to content

Commit 4f9c82f

Browse files
committed
PDFBOX-5660: expand test coverage
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1930620 13f79535-47bb-0310-9956-ffa450edef68
1 parent a80bb1b commit 4f9c82f

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

xmpbox/src/test/java/org/apache/xmpbox/xml/DomXmpParserTest.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,4 +681,50 @@ void testNoRdfChildren() throws XmpParsingException
681681
() -> xmpParser.parse(s.getBytes(StandardCharsets.UTF_8)));
682682
assertEquals("No rdf description found in xmp", ex.getMessage());
683683
}
684+
685+
@Test
686+
void testTextInsteadOfArray() throws XmpParsingException
687+
{
688+
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
689+
"<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n" +
690+
"<x:xmpmeta xmlns:x=\"adobe:ns:meta/\"\n" +
691+
" x:xmptk=\"3.1-701\">\n" +
692+
" <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
693+
" <rdf:Description xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" +
694+
" rdf:about=\"\">\n" +
695+
" <dc:title>Title</dc:title>\n" +
696+
" </rdf:Description>\n" +
697+
" </rdf:RDF>\n" +
698+
"</x:xmpmeta><?xpacket end=\"w\"?>";
699+
final DomXmpParser xmpParser = new DomXmpParser();
700+
XmpParsingException ex = assertThrows(
701+
XmpParsingException.class,
702+
() -> xmpParser.parse(s.getBytes(StandardCharsets.UTF_8)));
703+
assertEquals("Invalid array definition, expecting Alt and found Text [prefix=dc; name=title]", ex.getMessage());
704+
}
705+
706+
@Test
707+
void testPropertyNotDefined() throws XmpParsingException
708+
{
709+
// While "Fired" does exist as a type, it's not the correct syntax, the PDFLib XMP validator complains too.
710+
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
711+
"<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>\n" +
712+
"<x:xmpmeta xmlns:x=\"adobe:ns:meta/\"\n" +
713+
" x:xmptk=\"XMP toolkit 3.0-28, framework 1.6\">\n" +
714+
" <rdf:RDF xmlns:iX=\"http://ns.adobe.com/iX/1.0/\"\n" +
715+
" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
716+
" <rdf:Description xmlns:exif=\"http://ns.adobe.com/exif/1.0/\"\n" +
717+
" rdf:about=\"uuid:d9974396-53ee-11d9-9542-81b7ec7f4613\">\n" +
718+
" <exif:Flash rdf:parseType=\"Resource\">\n" +
719+
" <exif:Fired>False</exif:Fired>\n" +
720+
" </exif:Flash>\n" +
721+
" </rdf:Description>\n" +
722+
" </rdf:RDF>\n" +
723+
"</x:xmpmeta><?xpacket end='w'?>";
724+
final DomXmpParser xmpParser = new DomXmpParser();
725+
XmpParsingException ex = assertThrows(
726+
XmpParsingException.class,
727+
() -> xmpParser.parse(s.getBytes(StandardCharsets.UTF_8)));
728+
assertEquals("Property 'Fired' not defined in http://ns.adobe.com/exif/1.0/", ex.getMessage());
729+
}
684730
}

0 commit comments

Comments
 (0)