SnappyTest Class — netty Architecture
Architecture documentation for the SnappyTest class in SnappyTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1a449087_fef9_c1b9_33e3_88b8aff8d675["SnappyTest"] bf1509f4_d261_8811_4f6f_30655cd4d9d4["SnappyTest.java"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|defined in| bf1509f4_d261_8811_4f6f_30655cd4d9d4 5ec04737_91c7_954e_7a9d_3468263851c2["resetSnappy()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| 5ec04737_91c7_954e_7a9d_3468263851c2 3cce76a5_5e44_b75c_c13c_16adda23ff58["testDecodeLiteral()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| 3cce76a5_5e44_b75c_c13c_16adda23ff58 c64dffd6_6e9a_3fe9_9e9d_3ee6b6bdc366["testDecodeCopyWith1ByteOffset()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| c64dffd6_6e9a_3fe9_9e9d_3ee6b6bdc366 2df7d882_496d_d522_22c3_9e2882e0575e["testDecodeCopyWithTinyOffset()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| 2df7d882_496d_d522_22c3_9e2882e0575e 2156b37a_98ff_4b8a_1421_e6971f5a2b56["testDecodeCopyWithOffsetBeforeChunk()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| 2156b37a_98ff_4b8a_1421_e6971f5a2b56 99377582_dc85_4444_3b07_96b987e49114["testDecodeWithOverlyLongPreamble()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| 99377582_dc85_4444_3b07_96b987e49114 c490ee33_1dc2_0a79_931f_442d43405bc8["encodeShortTextIsLiteral()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| c490ee33_1dc2_0a79_931f_442d43405bc8 640ea35f_21d9_0736_f78c_94a1829e9b38["encodeAndDecodeLongTextUsesCopy()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| 640ea35f_21d9_0736_f78c_94a1829e9b38 5d465e89_2ca2_d8a9_3cdf_1bb6e39a6c07["testCalculateChecksum()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| 5d465e89_2ca2_d8a9_3cdf_1bb6e39a6c07 110f182b_bc33_ee0a_d09b_8aef6248de95["testMaskChecksum()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| 110f182b_bc33_ee0a_d09b_8aef6248de95 47bb0a2f_bb93_b7ce_4819_7f3edc35b6dc["testValidateChecksumMatches()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| 47bb0a2f_bb93_b7ce_4819_7f3edc35b6dc f0f13b16_5685_de0f_654e_b9c107f539ad["testValidateChecksumFails()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| f0f13b16_5685_de0f_654e_b9c107f539ad ac7399f9_c466_ca76_a8b0_a11039093c26["testEncodeLiteralAndDecodeLiteral()"] 1a449087_fef9_c1b9_33e3_88b8aff8d675 -->|method| ac7399f9_c466_ca76_a8b0_a11039093c26
Relationship Graph
Source Code
codec-compression/src/test/java/io/netty/handler/codec/compression/SnappyTest.java lines 32–360
public class SnappyTest {
private final Snappy snappy = new Snappy();
@AfterEach
public void resetSnappy() {
snappy.reset();
}
@Test
public void testDecodeLiteral() throws Exception {
ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
0x05, // preamble length
0x04 << 2, // literal tag + length
0x6e, 0x65, 0x74, 0x74, 0x79 // "netty"
});
ByteBuf out = Unpooled.buffer(5);
snappy.decode(in, out);
// "netty"
ByteBuf expected = Unpooled.wrappedBuffer(new byte[] {
0x6e, 0x65, 0x74, 0x74, 0x79
});
assertEquals(expected, out, "Literal was not decoded correctly");
in.release();
out.release();
expected.release();
}
@Test
public void testDecodeCopyWith1ByteOffset() throws Exception {
ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
0x0a, // preamble length
0x04 << 2, // literal tag + length
0x6e, 0x65, 0x74, 0x74, 0x79, // "netty"
0x01 << 2 | 0x01, // copy with 1-byte offset + length
0x05 // offset
});
ByteBuf out = Unpooled.buffer(10);
snappy.decode(in, out);
// "nettynetty" - we saved a whole byte :)
ByteBuf expected = Unpooled.wrappedBuffer(new byte[] {
0x6e, 0x65, 0x74, 0x74, 0x79, 0x6e, 0x65, 0x74, 0x74, 0x79
});
assertEquals(expected, out, "Copy was not decoded correctly");
in.release();
out.release();
expected.release();
}
@Test
public void testDecodeCopyWithTinyOffset() {
final ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
0x0b, // preamble length
0x04 << 2, // literal tag + length
0x6e, 0x65, 0x74, 0x74, 0x79, // "netty"
0x05 << 2 | 0x01, // copy with 1-byte offset + length
0x00 // INVALID offset (< 1)
});
final ByteBuf out = Unpooled.buffer(10);
try {
assertThrows(DecompressionException.class, new Executable() {
@Override
public void execute() {
snappy.decode(in, out);
}
});
} finally {
in.release();
out.release();
}
}
@Test
public void testDecodeCopyWithOffsetBeforeChunk() {
final ByteBuf in = Unpooled.wrappedBuffer(new byte[] {
0x0a, // preamble length
0x04 << 2, // literal tag + length
0x6e, 0x65, 0x74, 0x74, 0x79, // "netty"
Source
Frequently Asked Questions
What is the SnappyTest class?
SnappyTest is a class in the netty codebase, defined in codec-compression/src/test/java/io/netty/handler/codec/compression/SnappyTest.java.
Where is SnappyTest defined?
SnappyTest is defined in codec-compression/src/test/java/io/netty/handler/codec/compression/SnappyTest.java at line 32.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free