@Test public void testRead() { int len = 100; try (FakeInputStream fakeInputStream = new FakeInputStream(len, true)) { assertEquals(len, JunitHelper.consumeInputStreamPerByte(fakeInputStream)); } try (FakeInputStream fakeInputStream = new FakeInputStream(len, false)) { assertEquals(len, JunitHelper.consumeInputStreamPerByte(fakeInputStream)); } len = 1000000; try (FakeInputStream fakeInputStream = new FakeInputStream(len, true)) { assertEquals(len, JunitHelper.consumeInputStreamPerByte(fakeInputStream)); } try (FakeInputStream fakeInputStream = new FakeInputStream(len, false)) { assertEquals(len, JunitHelper.consumeInputStreamPerByte(fakeInputStream)); } }
@Override public int read() { if (limit <= 0) { return -1; } limit--; read++; return getValue(); }
FakeInputStream extends InputStream { @Override public int read() { if (limit <= 0) { return -1; } limit--; read++; return getValue(); } }
FakeInputStream extends InputStream { @Override public int read() { if (limit <= 0) { return -1; } limit--; read++; return getValue(); } FakeInputStream(long limit);  FakeInputStream(long limit, boolean block);  FakeInputStream(long limit, boolean block, boolean useRandom); }
FakeInputStream extends InputStream { @Override public int read() { if (limit <= 0) { return -1; } limit--; read++; return getValue(); } 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 read() { if (limit <= 0) { return -1; } limit--; read++; return getValue(); } 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();  }