@Test public void testRDFSeq() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-seq-example.xml")); assertEquals(1, directory.size()); assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(Arrays.asList("XMP", "metadata", "ISO standard"))); }
@Test public void testRDFBag() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-bag-example.xml")); assertEquals(1, directory.size()); assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(Arrays.asList("XMP", "metadata", "ISO standard"))); // Order does not matter }
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentDC() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // dc|http://purl.org/dc/elements/1.1/ Directory dc = getDirectoryByNS(compound, XMP.NS_DC); assertEquals(1, dc.size()); assertThat(dc.getEntryById("http://purl.org/dc/elements/1.1/format"), hasValue("image/jpeg")); }
@Test public void testRDFAttributeSyntaxCompound() throws IOException { // Alternate RDF syntax, using attribute values instead of nested tags Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; assertEquals(6, compound.directoryCount()); int size = 0; for (int i = 0; i < compound.directoryCount(); i++) { Directory sub = compound.getDirectory(i); assertNotNull(sub); size += sub.size(); } assertEquals(directory.size(), size); }
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentPhotoshop() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // photoshop|http://ns.adobe.com/photoshop/1.0/ Directory photoshop = getDirectoryByNS(compound, XMP.NS_PHOTOSHOP); assertEquals(3, photoshop.size()); assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/ColorMode"), hasValue("1")); assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/ICCProfile"), hasValue("Dot Gain 20%")); assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/History"), hasValue("")); }
@Test public void testRDFAlt() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-alt-example.xml")); assertEquals(1, directory.size()); assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(new HashMap<String, String>() {{ put("x-default", "One"); put("en-us", "One"); put("de", "Ein"); put("no-nb", "En"); }})); }
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentXAP() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // xap|http://ns.adobe.com/xap/1.0/ Directory xap = getDirectoryByNS(compound, XMP.NS_XAP); assertEquals(4, xap.size()); assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/ModifyDate"), hasValue("2008-07-16T14:44:49-07:00")); assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/CreatorTool"), hasValue("Adobe Photoshop CS3 Windows")); assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/CreateDate"), hasValue("2008-07-16T14:44:49-07:00")); assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/MetadataDate"), hasValue("2008-07-16T14:44:49-07:00")); }
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentEXIF() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // exif|http://ns.adobe.com/exif/1.0/ Directory exif = getDirectoryByNS(compound, XMP.NS_EXIF); assertEquals(4, exif.size()); assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/ColorSpace"), hasValue("-1")); // SIC. Same as unsigned short 65535, meaning "uncalibrated"? assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/PixelXDimension"), hasValue("426")); assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/PixelYDimension"), hasValue("550")); assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/NativeDigest"), hasValue("36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;A7F21D25E2C562F152B2C4ECC9E534DA")); } }
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentMM() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // xapMM|http://ns.adobe.com/xap/1.0/mm/ Directory mm = getDirectoryByNS(compound, XMP.NS_XAP_MM); assertEquals(3, mm.size()); assertThat(directory.getEntryById("http://ns.adobe.com/xap/1.0/mm/DocumentID"), hasValue("uuid:6DCA50CC7D53DD119F20F5A7EA4C9BEC")); assertThat(directory.getEntryById("http://ns.adobe.com/xap/1.0/mm/InstanceID"), hasValue("uuid:6ECA50CC7D53DD119F20F5A7EA4C9BEC")); // Custom test, as NamedNodeMap does not preserve order (tests can't rely on XML impl specifics) Entry derivedFrom = directory.getEntryById("http://ns.adobe.com/xap/1.0/mm/DerivedFrom"); assertNotNull(derivedFrom); assertThat(derivedFrom.getValue(), instanceOf(RDFDescription.class)); // stRef|http://ns.adobe.com/xap/1.0/sType/ResourceRef# RDFDescription stRef = (RDFDescription) derivedFrom.getValue(); assertThat(stRef.getEntryById("http://ns.adobe.com/xap/1.0/sType/ResourceRef#instanceID"), hasValue("uuid:74E1C905B405DD119306A1902BA5AA28")); assertThat(stRef.getEntryById("http://ns.adobe.com/xap/1.0/sType/ResourceRef#documentID"), hasValue("uuid:7A6C79768005DD119306A1902BA5AA28")); }
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentTIFF() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // tiff|http://ns.adobe.com/tiff/1.0/ Directory tiff = getDirectoryByNS(compound, XMP.NS_TIFF); assertEquals(5, tiff.size()); assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/Orientation"), hasValue("1")); assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/XResolution"), hasValue("720000/10000")); assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/YResolution"), hasValue("720000/10000")); assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/ResolutionUnit"), hasValue("2")); assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/NativeDigest"), hasValue("256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;C08D8E93274C4BEE83E86CF999955A87")); }
@Test public void testRDFSeq() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-seq-example.xml")); assertEquals(1, directory.size()); assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(Arrays.asList("XMP", "metadata", "ISO standard"))); }
@Test public void testRDFBag() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-bag-example.xml")); assertEquals(1, directory.size()); assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(Arrays.asList("XMP", "metadata", "ISO standard"))); // Order does not matter }
@Test public void testRDFAttributeSyntax() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml"));
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentDC() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // dc|http://purl.org/dc/elements/1.1/ Directory dc = getDirectoryByNS(compound, XMP.NS_DC); assertEquals(1, dc.size()); assertThat(dc.getEntryById("http://purl.org/dc/elements/1.1/format"), hasValue("image/jpeg")); }
@Test public void testRDFAttributeSyntaxCompound() throws IOException { // Alternate RDF syntax, using attribute values instead of nested tags Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; assertEquals(6, compound.directoryCount()); int size = 0; for (int i = 0; i < compound.directoryCount(); i++) { Directory sub = compound.getDirectory(i); assertNotNull(sub); size += sub.size(); } assertEquals(directory.size(), size); }
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentPhotoshop() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // photoshop|http://ns.adobe.com/photoshop/1.0/ Directory photoshop = getDirectoryByNS(compound, XMP.NS_PHOTOSHOP); assertEquals(3, photoshop.size()); assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/ColorMode"), hasValue("1")); assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/ICCProfile"), hasValue("Dot Gain 20%")); assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/History"), hasValue("")); }
@Test public void testRDFAlt() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-alt-example.xml")); assertEquals(1, directory.size()); assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(new HashMap<String, String>() {{ put("x-default", "One"); put("en-us", "One"); put("de", "Ein"); put("no-nb", "En"); }})); }
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentXAP() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // xap|http://ns.adobe.com/xap/1.0/ Directory xap = getDirectoryByNS(compound, XMP.NS_XAP); assertEquals(4, xap.size()); assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/ModifyDate"), hasValue("2008-07-16T14:44:49-07:00")); assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/CreatorTool"), hasValue("Adobe Photoshop CS3 Windows")); assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/CreateDate"), hasValue("2008-07-16T14:44:49-07:00")); assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/MetadataDate"), hasValue("2008-07-16T14:44:49-07:00")); }
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentEXIF() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // exif|http://ns.adobe.com/exif/1.0/ Directory exif = getDirectoryByNS(compound, XMP.NS_EXIF); assertEquals(4, exif.size()); assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/ColorSpace"), hasValue("-1")); // SIC. Same as unsigned short 65535, meaning "uncalibrated"? assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/PixelXDimension"), hasValue("426")); assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/PixelYDimension"), hasValue("550")); assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/NativeDigest"), hasValue("36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;A7F21D25E2C562F152B2C4ECC9E534DA")); } }
@Test public void testRDFAttributeSyntaxCompoundDirectoryContentTIFF() throws IOException { Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml")); assertThat(directory, instanceOf(CompoundDirectory.class)); CompoundDirectory compound = (CompoundDirectory) directory; // tiff|http://ns.adobe.com/tiff/1.0/ Directory tiff = getDirectoryByNS(compound, XMP.NS_TIFF); assertEquals(5, tiff.size()); assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/Orientation"), hasValue("1")); assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/XResolution"), hasValue("720000/10000")); assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/YResolution"), hasValue("720000/10000")); assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/ResolutionUnit"), hasValue("2")); assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/NativeDigest"), hasValue("256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;C08D8E93274C4BEE83E86CF999955A87")); }