ByteBufUtilTest Class — netty Architecture
Architecture documentation for the ByteBufUtilTest class in ByteBufUtilTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1b32157c_4c5c_4c3c_706b_1a74a9afdca7["ByteBufUtilTest"] 4c0e19ee_2be2_1e4f_193f_c598de608ee3["ByteBufUtilTest.java"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|defined in| 4c0e19ee_2be2_1e4f_193f_c598de608ee3 81494051_cb4f_f355_d392_780646f02999["ByteBuf()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| 81494051_cb4f_f355_d392_780646f02999 a8d8eddb_dbf6_c90a_a4d8_e1e8ef507ebd["CompositeByteBuf()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| a8d8eddb_dbf6_c90a_a4d8_e1e8ef507ebd 74511f09_be76_6171_82c1_dd486f2503d4["noUnsafe()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| 74511f09_be76_6171_82c1_dd486f2503d4 bf0881bf_db00_b12d_a8d2_196d9d2b2ba5["decodeRandomHexBytesWithEvenLength()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| bf0881bf_db00_b12d_a8d2_196d9d2b2ba5 ec42792f_25fc_0c93_6b44_594bd120bd6c["decodeRandomHexBytesWithOddLength()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| ec42792f_25fc_0c93_6b44_594bd120bd6c 8ff54b77_cabc_1f9d_9c67_92a649bd9c12["decodeRandomHexBytes()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| 8ff54b77_cabc_1f9d_9c67_92a649bd9c12 507bc0a7_24ad_1210_0800_094b5761d2fb["decodeHexDumpWithOddLength()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| 507bc0a7_24ad_1210_0800_094b5761d2fb f4d20ede_12d3_bd68_51d5_7a466f2068fc["decodeHexDumpWithInvalidChar()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| f4d20ede_12d3_bd68_51d5_7a466f2068fc a17f95b5_2261_36b7_1ba7_056cfe20afc0["testIndexOf()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| a17f95b5_2261_36b7_1ba7_056cfe20afc0 089960a6_5ea1_7a61_e2cc_4f28f14dcceb["equalsBufferSubsections()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| 089960a6_5ea1_7a61_e2cc_4f28f14dcceb 89bb59cb_8b6e_121f_1587_25bd20e90f2a["random()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| 89bb59cb_8b6e_121f_1587_25bd20e90f2a 9c382e0b_955d_1535_b5bf_edc98ee27513["notEqualsBufferSubsections()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| 9c382e0b_955d_1535_b5bf_edc98ee27513 5bfdd8a4_5a0d_1ab6_cde8_89c35cd461f4["notEqualsBufferOverflow()"] 1b32157c_4c5c_4c3c_706b_1a74a9afdca7 -->|method| 5bfdd8a4_5a0d_1ab6_cde8_89c35cd461f4
Relationship Graph
Source Code
buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java lines 46–1111
public class ByteBufUtilTest {
private static final String PARAMETERIZED_NAME = "bufferType = {0}";
private final AdaptiveByteBufAllocator adaptiveByteBufAllocator = new AdaptiveByteBufAllocator();
private enum BufferType {
DIRECT_UNPOOLED, DIRECT_POOLED, DIRECT_ADAPTIVE, HEAP_POOLED, HEAP_UNPOOLED, HEAP_ADAPTIVE
}
private ByteBuf buffer(BufferType bufferType, int capacity) {
switch (bufferType) {
case DIRECT_UNPOOLED:
return Unpooled.directBuffer(capacity);
case HEAP_UNPOOLED:
return Unpooled.buffer(capacity);
case DIRECT_POOLED:
return PooledByteBufAllocator.DEFAULT.directBuffer(capacity);
case HEAP_POOLED:
return PooledByteBufAllocator.DEFAULT.buffer(capacity);
case DIRECT_ADAPTIVE:
return adaptiveByteBufAllocator.directBuffer(capacity);
case HEAP_ADAPTIVE:
return adaptiveByteBufAllocator.heapBuffer(capacity);
default:
throw new AssertionError("unexpected buffer type: " + bufferType);
}
}
private CompositeByteBuf compositeByteBuf(BufferType bufferType) {
switch (bufferType) {
case DIRECT_UNPOOLED:
return UnpooledByteBufAllocator.DEFAULT.compositeDirectBuffer();
case HEAP_UNPOOLED:
return UnpooledByteBufAllocator.DEFAULT.compositeHeapBuffer();
case DIRECT_POOLED:
return PooledByteBufAllocator.DEFAULT.compositeDirectBuffer();
case HEAP_POOLED:
return PooledByteBufAllocator.DEFAULT.compositeHeapBuffer();
case DIRECT_ADAPTIVE:
return adaptiveByteBufAllocator.compositeDirectBuffer();
case HEAP_ADAPTIVE:
return adaptiveByteBufAllocator.compositeHeapBuffer();
default:
throw new AssertionError("unexpected buffer type: " + bufferType);
}
}
public static Collection<Object[]> noUnsafe() {
return Arrays.asList(new Object[][] {
{ BufferType.DIRECT_POOLED },
{ BufferType.DIRECT_UNPOOLED },
{ BufferType.HEAP_POOLED },
{ BufferType.HEAP_UNPOOLED },
{ BufferType.DIRECT_ADAPTIVE },
{ BufferType.HEAP_ADAPTIVE }
});
}
@Test
public void decodeRandomHexBytesWithEvenLength() {
decodeRandomHexBytes(256);
}
@Test
public void decodeRandomHexBytesWithOddLength() {
decodeRandomHexBytes(257);
}
private static void decodeRandomHexBytes(int len) {
byte[] b = new byte[len];
Random rand = new Random();
rand.nextBytes(b);
String hexDump = ByteBufUtil.hexDump(b);
for (int i = 0; i <= len; i++) { // going over sub-strings of various lengths including empty byte[].
byte[] b2 = Arrays.copyOfRange(b, i, b.length);
byte[] decodedBytes = ByteBufUtil.decodeHexDump(hexDump, i * 2, (len - i) * 2);
assertArrayEquals(b2, decodedBytes);
}
}
Source
Frequently Asked Questions
What is the ByteBufUtilTest class?
ByteBufUtilTest is a class in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java.
Where is ByteBufUtilTest defined?
ByteBufUtilTest is defined in buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java at line 46.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free