Skip to content

Commit 0155e7a

Browse files
committed
PDFBOX-6108: add test for PageTextSchema and Dimensions
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1930108 13f79535-47bb-0310-9956-ffa450edef68
1 parent d1af992 commit 0155e7a

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
import org.apache.xmpbox.XMPMetadata;
2929
import org.apache.xmpbox.schema.XMPMediaManagementSchema;
30+
import org.apache.xmpbox.schema.XMPPageTextSchema;
3031
import org.apache.xmpbox.type.ArrayProperty;
32+
import org.apache.xmpbox.type.DimensionsType;
3133
import org.apache.xmpbox.type.ResourceEventType;
3234

3335
import org.junit.jupiter.api.Assertions;
@@ -39,10 +41,6 @@
3941
*/
4042
class DomXmpParserTest
4143
{
42-
DomXmpParserTest()
43-
{
44-
}
45-
4644
@Test
4745
void testPDFBox5649() throws IOException, XmpParsingException
4846
{
@@ -158,4 +156,32 @@ void testPDFBox5288() throws XmpParsingException
158156
Assertions.assertEquals("created", firstHistoryEntry.getAction());
159157
Assertions.assertEquals("iDRS PDF output engine 7", firstHistoryEntry.getParameters());
160158
}
159+
160+
@Test
161+
void testPageTextSchema() throws XmpParsingException
162+
{
163+
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
164+
"<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n" +
165+
"<x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n" +
166+
" <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
167+
" <rdf:Description xmlns:xmpTPg=\"http://ns.adobe.com/xap/1.0/t/pg/\"\n" +
168+
" rdf:about=\"\">\n" +
169+
" <xmpTPg:MaxPageSize>\n" +
170+
" <rdf:Description xmlns:stDim=\"http://ns.adobe.com/xap/1.0/sType/Dimensions#\">\n" +
171+
" <stDim:w>4</stDim:w>\n" +
172+
" <stDim:h>3</stDim:h>\n" +
173+
" <stDim:unit>inch</stDim:unit>\n" +
174+
" </rdf:Description>\n" +
175+
" </xmpTPg:MaxPageSize>\n" +
176+
" <xmpTPg:NPages>7</xmpTPg:NPages>\n" +
177+
" </rdf:Description>\n" +
178+
" </rdf:RDF>\n" +
179+
"</x:xmpmeta><?xpacket end=\"r\"?>";
180+
DomXmpParser xmpParser = new DomXmpParser();
181+
XMPMetadata xmp = xmpParser.parse(s.getBytes(StandardCharsets.UTF_8));
182+
XMPPageTextSchema pageTextSchema = xmp.getPageTextSchema();
183+
DimensionsType dim = (DimensionsType) pageTextSchema.getProperty(XMPPageTextSchema.MAX_PAGE_SIZE);
184+
Assertions.assertEquals("DimensionsType{4.0 x 3.0 inch}", dim.toString());
185+
Assertions.assertEquals("[IntegerType:7]", pageTextSchema.getProperty(XMPPageTextSchema.N_PAGES).toString());
186+
}
161187
}

0 commit comments

Comments
 (0)