UnsyncBufferedInputStream extends UnsyncFilterInputStream { @Override public int available() throws IOException { if (inputStream == null) { throw new IOException("Input stream is null"); } return inputStream.available() + (_firstInvalidIndex - _index); } UnsyncBufferedInputStream(InputStream inputStream);  UnsyncBufferedInputStream(InputStream inputStream, int size); @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 testConstructor() throws IOException { int size = 10; UnsyncBufferedInputStream unsyncBufferedInputStream = new UnsyncBufferedInputStream( new ByteArrayInputStream(new byte[size])); Assert.assertEquals(size, unsyncBufferedInputStream.available()); unsyncBufferedInputStream = new UnsyncBufferedInputStream( new ByteArrayInputStream(new byte[size]), _SIZE); Assert.assertEquals(size, unsyncBufferedInputStream.available()); try { new UnsyncBufferedInputStream( new ByteArrayInputStream(new byte[size]), 0); Assert.fail(); } catch (IllegalArgumentException illegalArgumentException) { Assert.assertEquals( "Size is less than 1", illegalArgumentException.getMessage()); } try { new UnsyncBufferedInputStream( new ByteArrayInputStream(new byte[size]), -1); Assert.fail(); } catch (IllegalArgumentException illegalArgumentException) { Assert.assertEquals( "Size is less than 1", illegalArgumentException.getMessage()); } }