SntpClient { public static synchronized void ntpTime(final Callback callback, boolean isConnected) { callback.networkConnected = isConnected; if (callback.networkConnected) { new Thread(() -> doNtpTime(callback)).start(); } else { callback.run(); } }  static synchronized void ntpTime(final Callback callback, boolean isConnected); long getRoundTripTime();  }
@Test public void ntpTimeTest() { SntpClient.ntpTime(new SntpClient.Callback() { @Override public void run() { Assert.assertFalse(networkConnected); Assert.assertFalse(success); Assert.assertEquals(0L, time); } }, false); SntpClient.doNtpTime(new SntpClient.Callback() { @Override public void run() { Assert.assertTrue(success); Assert.assertTrue(Math.abs(time - DateUtil.now()) < 60000); } }); }