GzipCodec extends DefaultCodec { @Override public CompressionOutputStream createOutputStream(OutputStream out) throws IOException { if (!ZlibFactory.isNativeZlibLoaded(conf)) { return new GzipOutputStream(out); } return CompressionCodec.Util. createOutputStreamWithCodecPool(this, conf, out); }  @Override CompressionOutputStream createOutputStream(OutputStream out); @Override CompressionOutputStream createOutputStream(OutputStream out, 
                                                    Compressor compressor); @Override Compressor createCompressor(); @Override Class<? extends Compressor> getCompressorType(); @Override CompressionInputStream createInputStream(InputStream in); @Override CompressionInputStream createInputStream(InputStream in,
                                                  Decompressor decompressor); @Override Decompressor createDecompressor(); @Override Class<? extends Decompressor> getDecompressorType(); @Override DirectDecompressor createDirectDecompressor(); @Override String getDefaultExtension();  }
@Test public void testSingleCompress() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); CompressionOutputStream cmpOut = codec.createOutputStream(baos); cmpOut.write(DATA1.getBytes(StandardCharsets.UTF_8)); cmpOut.finish(); cmpOut.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); GZIPInputStream cmpIn = new GZIPInputStream(bais); byte[] buf = new byte[1024]; int len = cmpIn.read(buf); String result = new String(buf, 0, len, StandardCharsets.UTF_8); assertEquals("Input must match output", DATA1, result); }