|
33 | 33 | import java.security.MessageDigest; |
34 | 34 | import java.security.NoSuchAlgorithmException; |
35 | 35 | import java.util.List; |
| 36 | +import java.util.TimeZone; |
36 | 37 | import javax.xml.transform.TransformerException; |
37 | 38 |
|
38 | 39 | import org.apache.xmpbox.DateConverter; |
|
46 | 47 | import org.apache.xmpbox.xml.DomXmpParser; |
47 | 48 | import org.apache.xmpbox.xml.XmpParsingException; |
48 | 49 | import org.apache.xmpbox.xml.XmpParsingException.ErrorType; |
| 50 | +import org.junit.jupiter.api.AfterAll; |
| 51 | +import org.junit.jupiter.api.BeforeAll; |
49 | 52 | import org.junit.jupiter.api.BeforeEach; |
50 | 53 | import org.junit.jupiter.api.Test; |
51 | 54 | import org.apache.xmpbox.xml.XmpSerializer; |
52 | 55 |
|
53 | 56 | class DeserializationTest |
54 | 57 | { |
55 | 58 |
|
56 | | - protected ByteArrayOutputStream bos; |
| 59 | + private ByteArrayOutputStream baos; |
57 | 60 |
|
58 | | - protected XmpSerializer serializer; |
| 61 | + private XmpSerializer serializer; |
59 | 62 |
|
60 | 63 | private DomXmpParser xdb; |
61 | 64 |
|
| 65 | + private static TimeZone defaultTZ; |
| 66 | + |
| 67 | + @BeforeAll |
| 68 | + static void initAll() |
| 69 | + { |
| 70 | + defaultTZ = TimeZone.getDefault(); |
| 71 | + // Need to set a timezone or date values will be different depending on test location |
| 72 | + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); |
| 73 | + } |
| 74 | + |
62 | 75 | @BeforeEach |
63 | 76 | void init() throws XmpParsingException |
64 | 77 | { |
65 | | - bos = new ByteArrayOutputStream(); |
| 78 | + baos = new ByteArrayOutputStream(); |
66 | 79 | serializer = new XmpSerializer(); |
67 | 80 | xdb = new DomXmpParser(); |
68 | 81 | } |
69 | 82 |
|
| 83 | + @AfterAll |
| 84 | + static void finishAll() |
| 85 | + { |
| 86 | + TimeZone.setDefault(defaultTZ); |
| 87 | + } |
| 88 | + |
70 | 89 | @Test |
71 | 90 | void testStructuredRecursive() throws XmpParsingException |
72 | 91 | { |
@@ -107,7 +126,7 @@ void testAltBagSeq() throws XmpParsingException, TransformerException, NoSuchAlg |
107 | 126 | { |
108 | 127 | InputStream fis = DomXmpParser.class.getResourceAsStream("/org/apache/xmpbox/parser/AltBagSeqTest.xml"); |
109 | 128 | XMPMetadata metadata=xdb.parse(fis); |
110 | | - checkTransform(metadata, "96393121650279079517435472505216876362174786845882116375023427217573081361024"); |
| 129 | + checkTransform(metadata, "16805992283807186369849610414335227396239089071611806706387795179375897398118"); |
111 | 130 | } |
112 | 131 |
|
113 | 132 | @Test |
@@ -330,7 +349,6 @@ void testSpaceTextValues() throws XmpParsingException |
330 | 349 | private void checkTransform(XMPMetadata metadata, String expected) |
331 | 350 | throws TransformerException, NoSuchAlgorithmException, IOException |
332 | 351 | { |
333 | | - ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
334 | 352 | serializer.serialize(metadata, baos, true); |
335 | 353 | String replaced = baos.toString(StandardCharsets.UTF_8).replace("\r\n", "\n"); |
336 | 354 | byte[] ba = replaced.getBytes(StandardCharsets.UTF_8); |
|
0 commit comments