@Test
public void testComputeSleepDuration() throws Exception
{

  RateControl rc = new RateControl(10,1);
  Assert.assertEquals(true, rc.isEnabled());
  long curTime = 0L;
  MockRateMonitor mrm = new MockRateMonitor("mock");
  mrm.setNanoTime(curTime);
  mrm.start();
  Field field = rc.getClass().getDeclaredField("_ra");
  field.setAccessible(true);
  field.set(rc, mrm);
  
  curTime = (1L * DbusConstants.NUM_NSECS_IN_SEC) - 10 ;
  mrm.ticks(10L);
  mrm.setNanoTime(curTime);
  Assert.assertEquals(10, rc.computeSleepDuration());
  curTime = (1L * DbusConstants.NUM_NSECS_IN_SEC) ;
  mrm.setNanoTime(curTime);
  Assert.assertEquals(0, rc.computeSleepDuration());
  curTime = (1L * DbusConstants.NUM_NSECS_IN_SEC) + 10 ;
  mrm.setNanoTime(curTime);
  Assert.assertEquals(0, rc.computeSleepDuration());
  return;
}