### Question:
RateLimitCheck { public boolean test() { boolean test = false; long now = System.nanoTime(); synchronized (this) { if (now >= nextSuccess) { test = true; nextSuccess = now + intervalNanos; } } return test; } RateLimitCheck(long time, TimeUnit unit); boolean test();  }### Answer:
@Test public void testLimit() throws Exception { RateLimitCheck check = new RateLimitCheck(100, TimeUnit.MILLISECONDS); assertTrue(check.test()); assertFalse(check.test()); Thread.sleep(200); assertTrue(check.test()); assertFalse(check.test()); }