@Test public void shouldAddUptime() throws Exception { target.event( new EventScheduler() { @Override public void schedule(long delay, TimeUnit timeUnit) { assertEquals(100, timeUnit.toMillis(delay)); schedules++; } }, new EventAdder() { @Override public void add(byte[] event) { assertEquals(32, event.length); adds++; } } ); assertEquals(1, schedules); assertEquals(1, adds); }
@Override public void event(EventScheduler scheduler, EventAdder adder) { try { InputStream inputStream = device2Stream(); try { int size = inputStream.read(bytes); Preconditions.checkState(size == bytes.length); adder.add(bytes); scheduler.schedule(100, TimeUnit.MILLISECONDS); } finally { inputStream.close(); } } catch (IOException e) { throw new IllegalStateException("unexpected error while obtaining entropy: ", e); } }
PlatformEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { try { InputStream inputStream = device2Stream(); try { int size = inputStream.read(bytes); Preconditions.checkState(size == bytes.length); adder.add(bytes); scheduler.schedule(100, TimeUnit.MILLISECONDS); } finally { inputStream.close(); } } catch (IOException e) { throw new IllegalStateException("unexpected error while obtaining entropy: ", e); } } }
PlatformEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { try { InputStream inputStream = device2Stream(); try { int size = inputStream.read(bytes); Preconditions.checkState(size == bytes.length); adder.add(bytes); scheduler.schedule(100, TimeUnit.MILLISECONDS); } finally { inputStream.close(); } } catch (IOException e) { throw new IllegalStateException("unexpected error while obtaining entropy: ", e); } }  }
PlatformEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { try { InputStream inputStream = device2Stream(); try { int size = inputStream.read(bytes); Preconditions.checkState(size == bytes.length); adder.add(bytes); scheduler.schedule(100, TimeUnit.MILLISECONDS); } finally { inputStream.close(); } } catch (IOException e) { throw new IllegalStateException("unexpected error while obtaining entropy: ", e); } }  @Override void event(EventScheduler scheduler, EventAdder adder); }
PlatformEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { try { InputStream inputStream = device2Stream(); try { int size = inputStream.read(bytes); Preconditions.checkState(size == bytes.length); adder.add(bytes); scheduler.schedule(100, TimeUnit.MILLISECONDS); } finally { inputStream.close(); } } catch (IOException e) { throw new IllegalStateException("unexpected error while obtaining entropy: ", e); } }  @Override void event(EventScheduler scheduler, EventAdder adder); static final File URANDOM; }