@Test
public void testCheckExpired() throws Exception
{

  RateControl rc1 = new RateControl(10,-1);
  Assert.assertEquals(false, rc1.checkExpired());
  Assert.assertEquals(false, rc1.isEnabled());
  RateControl rc2 = new RateControl(10,1);
  Assert.assertEquals(true, rc2.isEnabled());
  boolean expired = true;
  Field field = rc2.getClass().getDeclaredField("_expired");
  field.setAccessible(true);
  field.set(rc2, expired);
  Assert.assertEquals(expired, rc2.checkExpired());
  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 field2 = rc.getClass().getDeclaredField("_ra");
  field2.setAccessible(true);
  field2.set(rc, mrm);
    
  curTime = (1L * DbusConstants.NUM_NSECS_IN_SEC) - 10;
  mrm.setNanoTime(curTime);
  Assert.assertEquals(rc.checkExpired(), false);
  curTime = (1L * DbusConstants.NUM_NSECS_IN_SEC);
  mrm.setNanoTime(curTime);
  Assert.assertEquals(rc.checkExpired(), true);
  curTime = (1L * DbusConstants.NUM_NSECS_IN_SEC) + 10;
  mrm.setNanoTime(curTime);
  Assert.assertEquals(rc.checkExpired(), true);
}