@Test
public void shouldDecompressBZip2Stream() throws IOException {

  BZip2Decompressor<String> decompressor =
      new BZip2Decompressor<>(
          inputStream -> {
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            String output = reader.readLine();
            reader.close();
            return output;
          });
  String originalString = "abc";
  ByteArrayOutputStream compressedStream = new ByteArrayOutputStream();
  try (BZip2CompressorOutputStream bzip2Output =
      new BZip2CompressorOutputStream(compressedStream)) {
    bzip2Output.write(originalString.getBytes());
  }
  String decompressedString = decompressor.decompress(compressedStream.toByteArray());
  assertEquals(originalString, decompressedString);
}