|
28 | 28 | import java.io.ByteArrayOutputStream; |
29 | 29 | import java.io.IOException; |
30 | 30 | import java.io.InputStream; |
| 31 | +import java.nio.ByteBuffer; |
| 32 | +import java.security.MessageDigest; |
| 33 | +import java.security.NoSuchAlgorithmException; |
31 | 34 | import java.util.List; |
| 35 | +import javax.xml.transform.TransformerException; |
32 | 36 |
|
33 | 37 | import org.apache.xmpbox.DateConverter; |
34 | 38 | import org.apache.xmpbox.XMPMetadata; |
@@ -98,12 +102,11 @@ void testGetTitle() throws XmpParsingException, BadFieldValueException |
98 | 102 | } |
99 | 103 |
|
100 | 104 | @Test |
101 | | - void testAltBagSeq() throws XmpParsingException |
| 105 | + void testAltBagSeq() throws XmpParsingException, TransformerException, NoSuchAlgorithmException |
102 | 106 | { |
103 | 107 | InputStream fis = DomXmpParser.class.getResourceAsStream("/org/apache/xmpbox/parser/AltBagSeqTest.xml"); |
104 | | - xdb.parse(fis); |
105 | | - // XMPMetadata metadata=xdb.parse(fis); |
106 | | - // SaveMetadataHelper.serialize(metadata, true, System.out); |
| 108 | + XMPMetadata metadata=xdb.parse(fis); |
| 109 | + checkTransform(metadata, "AA3B148E4F802DE4"); |
107 | 110 | } |
108 | 111 |
|
109 | 112 | @Test |
@@ -322,4 +325,14 @@ void testSpaceTextValues() throws XmpParsingException |
322 | 325 | // check creator tool |
323 | 326 | assertEquals("Canon ",meta.getXMPBasicSchema().getCreatorTool()); |
324 | 327 | } |
| 328 | + |
| 329 | + private void checkTransform(XMPMetadata metadata, String expected) |
| 330 | + throws TransformerException, NoSuchAlgorithmException |
| 331 | + { |
| 332 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| 333 | + serializer.serialize(metadata, baos, true); |
| 334 | + byte[] digest = MessageDigest.getInstance("SHA-256").digest(baos.toByteArray()); |
| 335 | + String result = String.format("%X", ByteBuffer.wrap(digest).getLong()); |
| 336 | + assertEquals(expected, result); |
| 337 | + } |
325 | 338 | } |
0 commit comments