List of usage examples for io.netty.channel ChannelInboundHandler channelInactive
void channelInactive(ChannelHandlerContext ctx) throws Exception;
From source file:org.anhonesteffort.chnlzr.ServerHandlerTest.java
License:Open Source License
@Test public void testRequestResourcesReleasedOnClose() throws Exception { final ChnlzrServerConfig CONFIG = config(); final SamplesSinkFactory SINK_FACTORY = Mockito.mock(SamplesSinkFactory.class); final SamplesSink SINK = Mockito.mock(SamplesSink.class); final SamplesSourceController SOURCE_CONTROLLER = Mockito.mock(SamplesSourceController.class); final ChannelSpec SPEC = ChannelSpec.fromMinMax(1337d, 9001d); Mockito.when(SOURCE_CONTROLLER.getCapabilities()).thenReturn(SPEC); Mockito.when(SOURCE_CONTROLLER.configureSourceForSink(Mockito.any())).thenReturn(0x00); Mockito.when(SINK.getSpec()).thenReturn(new ChannelSpec(1337d, 9001d)); Mockito.when(SINK_FACTORY.create(Mockito.any(), Mockito.any())).thenReturn(SINK); final ChannelInboundHandler HANDLER = new ServerHandler(CONFIG, SINK_FACTORY, SOURCE_CONTROLLER); final EmbeddedChannel CHANNEL = new EmbeddedChannel(HANDLER); assert CHANNEL.readOutbound() != null; CHANNEL.writeInbound(request().getRoot(BaseMessage.factory).asReader()); Mockito.verify(SOURCE_CONTROLLER, Mockito.times(1)).configureSourceForSink(Mockito.any()); Mockito.verify(SOURCE_CONTROLLER, Mockito.never()).releaseSink(Mockito.any()); HANDLER.channelInactive(Mockito.mock(ChannelHandlerContext.class)); Mockito.verify(SOURCE_CONTROLLER, Mockito.times(1)).releaseSink(Mockito.any()); }