@Test public void testPipeline() throws Exception { final Minijax minijax = new Minijax(); final ScheduledExecutorService executor = mock(ScheduledExecutorService.class); final ChannelPipeline pipeline = mock(ChannelPipeline.class); when(pipeline.addLast(anyString(), any())).thenReturn(pipeline); final SocketChannel ch = mock(SocketChannel.class); when(ch.pipeline()).thenReturn(pipeline); final ServerInitializer initializer = new ServerInitializer(minijax, executor); initializer.initChannel(ch); final ArgumentCaptor<ChannelHandler> argument = ArgumentCaptor.forClass(ChannelHandler.class); verify(pipeline, times(4)).addLast(anyString(), argument.capture()); final List<ChannelHandler> handlers = argument.getAllValues(); assertEquals(HttpResponseEncoder.class, handlers.get(0).getClass()); assertEquals(HttpRequestDecoder.class, handlers.get(1).getClass()); assertEquals(HttpObjectAggregator.class, handlers.get(2).getClass()); assertEquals(ServerHandler.class, handlers.get(3).getClass()); }
@Override public void initChannel(final SocketChannel ch) { ch.pipeline() .addLast("encoder", new HttpResponseEncoder()) .addLast("decoder", new HttpRequestDecoder(4096, 8192, 8192, false)) .addLast("aggregator", new HttpObjectAggregator(1048576)) .addLast("handler", new ServerHandler(minijax, service)); }
ServerInitializer extends ChannelInitializer<SocketChannel> { @Override public void initChannel(final SocketChannel ch) { ch.pipeline() .addLast("encoder", new HttpResponseEncoder()) .addLast("decoder", new HttpRequestDecoder(4096, 8192, 8192, false)) .addLast("aggregator", new HttpObjectAggregator(1048576)) .addLast("handler", new ServerHandler(minijax, service)); } }
ServerInitializer extends ChannelInitializer<SocketChannel> { @Override public void initChannel(final SocketChannel ch) { ch.pipeline() .addLast("encoder", new HttpResponseEncoder()) .addLast("decoder", new HttpRequestDecoder(4096, 8192, 8192, false)) .addLast("aggregator", new HttpObjectAggregator(1048576)) .addLast("handler", new ServerHandler(minijax, service)); } ServerInitializer(final Minijax minijax, final ScheduledExecutorService service); }
ServerInitializer extends ChannelInitializer<SocketChannel> { @Override public void initChannel(final SocketChannel ch) { ch.pipeline() .addLast("encoder", new HttpResponseEncoder()) .addLast("decoder", new HttpRequestDecoder(4096, 8192, 8192, false)) .addLast("aggregator", new HttpObjectAggregator(1048576)) .addLast("handler", new ServerHandler(minijax, service)); } ServerInitializer(final Minijax minijax, final ScheduledExecutorService service); @Override void initChannel(final SocketChannel ch); }
ServerInitializer extends ChannelInitializer<SocketChannel> { @Override public void initChannel(final SocketChannel ch) { ch.pipeline() .addLast("encoder", new HttpResponseEncoder()) .addLast("decoder", new HttpRequestDecoder(4096, 8192, 8192, false)) .addLast("aggregator", new HttpObjectAggregator(1048576)) .addLast("handler", new ServerHandler(minijax, service)); } ServerInitializer(final Minijax minijax, final ScheduledExecutorService service); @Override void initChannel(final SocketChannel ch);  }