_executor.shutdown();
}
@Test
public void testSetPeriod() {
final RateLimiter rl = new RateLimiter(0,
MAXPERIOD,
20,
_executor);
_executor.scheduleAtFixedRate(new Runnable() {
private int _period = 300;
@Override
public void run() {
rl.setPeriod(_period);
_period += 50;
}
}, 0, 100, TimeUnit.MILLISECONDS);
RateLimiterRunner runner = new RateLimiterRunner(System.currentTimeMillis());
rl.submit(runner);
try {
Assert.assertTrue(runner.getElapsedTime() <= MAXPERIOD, "Elapsed Time exceed MAX Period");
} catch (Exception e) {
Assert.fail("Unexpected failure", e);