You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2017/01/23 07:48:38 UTC
[3/3] commons-compress git commit: COMPRESS-271 test for single-byte
read and premature close
COMPRESS-271 test for single-byte read and premature close
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/226489c0
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/226489c0
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/226489c0
Branch: refs/heads/master
Commit: 226489c0f04d427f7a75468d12b7ccbdcf4c7ccf
Parents: 3f839db
Author: Stefan Bodewig <bo...@apache.org>
Authored: Mon Jan 23 08:48:10 2017 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Mon Jan 23 08:48:10 2017 +0100
----------------------------------------------------------------------
.../lz4/FramedLZ4CompressorInputStreamTest.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/226489c0/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java
index 7d774d9..3727518 100644
--- a/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java
@@ -185,6 +185,23 @@ public final class FramedLZ4CompressorInputStreamTest
}
@Test
+ public void readsUncompressedBlocksUsingSingleByteRead() throws IOException {
+ byte[] input = new byte[] {
+ 4, 0x22, 0x4d, 0x18, // signature
+ 0x60, // flag - Version 01, block independent, no block checksum, no content size, no content checksum
+ 0x70, // block size 4MB
+ 0x00, // checksum, revisit once it gets validated
+ 13, 0, 0, (byte) 0x80, // 13 bytes length and uncompressed bit set
+ 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!', // content
+ 0, 0, 0, 0, // empty block marker
+ };
+ try (InputStream a = new FramedLZ4CompressorInputStream(new ByteArrayInputStream(input))) {
+ int h = a.read();
+ assertEquals('H', h);
+ }
+ }
+
+ @Test
public void rejectsBlocksWithoutChecksum() throws IOException {
byte[] input = new byte[] {
4, 0x22, 0x4d, 0x18, // signature