1920212223242526272829
int time = 0; boolean result; for (int i = 0; i < 10; i++) { time += 10; result = limit.check(time); Assert.assertTrue(result); } result = limit.check(time + 10); Assert.assertFalse(result);
2223242526272829303132
for (int i = 0; i < 10; i++) { time += 10; result = limit.check(time); Assert.assertTrue(result); } result = limit.check(time + 10); Assert.assertFalse(result); result = limit.check(time + 1000); Assert.assertTrue(result); }
2526272829303132333435
Assert.assertTrue(result); } result = limit.check(time + 10); Assert.assertFalse(result); result = limit.check(time + 1000); Assert.assertTrue(result); } @Test public void testRateLimiter2() {
4243444546474849505152
int time = 0; int interval = 100; for (int i = 0; i < 10; i++) { time += interval; boolean result = limit.check(time); Assert.assertTrue(result); } boolean result = limit.check(time + interval); Assert.assertTrue(result); }
454647484950515253
for (int i = 0; i < 10; i++) { time += interval; boolean result = limit.check(time); Assert.assertTrue(result); } boolean result = limit.check(time + interval); Assert.assertTrue(result); } }