Class ReadableByteBufSingleRequestBufferTest
java.lang.Object
org.apache.kafka.common.network.netty.ReadableByteBufSingleRequestBufferTest
Test class to test ReadableByteBuf backing only a single buffer.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic voidvoidvoidvoidtestFlip()voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidUnsigned integer encoded as variable integer require special serialization to test.voidSigned integer encoded as variable integer require special serialization to test.voidvoidTest if we read only partial data then remaining bytes returned is correct.voidvoidvoid
-
Constructor Details
-
ReadableByteBufSingleRequestBufferTest
public ReadableByteBufSingleRequestBufferTest()
-
-
Method Details
-
beforeAll
- Throws:
IOException
-
beforeEach
@BeforeEach public void beforeEach() -
afterEach
@AfterEach public void afterEach() -
testSlice
@Test public void testSlice() -
testPosition
@Test public void testPosition() -
testSetPosition
@Test public void testSetPosition() -
testRewind
@Test public void testRewind() -
testFlip
@Test public void testFlip() -
testReadByte
@Test public void testReadByte() -
testReadShort
@Test public void testReadShort() -
testReadInt
@Test public void testReadInt() -
testReadLong
@Test public void testReadLong() -
testReadDouble
@Test public void testReadDouble() -
testReadArray
@Test public void testReadArray() -
testReadByteBuffer
@Test public void testReadByteBuffer() -
testReadByteBufferStillWorksAfterReleased
@Test public void testReadByteBufferStillWorksAfterReleased() -
testReadUnsignedVarInt
@Test public void testReadUnsignedVarInt()Unsigned integer encoded as variable integer require special serialization to test. The format of long/integer as variable number of bytes is described here: Google Protocol BuffersWe will test this by writing an int value and then reading it back. The value we use is same as one in the doc above, which is 150, serialized as 0x96 0x01. Refer to the doc above to understand why 150 gets serialized as 0x96 0x01.
-
testReadVarInt
@Test public void testReadVarInt()Signed integer encoded as variable integer require special serialization to test. The format of long/integer as variable number of bytes is described here: Google Protocol Buffers. Instead of using two's complement to encode negative numbers, ZigZag encoding is used to encode the number. The format is described in the link above.We will test this by writing a signed int value and then reading it back. The value we use is same as one in the doc above, which is -2, serialized as value of 3 unsigned int.
-
testReadVarLong
@Test public void testReadVarLong() -
testRemaining
@Test public void testRemaining()Test if we read only partial data then remaining bytes returned is correct. -
testNioBufferReturnsCorrectByteBuffer
@Test public void testNioBufferReturnsCorrectByteBuffer() -
testNioBufferDoesNotModifyReaderIndex
@Test public void testNioBufferDoesNotModifyReaderIndex() -
testNioBufferOnEmptyBufferReturnsEmptyByteBuffer
@Test public void testNioBufferOnEmptyBufferReturnsEmptyByteBuffer() -
testNioBufferFromMiddleOfTheBuffer
@Test public void testNioBufferFromMiddleOfTheBuffer() -
testNioBufferFromMiddleOfTheBufferWithModifiedReaderAndWriterIndex
@Test public void testNioBufferFromMiddleOfTheBufferWithModifiedReaderAndWriterIndex() -
closeHandlesAlreadyReleasedBufferGracefully
@Test public void closeHandlesAlreadyReleasedBufferGracefully()
-