RateControl { public boolean isEnabled() { return _enabled; } RateControl(long numEventsPerSec, long throttleDurationInSecs); long incrementEventCount(); boolean isEnabled(); long getNumSleeps(); void resetNumSleeps(); static final String MODULE; static final Logger LOG; }
@Test public void testInvalidRate() throws Exception { RateControl rc = new RateControl(Long.MIN_VALUE, 2L); Assert.assertEquals(rc.isEnabled(), false); RateControl rc1 = new RateControl(0, 2L); Assert.assertEquals(rc1.isEnabled(), false); RateControl rc2 = new RateControl(1, 2L); Assert.assertEquals(rc2.isEnabled(), true); RateControl rc3 = new RateControl(Long.MAX_VALUE, 2L); Assert.assertEquals(rc3.isEnabled(), true); RateControl rc4 = new RateControl(2L, Long.MIN_VALUE); Assert.assertEquals(rc4.isEnabled(), false); RateControl rc5 = new RateControl(2L, 0); Assert.assertEquals(rc5.isEnabled(), false); RateControl rc6 = new RateControl(2L, 1L); Assert.assertEquals(rc6.isEnabled(), true); RateControl rc7 = new RateControl(2L, Long.MAX_VALUE); Assert.assertEquals(rc7.isEnabled(), true); }