private void advanceClock(ManualClock clock) { long t = clock.wallTime(); clock.setWallTime(t + 10 * 60000 + 1); }
@Test public void measureTimestamp() { long start = clock.wallTime(); clock.setWallTime(start + step); Assertions.assertEquals(start + step, gauge.measure().iterator().next().timestamp()); clock.setWallTime(start + step * 2); Assertions.assertEquals(start + step * 2, gauge.measure().iterator().next().timestamp()); } }
@Test public void expiration() { long start = clock.wallTime(); clock.setWallTime(start + step * 2); Assertions.assertTrue(dist.hasExpired()); dist.record(42); Assertions.assertFalse(dist.hasExpired()); clock.setWallTime(start + step * 3 + 1); Assertions.assertTrue(dist.hasExpired()); } }
@Test public void expiration() { long start = clock.wallTime(); clock.setWallTime(start + step * 2); Assertions.assertTrue(dist.hasExpired()); dist.record(42, TimeUnit.MICROSECONDS); Assertions.assertFalse(dist.hasExpired()); clock.setWallTime(start + step * 3 + 1); Assertions.assertTrue(dist.hasExpired()); } }
@Test public void expiration() { long start = clock.wallTime(); clock.setWallTime(start + step * 2); Assertions.assertTrue(gauge.hasExpired()); gauge.set(1); Assertions.assertFalse(gauge.hasExpired()); clock.setWallTime(start + step * 3 + 1); Assertions.assertTrue(gauge.hasExpired()); gauge.set(1); Assertions.assertFalse(gauge.hasExpired()); }
@Test public void expiration() { long start = clock.wallTime(); clock.setWallTime(start + step * 2); Assertions.assertTrue(counter.hasExpired()); counter.increment(); Assertions.assertFalse(counter.hasExpired()); clock.setWallTime(start + step * 3 + 1); Assertions.assertTrue(counter.hasExpired()); counter.increment(42L); Assertions.assertFalse(counter.hasExpired()); } }
@Test public void expiration() { long start = clock.wallTime(); clock.setWallTime(start + step * 2); Assertions.assertTrue(gauge.hasExpired()); gauge.set(1); Assertions.assertFalse(gauge.hasExpired()); clock.setWallTime(start + step * 3 + 1); Assertions.assertTrue(gauge.hasExpired()); gauge.set(1); Assertions.assertFalse(gauge.hasExpired()); } }