Browse souce code repository at: https://github.com/jjYBdx4IL/java-evaluation/blob/master/src/test/java/com/google/common/util/concurrent/RateLimiterTest.java
package com.google.common.util.concurrent;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class RateLimiterTest {

    RateLimiter rl = RateLimiter.create(1.0);
    
    @Test
    public void test() {
        assertTrue(nextDelayMs() < 500);
        assertTrue(nextDelayMs() > 500);
    }
    
    public long nextDelayMs() {
        long start = System.currentTimeMillis();
        rl.acquire();
        return System.currentTimeMillis() - start;
    }
}
-------------------------------------------------------------------------------
Test set: com.google.common.util.concurrent.RateLimiterTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.994 s - in com.google.common.util.concurrent.RateLimiterTest
test  Time elapsed: 0.994 s