@Test public void shouldUseTimeBetweenCallsToCreateEvents() throws Exception { target.event( new EventScheduler() { @Override public void schedule(long delay, TimeUnit timeUnit) { assertEquals(10, timeUnit.toMillis(delay)); schedules++; } }, new EventAdder() { @Override public void add(byte[] event) { assertEquals(2, event.length); adds++; } } ); assertEquals(1, schedules); assertEquals(1, adds); }
@Override public void event(EventScheduler scheduler, EventAdder adder) { long now = System.nanoTime(); long elapsed = now - lastTime; lastTime = now; adder.add(Util.twoLeastSignificantBytes(elapsed)); scheduler.schedule(10, TimeUnit.MILLISECONDS); }
SchedulingEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { long now = System.nanoTime(); long elapsed = now - lastTime; lastTime = now; adder.add(Util.twoLeastSignificantBytes(elapsed)); scheduler.schedule(10, TimeUnit.MILLISECONDS); } }
SchedulingEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { long now = System.nanoTime(); long elapsed = now - lastTime; lastTime = now; adder.add(Util.twoLeastSignificantBytes(elapsed)); scheduler.schedule(10, TimeUnit.MILLISECONDS); }  }
SchedulingEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { long now = System.nanoTime(); long elapsed = now - lastTime; lastTime = now; adder.add(Util.twoLeastSignificantBytes(elapsed)); scheduler.schedule(10, TimeUnit.MILLISECONDS); }  @Override void event(EventScheduler scheduler, EventAdder adder); }
SchedulingEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { long now = System.nanoTime(); long elapsed = now - lastTime; lastTime = now; adder.add(Util.twoLeastSignificantBytes(elapsed)); scheduler.schedule(10, TimeUnit.MILLISECONDS); }  @Override void event(EventScheduler scheduler, EventAdder adder);  }