27import java.time.Instant;
28import java.time.ZoneOffset;
29import java.time.temporal.ChronoUnit;
31import org.jau.io.PrintUtil;
32import org.jau.sys.Clock;
33import org.junit.Assert;
34import org.junit.FixMethodOrder;
36import org.junit.runners.MethodSorters;
38import jau.pkg.PlatformRuntime;
39import jau.test.junit.util.JunitTracer;
41@FixMethodOrder(MethodSorters.NAME_ASCENDING)
46 PlatformRuntime.checkInitialized();
47 PrintUtil.fprintf_td(System.err,
"test00\n");
49 final Instant m_t0 = Instant.ofEpochMilli(Clock.currentTimeMillis());
50 final Instant m_t1 = Clock.getMonotonicTime();
51 final Instant w_t2 = Instant.ofEpochSecond(Clock.wallClockSeconds());
52 final Instant w_t3 = Clock.getWallClockTime();
56 }
catch (
final InterruptedException e) { }
58 final Instant m_t0_b = Instant.ofEpochMilli(Clock.currentTimeMillis());
59 final Instant m_t1_b = Clock.getMonotonicTime();
60 final Instant w_t2_b = Instant.ofEpochSecond(Clock.wallClockSeconds());
61 final Instant w_t3_b = Clock.getWallClockTime();
63 final long m_t0_d = m_t0.until(m_t0_b, ChronoUnit.MILLIS);
64 final long m_t1_d = m_t1.until(m_t1_b, ChronoUnit.MILLIS);
65 final long w_t2_d = w_t2.until(w_t2_b, ChronoUnit.MILLIS);
66 final long w_t3_d = w_t3.until(w_t3_b, ChronoUnit.MILLIS);
68 PrintUtil.fprintf_td(System.err,
"mono t0 %s, %d ms\n", m_t0.atZone(ZoneOffset.UTC), m_t0_d);
69 PrintUtil.fprintf_td(System.err,
"mono t1 %s, %d ms\n", m_t1.atZone(ZoneOffset.UTC), m_t1_d);
70 PrintUtil.fprintf_td(System.err,
"wall t2 %s, %d ms\n", w_t2.atZone(ZoneOffset.UTC), w_t2_d);
71 PrintUtil.fprintf_td(System.err,
"wall t3 %s, %d ms\n", w_t3.atZone(ZoneOffset.UTC), w_t3_d);
73 final long td_min = 50;
74 final long td_max = 150;
75 Assert.assertTrue( td_min <= m_t0_d );
76 Assert.assertTrue( td_max >= m_t0_d );
78 Assert.assertTrue( td_min <= m_t1_d );
79 Assert.assertTrue( td_max >= m_t1_d );
81 Assert.assertTrue( 0 <= w_t2_d );
82 Assert.assertTrue( 1000 >= w_t2_d );
84 Assert.assertTrue( td_min <= w_t3_d );
85 Assert.assertTrue( td_max >= w_t3_d );
88 public static void main(
final String args[]) {
90 org.junit.runner.JUnitCore.
main(tstname);
static void main(final String args[])