@Test(timeout = 60000) public void testAddChannelHandlerAfter() throws Exception { String handlerName = "test_handler"; String baseHandlerName = "test_handler_base"; Func0<ChannelHandler> handlerFactory = clientStateRule.newHandler(); ClientState<String, String> newState = clientStateRule.clientState .addChannelHandlerAfter(baseHandlerName, handlerName, handlerFactory); clientStateRule.verifyMockPipelineAccessPostCopy(); assertThat("Client state not copied.", clientStateRule.clientState, is(not(newState))); assertThat("Options copied.", clientStateRule.clientState.unsafeChannelOptions(), is(newState.unsafeChannelOptions())); assertThat("Detached pipeline not copied.", clientStateRule.clientState.unsafeDetachedPipeline(), is(not(newState.unsafeDetachedPipeline()))); Mockito.verify(newState.unsafeDetachedPipeline()).addAfter(baseHandlerName, handlerName, handlerFactory); Mockito.verifyNoMoreInteractions(newState.unsafeDetachedPipeline()); Mockito.verifyNoMoreInteractions(clientStateRule.mockPipeline); }
@Test(timeout = 60000) public void testAddChannelHandlerAfterWithEventExecGroup() throws Exception { String handlerName = "test_handler"; String baseHandlerName = "test_handler_base"; Func0<ChannelHandler> handlerFactory = clientStateRule.newHandler(); NioEventLoopGroup executor = new NioEventLoopGroup(); ClientState<String, String> newState = clientStateRule.clientState .addChannelHandlerAfter(executor, baseHandlerName, handlerName, handlerFactory); clientStateRule.verifyMockPipelineAccessPostCopy(); assertThat("Client state not copied.", clientStateRule.clientState, is(not(newState))); assertThat("Options copied.", clientStateRule.clientState.unsafeChannelOptions(), is(newState.unsafeChannelOptions())); assertThat("Detached pipeline not copied.", clientStateRule.clientState.unsafeDetachedPipeline(), is(not(newState.unsafeDetachedPipeline()))); Mockito.verify(newState.unsafeDetachedPipeline()).addAfter(executor, baseHandlerName, handlerName, handlerFactory); Mockito.verifyNoMoreInteractions(newState.unsafeDetachedPipeline()); Mockito.verifyNoMoreInteractions(clientStateRule.mockPipeline); }
@Override public <WW, RR> TcpClient<WW, RR> addChannelHandlerAfter(EventExecutorGroup group, String baseName, String name, Func0<ChannelHandler> handlerFactory) { return copy(state.<WW, RR>addChannelHandlerAfter(group, baseName, name, handlerFactory), eventPublisher); }
@Override public <WW, RR> TcpClient<WW, RR> addChannelHandlerAfter(String baseName, String name, Func0<ChannelHandler> handlerFactory) { return copy(state.<WW, RR>addChannelHandlerAfter(baseName, name, handlerFactory), eventPublisher); }