use of org.apache.kafka.common.message.EnvelopeRequestData in project kafka by apache.
the class EnvelopeRequestTest method testToSend.
@Test
public void testToSend() throws IOException {
for (short version : ApiKeys.ENVELOPE.allVersions()) {
ByteBuffer requestData = ByteBuffer.wrap("foobar".getBytes());
RequestHeader header = new RequestHeader(ApiKeys.ENVELOPE, version, "clientId", 15);
EnvelopeRequest request = new EnvelopeRequest.Builder(requestData, "principal".getBytes(), InetAddress.getLocalHost().getAddress()).build(version);
Send send = request.toSend(header);
ByteBuffer buffer = TestUtils.toBuffer(send);
assertEquals(send.size() - 4, buffer.getInt());
assertEquals(header, RequestHeader.parse(buffer));
EnvelopeRequestData parsedRequestData = new EnvelopeRequestData();
parsedRequestData.read(new ByteBufferAccessor(buffer), version);
assertEquals(request.data(), parsedRequestData);
}
}
Aggregations