@Test @UseDataProvider("provideInvalidThrottleInputStream") public void invalidInputStream(final InputStream in, final long bytesPerSecond, final Class<Exception> expectedException) { this.thrown.expect(expectedException); Streams.throttle(in, bytesPerSecond); }
private void throttle(final int bytes) { if (bytes == 1) { this.rateLimiter.acquire(); } else if (bytes > 1) { this.rateLimiter.acquire(bytes - 1); this.rateLimiter.acquire(); } }
ThrottledInputStream extends FilterInputStream { private void throttle(final int bytes) { if (bytes == 1) { this.rateLimiter.acquire(); } else if (bytes > 1) { this.rateLimiter.acquire(bytes - 1); this.rateLimiter.acquire(); } } }
ThrottledInputStream extends FilterInputStream { private void throttle(final int bytes) { if (bytes == 1) { this.rateLimiter.acquire(); } else if (bytes > 1) { this.rateLimiter.acquire(bytes - 1); this.rateLimiter.acquire(); } } ThrottledInputStream(final InputStream in, final long bytesPerSecond); }
ThrottledInputStream extends FilterInputStream { private void throttle(final int bytes) { if (bytes == 1) { this.rateLimiter.acquire(); } else if (bytes > 1) { this.rateLimiter.acquire(bytes - 1); this.rateLimiter.acquire(); } } ThrottledInputStream(final InputStream in, final long bytesPerSecond); @Override int read(); @Override int read(final byte[] b); @Override int read(final byte[] b, final int off, final int len); @Override String toString(); }
ThrottledInputStream extends FilterInputStream { private void throttle(final int bytes) { if (bytes == 1) { this.rateLimiter.acquire(); } else if (bytes > 1) { this.rateLimiter.acquire(bytes - 1); this.rateLimiter.acquire(); } } ThrottledInputStream(final InputStream in, final long bytesPerSecond); @Override int read(); @Override int read(final byte[] b); @Override int read(final byte[] b, final int off, final int len); @Override String toString();  }