Search in sources :

Example 1 with GzipCompressor

use of com.linkedin.r2.filter.compression.streaming.GzipCompressor in project rest.li by linkedin.

the class TestStreamingCompression method testGzipCompressor.

@Test
public void testGzipCompressor() throws IOException, InterruptedException, CompressionException, ExecutionException {
    StreamingCompressor compressor = new GzipCompressor(_executor);
    final byte[] origin = new byte[BUF_SIZE];
    Arrays.fill(origin, (byte) 'b');
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    GZIPOutputStream gzip = new GZIPOutputStream(out);
    IOUtils.write(origin, gzip);
    gzip.close();
    byte[] compressed = out.toByteArray();
    testCompress(compressor, origin, compressed);
    testDecompress(compressor, origin, compressed);
    testCompressThenDecompress(compressor, origin);
}
Also used : GzipCompressor(com.linkedin.r2.filter.compression.streaming.GzipCompressor) GZIPOutputStream(java.util.zip.GZIPOutputStream) StreamingCompressor(com.linkedin.r2.filter.compression.streaming.StreamingCompressor) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Example 2 with GzipCompressor

use of com.linkedin.r2.filter.compression.streaming.GzipCompressor in project rest.li by linkedin.

the class TestStreamingCompression method testGzipCompressor.

@Test
public void testGzipCompressor() throws IOException, InterruptedException, CompressionException, ExecutionException {
    StreamingCompressor compressor = new GzipCompressor(_executor);
    final byte[] origin = new byte[BUF_SIZE];
    Arrays.fill(origin, (byte) 'b');
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    GZIPOutputStream gzip = new GZIPOutputStream(out);
    IOUtils.write(origin, gzip);
    gzip.close();
    byte[] compressed = out.toByteArray();
    testCompress(compressor, origin, compressed);
    testDecompress(compressor, origin, compressed);
    testCompressThenDecompress(compressor, origin);
}
Also used : GzipCompressor(com.linkedin.r2.filter.compression.streaming.GzipCompressor) GZIPOutputStream(java.util.zip.GZIPOutputStream) StreamingCompressor(com.linkedin.r2.filter.compression.streaming.StreamingCompressor) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Aggregations

GzipCompressor (com.linkedin.r2.filter.compression.streaming.GzipCompressor)2 StreamingCompressor (com.linkedin.r2.filter.compression.streaming.StreamingCompressor)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 GZIPOutputStream (java.util.zip.GZIPOutputStream)2 Test (org.testng.annotations.Test)2