Skip to content

Commit 38c87e5

Browse files
committed
PDFBOX-6127: add comment, make sure that the intermediate data contains the test sequence, improve formatting
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1930810 13f79535-47bb-0310-9956-ffa450edef68
1 parent 2e6fe11 commit 38c87e5

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -998,14 +998,17 @@ void testPDFBOX6126() throws XmpParsingException, BadFieldValueException, Transf
998998
@Test
999999
void testNonStandardURIinRDF() throws XmpParsingException, TransformerException
10001000
{
1001-
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
1002-
"<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?><x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 4.2.1-c041 52.342996, 2008/05/07-20:48:00 \">\n" +
1003-
" <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
1004-
" <rdf:Description xmlns:pdfx=\"http://ns.adobe.com/pdfx/1.3/\" rdf:about=\"\">\n" +
1005-
" <pdfx:XPressPrivate>private</pdfx:XPressPrivate>\n" +
1006-
" </rdf:Description>\n" +
1007-
" </rdf:RDF>\n" +
1008-
"</x:xmpmeta><?xpacket end=\"w\"?>";
1001+
// PDFBOX-6127: test that non standard namespaces not recognized if in rdf:RDF,
1002+
// which happens since the changes in XmpSerializer done in PDFBOX-2378.
1003+
String s =
1004+
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
1005+
"<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?><x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 4.2.1-c041 52.342996, 2008/05/07-20:48:00 \">\n" +
1006+
" <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
1007+
" <rdf:Description xmlns:pdfx=\"http://ns.adobe.com/pdfx/1.3/\" rdf:about=\"\">\n" +
1008+
" <pdfx:XPressPrivate>private</pdfx:XPressPrivate>\n" +
1009+
" </rdf:Description>\n" +
1010+
" </rdf:RDF>\n" +
1011+
"</x:xmpmeta><?xpacket end=\"w\"?>";
10091012
final DomXmpParser xmpParser1 = new DomXmpParser();
10101013
XmpParsingException ex = assertThrows(XmpParsingException.class,
10111014
() -> xmpParser1.parse(s.getBytes(StandardCharsets.UTF_8)));
@@ -1018,6 +1021,8 @@ void testNonStandardURIinRDF() throws XmpParsingException, TransformerException
10181021
XmpSerializer serializer = new XmpSerializer();
10191022
ByteArrayOutputStream baos = new ByteArrayOutputStream();
10201023
serializer.serialize(xmp2, baos, true);
1024+
// make sure that there is a non standard namespace in rdf:RDF
1025+
assertTrue(baos.toString(StandardCharsets.UTF_8).contains("<rdf:RDF xmlns:pdfx="));
10211026
final DomXmpParser xmpParser3 = new DomXmpParser();
10221027
ex = assertThrows(XmpParsingException.class, () -> xmpParser3.parse(baos.toByteArray()));
10231028
assertEquals("Cannot find a definition for the namespace http://ns.adobe.com/pdfx/1.3/, property: pdfx:XPressPrivate", ex.getMessage());

0 commit comments

Comments
 (0)