Search in sources :

Example 1 with DeflateCompressor

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

the class TestStreamingCompression method testDeflateCompressor.

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

Example 2 with DeflateCompressor

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

the class TestStreamingCompression method testDeflateCompressor.

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

Aggregations

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