@Test public void testAvailable() { final int len = 100; try (FakeInputStream fakeInputStream = new FakeInputStream(len, true)) { assertEquals(len, fakeInputStream.available()); fakeInputStream.read(); assertEquals(len - 1, fakeInputStream.available()); assertEquals(1, fakeInputStream.readCount()); } try (FakeInputStream fakeInputStream = new FakeInputStream(len, false)) { assertEquals(len, fakeInputStream.available()); fakeInputStream.read(); assertEquals(len - 1, fakeInputStream.available()); assertEquals(1, fakeInputStream.readCount()); } }
@Override public int available() { if (limit > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) limit; }
FakeInputStream extends InputStream { @Override public int available() { if (limit > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) limit; } }
FakeInputStream extends InputStream { @Override public int available() { if (limit > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) limit; } FakeInputStream(long limit);  FakeInputStream(long limit, boolean block);  FakeInputStream(long limit, boolean block, boolean useRandom); }
FakeInputStream extends InputStream { @Override public int available() { if (limit > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) limit; } FakeInputStream(long limit);  FakeInputStream(long limit, boolean block);  FakeInputStream(long limit, boolean block, boolean useRandom); @Override int read(); @Override int available(); @Override void close(); @Override int read(byte[] b, int off, int len); @Override int read(byte[] b); long readCount(); }
FakeInputStream extends InputStream { @Override public int available() { if (limit > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) limit; } FakeInputStream(long limit);  FakeInputStream(long limit, boolean block);  FakeInputStream(long limit, boolean block, boolean useRandom); @Override int read(); @Override int available(); @Override void close(); @Override int read(byte[] b, int off, int len); @Override int read(byte[] b); long readCount();  }