Example usage for io.netty.buffer DefaultByteBufHolder DefaultByteBufHolder

List of usage examples for io.netty.buffer DefaultByteBufHolder DefaultByteBufHolder

Introduction

In this page you can find the example usage for io.netty.buffer DefaultByteBufHolder DefaultByteBufHolder.

Prototype

public DefaultByteBufHolder(ByteBuf data) 

Source Link

Usage

From source file:co.rsk.rpc.netty.RskJsonRpcHandlerTest.java

License:Open Source License

@Test
public void handlerDeserializesAndHandlesRequest() throws Exception {
    Channel channel = mock(Channel.class);
    ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
    when(ctx.channel()).thenReturn(channel);

    when(serializer.deserializeRequest(any())).thenReturn(SAMPLE_SUBSCRIBE_REQUEST);
    when(emitter.subscribe(channel)).thenReturn(SAMPLE_SUBSCRIPTION_ID);
    when(serializer.serializeMessage(any())).thenReturn("serialized");

    DefaultByteBufHolder msg = new DefaultByteBufHolder(Unpooled.copiedBuffer("raw".getBytes()));
    handler.channelRead(ctx, msg);/* w  w  w  .j  a  va 2  s  . c o m*/

    verify(ctx, times(1)).writeAndFlush(new TextWebSocketFrame("serialized"));
    verify(ctx, never()).fireChannelRead(any());
}

From source file:co.rsk.rpc.netty.RskJsonRpcHandlerTest.java

License:Open Source License

@Test
public void handlerPassesRequestToNextHandlerOnException() throws Exception {
    ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);

    when(serializer.deserializeRequest(any())).thenThrow(new IOException());

    DefaultByteBufHolder msg = new DefaultByteBufHolder(Unpooled.copiedBuffer("raw".getBytes()));
    handler.channelRead(ctx, msg);/*from  ww w  .j ava  2 s. c  om*/

    verify(ctx, never()).writeAndFlush(any());
    verify(ctx, times(1)).fireChannelRead(msg);
}

From source file:com.addthis.basis.chars.ReadOnlyUtfBuf.java

License:Apache License

@Override
public ByteBufHolder copy() {
    return new DefaultByteBufHolder(data.copy());
}

From source file:com.addthis.basis.chars.ReadOnlyUtfBuf.java

License:Apache License

@Override
public ByteBufHolder duplicate() {
    return new DefaultByteBufHolder(data.duplicate());
}