### Question:
HttpServerInitializer extends ChannelInitializer<SocketChannel> { @Override protected void initChannel(SocketChannel socketChannel) throws Exception { ChannelPipeline p = socketChannel.pipeline(); p.addLast(new HttpRequestDecoder()); p.addLast(new HttpObjectAggregator(1024 * 1024)); p.addLast(new HttpResponseEncoder()); p.addLast(new HttpServerHandler()); }    }### Answer:
@Test public void testInitChannel() throws Exception { HttpServerInitializer httpServerInitializer = mock(HttpServerInitializer.class); SocketChannel socketChannel = mock(SocketChannel.class); ChannelPipeline channelPipeline = mock(ChannelPipeline.class); when(socketChannel.pipeline()).thenReturn(channelPipeline); doCallRealMethod().when(httpServerInitializer).initChannel(socketChannel); httpServerInitializer.initChannel(socketChannel); verify(channelPipeline, times(4)).addLast(any(ChannelHandler.class)); InOrder inOrder = inOrder(channelPipeline); inOrder.verify(channelPipeline).addLast(any(HttpRequestDecoder.class)); inOrder.verify(channelPipeline).addLast(any(HttpObjectAggregator.class)); inOrder.verify(channelPipeline).addLast(any(HttpResponseEncoder.class)); inOrder.verify(channelPipeline).addLast(any(HttpServerHandler.class)); }