DecompressorStream extends CompressionInputStream { @Override public int read() throws IOException { checkStream(); return (read(oneByte, 0, oneByte.length) == -1) ? -1 : (oneByte[0] & 0xff); } @VisibleForTesting  DecompressorStream(InputStream in, Decompressor decompressor,
                            int bufferSize, int skipBufferSize);  DecompressorStream(InputStream in, Decompressor decompressor,
                            int bufferSize);  DecompressorStream(InputStream in, Decompressor decompressor); protected  DecompressorStream(InputStream in); @Override int read(); @Override int read(byte[] b, int off, int len); @Override void resetState(); @Override long skip(long n); @Override int available(); @Override void close(); @Override boolean markSupported(); @Override synchronized void mark(int readlimit); @Override synchronized void reset();  }
@Test public void testReadOneByte() throws IOException { for (int i = 0; i < TEST_STRING.length(); ++i) { assertThat(decompressorStream.read(), is((int) TEST_STRING.charAt(i))); } try { int ret = decompressorStream.read(); fail("Not reachable but got ret " + ret); } catch (EOFException e) { } }
@Test public void testReadBuffer() throws IOException { byte[] buf = new byte[32]; int bytesToRead = TEST_STRING.length(); int i = 0; while (bytesToRead > 0) { int n = Math.min(bytesToRead, buf.length); int bytesRead = decompressorStream.read(buf, 0, n); assertTrue(bytesRead > 0 && bytesRead <= n); assertThat(new String(buf, 0, bytesRead), is(TEST_STRING.substring(i, i + bytesRead))); bytesToRead = bytesToRead - bytesRead; i = i + bytesRead; } try { int ret = decompressorStream.read(buf, 0, buf.length); fail("Not reachable but got ret " + ret); } catch (EOFException e) { } }