Package io.netty.channel

Examples of io.netty.channel.ChannelHandlerContext.channel()


    private SockJsSessionContext newSessionContext(final boolean active) {
        final Channel channel = mock(Channel.class);
        when(channel.isActive()).thenReturn(active);
        when(channel.isRegistered()).thenReturn(active);
        final ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
        when(ctx.channel()).thenReturn(channel);
        final SockJsSessionContext sessionContext = mock(SockJsSessionContext.class);
        when(sessionContext.getContext()).thenReturn(ctx);
        return sessionContext;
    }
View Full Code Here


     *
     * Listing 6.2 of <i>Netty in Action</i>
     */
    public static void eventsViaChannel(ChannelHandlerContext context) {
        ChannelHandlerContext ctx = context;
        Channel channel = ctx.channel();
        channel.write(Unpooled.copiedBuffer("Netty in Action",
                CharsetUtil.UTF_8));

    }

View Full Code Here

    ByteBufAllocator alloc = mock(ByteBufAllocator.class);
    when(ctx.alloc()).thenReturn(alloc);
    when(alloc.ioBuffer()).thenReturn(buf);

    DatagramChannel dc = mock(DatagramChannel.class);
    when(ctx.channel()).thenReturn(dc);
    when(ctx.writeAndFlush(any(), any(ChannelPromise.class))).thenReturn(
        null);

    Attribute<InetSocketAddress> attr = mock(Attribute.class);
    when(ctx.attr(any(AttributeKey.class))).thenReturn(attr);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.