UnsyncFilterInputStream extends InputStream { @Override public int available() throws IOException { return inputStream.available(); } UnsyncFilterInputStream(InputStream inputStream); @Override int available(); @Override void close(); @Override void mark(int readLimit); @Override boolean markSupported(); @Override int read(); @Override int read(byte[] bytes); @Override int read(byte[] bytes, int offset, int length); @Override void reset(); @Override long skip(long skip);  }
@Test public void testAvailable() throws IOException { AtomicBoolean availableCalled = new AtomicBoolean(); UnsyncFilterInputStream unsyncFilterInputStream = new UnsyncFilterInputStream( new TestInputStream() { @Override public int available() { availableCalled.set(true); return -1; } }); Assert.assertEquals(-1, unsyncFilterInputStream.available()); Assert.assertTrue(availableCalled.get()); }