MCPcopy Create free account
hub / github.com/amazon-ion/ion-java / TimestampGoodTest

Class TimestampGoodTest

src/test/java/com/amazon/ion/TimestampGoodTest.java:32–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31
32public class TimestampGoodTest
33 extends IonTestCase
34{
35 @Inject("testFile")
36 public static final File[] FILES =
37 testdataFiles(GLOBAL_SKIP_LIST,
38 false, /* recurse */
39 GOOD_TIMESTAMP_IONTESTS_FILES);
40
41 private File myTestFile;
42
43 public void setTestFile(File file)
44 {
45 myTestFile = file;
46 }
47
48
49 @Test
50 public void testRoundTripFromDom()
51 throws IOException
52 {
53 IonDatagram dg = load(myTestFile);
54 Iterator<IonValue> iterator = dg.iterator();
55 while (iterator.hasNext())
56 {
57 IonTimestamp its = (IonTimestamp) iterator.next();
58 String tsText = its.toString();
59 Timestamp ts = Timestamp.valueOf(tsText);
60 assertEquals("timestamp", its.timestampValue(), ts);
61 }
62 }
63
64
65 @Test
66 public void testValueOf()
67 throws IOException
68 {
69 if (! myTestFile.getName().endsWith(".ion")) return;
70
71 String fileText = _Private_Utils.utf8FileToString(myTestFile);
72 BufferedReader reader = new BufferedReader(new StringReader(fileText));
73
74 String line = reader.readLine();
75 while (line != null)
76 {
77 line = line.trim();
78 if (line.length() != 0 && ! line.startsWith("//"))
79 {
80 // The line must be a valid timestamp
81 Timestamp ts = Timestamp.valueOf(line);
82
83 IonTimestamp tsDom = (IonTimestamp) system().singleValue(line);
84 assertEquals("timestamp", ts, tsDom.timestampValue());
85 }
86
87 line = reader.readLine();
88 }
89 }

Callers

nothing calls this directly

Calls 1

testdataFilesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…