@Test void initChannel() throws Exception { Mockito .when(socketChannel.pipeline()) .thenReturn(channelPipeline); Mockito .when(channelPipeline.addLast(any())) .thenReturn(channelPipeline); Mockito .when(channelPipeline.first()) .thenReturn(new HttpServerCodec()); Mockito .when(channelPipeline.get(HttpObjectAggregator.class)) .thenReturn(new HttpObjectAggregator(65536)); Mockito .when(channelPipeline.get(DssHttpRequestHandler.class)) .thenReturn(new DssHttpRequestHandler("/websocket")); Mockito .when(channelPipeline.last()) .thenReturn(new DssWebSocketHandler()); final DssWebSocketChannelInitializer dssWebSocketChannelInitializer = Mockito.mock(DssWebSocketChannelInitializer.class); dssWebSocketChannelInitializer.initChannel(socketChannel); final ChannelPipeline p = socketChannel.pipeline(); assertEquals(HttpServerCodec.class, p.first().getClass()); assertEquals(HttpObjectAggregator.class, p.get(HttpObjectAggregator.class).getClass()); assertEquals(DssHttpRequestHandler.class, p.get(DssHttpRequestHandler.class).getClass()); assertEquals(DssWebSocketHandler.class, p.last().getClass()); }
@Override protected void initChannel(SocketChannel ch) throws Exception { logger.info("Try to initChannel"); final ChannelPipeline p = ch.pipeline(); p.addLast(new HttpServerCodec()); p.addLast(new HttpObjectAggregator(65536)); p.addLast(new DssHttpRequestHandler(WEBSOCKET_PATH)); p.addLast(new DssWebSocketHandler()); }
DssWebSocketChannelInitializer extends ChannelInitializer<SocketChannel> { @Override protected void initChannel(SocketChannel ch) throws Exception { logger.info("Try to initChannel"); final ChannelPipeline p = ch.pipeline(); p.addLast(new HttpServerCodec()); p.addLast(new HttpObjectAggregator(65536)); p.addLast(new DssHttpRequestHandler(WEBSOCKET_PATH)); p.addLast(new DssWebSocketHandler()); } }
DssWebSocketChannelInitializer extends ChannelInitializer<SocketChannel> { @Override protected void initChannel(SocketChannel ch) throws Exception { logger.info("Try to initChannel"); final ChannelPipeline p = ch.pipeline(); p.addLast(new HttpServerCodec()); p.addLast(new HttpObjectAggregator(65536)); p.addLast(new DssHttpRequestHandler(WEBSOCKET_PATH)); p.addLast(new DssWebSocketHandler()); }  }
DssWebSocketChannelInitializer extends ChannelInitializer<SocketChannel> { @Override protected void initChannel(SocketChannel ch) throws Exception { logger.info("Try to initChannel"); final ChannelPipeline p = ch.pipeline(); p.addLast(new HttpServerCodec()); p.addLast(new HttpObjectAggregator(65536)); p.addLast(new DssHttpRequestHandler(WEBSOCKET_PATH)); p.addLast(new DssWebSocketHandler()); }   }
DssWebSocketChannelInitializer extends ChannelInitializer<SocketChannel> { @Override protected void initChannel(SocketChannel ch) throws Exception { logger.info("Try to initChannel"); final ChannelPipeline p = ch.pipeline(); p.addLast(new HttpServerCodec()); p.addLast(new HttpObjectAggregator(65536)); p.addLast(new DssHttpRequestHandler(WEBSOCKET_PATH)); p.addLast(new DssWebSocketHandler()); }    }