written.release();
}
@Test
public void shouldEncodeContent() {
DefaultMemcacheContent content1 =
new DefaultMemcacheContent(Unpooled.copiedBuffer("Netty", CharsetUtil.UTF_8));
DefaultLastMemcacheContent content2 =
new DefaultLastMemcacheContent(Unpooled.copiedBuffer(" Rocks!", CharsetUtil.UTF_8));
int totalBodyLength = content1.content().readableBytes() + content2.content().readableBytes();
BinaryMemcacheRequest request = new DefaultBinaryMemcacheRequest();
request.setTotalBodyLength(totalBodyLength);
boolean result = channel.writeOutbound(request);
assertThat(result, is(true));
result = channel.writeOutbound(content1);
assertThat(result, is(true));
result = channel.writeOutbound(content2);
assertThat(result, is(true));
ByteBuf written = channel.readOutbound();
assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE));
written = channel.readOutbound();
assertThat(written.readableBytes(), is(content1.content().readableBytes()));
assertThat(
written.readBytes(content1.content().readableBytes()).toString(CharsetUtil.UTF_8),
is("Netty")
);
written.release();
written = channel.readOutbound();