use of org.apache.kafka.common.message.EnvelopeResponseData in project kafka by apache.
the class EnvelopeResponseTest method testToSend.
@Test
public void testToSend() {
for (short version : ApiKeys.ENVELOPE.allVersions()) {
ByteBuffer responseData = ByteBuffer.wrap("foobar".getBytes());
EnvelopeResponse response = new EnvelopeResponse(responseData, Errors.NONE);
short headerVersion = ApiKeys.ENVELOPE.responseHeaderVersion(version);
ResponseHeader header = new ResponseHeader(15, headerVersion);
Send send = response.toSend(header, version);
ByteBuffer buffer = TestUtils.toBuffer(send);
assertEquals(send.size() - 4, buffer.getInt());
assertEquals(header, ResponseHeader.parse(buffer, headerVersion));
EnvelopeResponseData parsedResponseData = new EnvelopeResponseData();
parsedResponseData.read(new ByteBufferAccessor(buffer), version);
assertEquals(response.data(), parsedResponseData);
}
}
Aggregations