Java 类io.netty.buffer.DefaultByteBufHolder 实例源码

项目:netty-netty-5.0.0.Alpha1    文件:LoggingHandlerTest.java   
@Test
public void shouldLogByteBufHolderDataRead() throws Exception {
    ByteBufHolder msg = new DefaultByteBufHolder(Unpooled.copiedBuffer("hello", CharsetUtil.UTF_8)) {
        @Override
        public String toString() {
            return "foobar";
        }
    };

    appender.doAppend(matchesLog(".+RECEIVED: foobar, 5B$"));
    replay(appender);
    EmbeddedChannel channel = new EmbeddedChannel(new LoggingHandler());
    channel.writeInbound(msg);
    verify(appender);

    ByteBufHolder handledMsg = channel.readInbound();
    assertThat(msg, is(sameInstance(handledMsg)));
    handledMsg.release();
    assertThat(channel.readInbound(), is(nullValue()));
}
项目:basis    文件:ReadOnlyUtfBuf.java   
@Override
public ByteBufHolder copy() {
    return new DefaultByteBufHolder(data.copy());
}
项目:basis    文件:ReadOnlyUtfBuf.java   
@Override
public ByteBufHolder duplicate() {
    return new DefaultByteBufHolder(data.duplicate());
}