@Test
public void testSleepToMaintainRate() throws Exception
{

  RateControl rc = new RateControl(2,1);
  long duration = 10000;
  long msecToSleep = rc.sleepToMaintainRate(duration);
  Assert.assertEquals(msecToSleep, 1L);
  duration = 100000;
  msecToSleep = rc.sleepToMaintainRate(duration);
  Assert.assertEquals(msecToSleep, 1L);
  duration = 1000000;
  msecToSleep = rc.sleepToMaintainRate(duration);
  Assert.assertEquals(msecToSleep, 1L);
  duration = 100000000;
  msecToSleep = rc.sleepToMaintainRate(duration);
  Assert.assertEquals(msecToSleep, 100L);
  duration = 1000000000;
  msecToSleep = rc.sleepToMaintainRate(duration);
  Assert.assertEquals(msecToSleep, 1000L);
}