use of org.apache.nifi.remote.io.CompressionInputStream in project nifi by apache.
the class TestCompressionInputOutputStreams method testSimple.
@Test
public void testSimple() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final byte[] data = "Hello, World!".getBytes("UTF-8");
final CompressionOutputStream cos = new CompressionOutputStream(baos);
cos.write(data);
cos.flush();
cos.close();
final byte[] compressedBytes = baos.toByteArray();
final CompressionInputStream cis = new CompressionInputStream(new ByteArrayInputStream(compressedBytes));
final byte[] decompressed = readFully(cis);
assertTrue(Arrays.equals(data, decompressed));
}
use of org.apache.nifi.remote.io.CompressionInputStream in project nifi by apache.
the class TestCompressionInputOutputStreams method testDataLargerThanBuffer.
@Test
public void testDataLargerThanBuffer() throws IOException {
final String str = "The quick brown fox jumps over the lazy dog\r\n\n\n\r";
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < 100; i++) {
sb.append(str);
}
final byte[] data = sb.toString().getBytes("UTF-8");
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final CompressionOutputStream cos = new CompressionOutputStream(baos, 8192);
cos.write(data);
cos.flush();
cos.close();
final byte[] compressedBytes = baos.toByteArray();
final CompressionInputStream cis = new CompressionInputStream(new ByteArrayInputStream(compressedBytes));
final byte[] decompressed = readFully(cis);
assertTrue(Arrays.equals(data, decompressed));
}
Aggregations