@Test(timeout = 60000) public void testAddChannelHandlerBeforeWithEventExecGroup() 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 .addChannelHandlerBefore(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()).addBefore(executor, baseHandlerName, handlerName, handlerFactory); Mockito.verifyNoMoreInteractions(newState.unsafeDetachedPipeline()); Mockito.verifyNoMoreInteractions(clientStateRule.mockPipeline); }
@Test(timeout = 60000) public void testAddChannelHandlerBefore() throws Exception { String handlerName = "test_handler"; String baseHandlerName = "test_handler_base"; Func0<ChannelHandler> handlerFactory = clientStateRule.newHandler(); ClientState<String, String> newState = clientStateRule.clientState .addChannelHandlerBefore(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()).addBefore(baseHandlerName, handlerName, handlerFactory); Mockito.verifyNoMoreInteractions(newState.unsafeDetachedPipeline()); Mockito.verifyNoMoreInteractions(clientStateRule.mockPipeline); }
@Override public <WW, RR> TcpClient<WW, RR> addChannelHandlerBefore(String baseName, String name, Func0<ChannelHandler> handlerFactory) { return copy(state.<WW, RR>addChannelHandlerBefore(baseName, name, handlerFactory), eventPublisher); }
@Override public <WW, RR> TcpClient<WW, RR> addChannelHandlerBefore(EventExecutorGroup group, String baseName, String name, Func0<ChannelHandler> handlerFactory) { return copy(state.<WW, RR>addChannelHandlerBefore(group, baseName, name, handlerFactory), eventPublisher); }