CriticalMeasure { public CriticalMeasure(CriticalComponent component, int id) { this.id = id; this.component = component; long time = System.nanoTime(); TIME_LEFT_UPDATER.set(this, time); TIME_ENTER_UPDATER.set(this, time); } CriticalMeasure(CriticalComponent component, int id); void enterCritical(); void leaveCritical(); boolean checkExpiration(long timeout, boolean reset); long enterTime(); long leaveTime();  }
@Test public void testCriticalMeasure() throws Exception { CriticalMeasure measure = new CriticalMeasure(null, 1); long time = System.nanoTime(); CriticalMeasure.TIME_ENTER_UPDATER.set(measure, time - TimeUnit.MINUTES.toNanos(5)); CriticalMeasure.TIME_LEFT_UPDATER.set(measure, time); Assert.assertFalse(measure.checkExpiration(TimeUnit.SECONDS.toNanos(30), false)); }