use of org.jboss.netty.channel.Channel in project neo4j by neo4j.
the class IdleChannelReaperTest method shouldNotCloseAnyRecentlyActiveChannels.
@Test
public void shouldNotCloseAnyRecentlyActiveChannels() {
// given
FakeClock clock = Clocks.fakeClock();
ChannelCloser channelCloser = mock(ChannelCloser.class);
IdleChannelReaper idleChannelReaper = new IdleChannelReaper(channelCloser, NO_LOGGING, clock, THRESHOLD);
Channel channel = mock(Channel.class);
idleChannelReaper.add(channel, dummyRequestContext());
// when
idleChannelReaper.run();
// then
verifyNoMoreInteractions(channelCloser);
}
use of org.jboss.netty.channel.Channel in project neo4j by neo4j.
the class IdleChannelReaperTest method shouldNotTryToCloseAChannelThatWasRecentlyActive.
@Test
public void shouldNotTryToCloseAChannelThatWasRecentlyActive() {
// given
FakeClock clock = Clocks.fakeClock();
ChannelCloser channelCloser = mock(ChannelCloser.class);
IdleChannelReaper idleChannelReaper = new IdleChannelReaper(channelCloser, NO_LOGGING, clock, THRESHOLD);
Channel channel = mock(Channel.class);
RequestContext request = dummyRequestContext();
idleChannelReaper.add(channel, request);
// when
clock.forward(THRESHOLD + 100, TimeUnit.MILLISECONDS);
idleChannelReaper.update(channel);
idleChannelReaper.run();
// then
verifyNoMoreInteractions(channelCloser);
}
use of org.jboss.netty.channel.Channel in project neo4j by neo4j.
the class PortRangeSocketBinderTest method shouldReturnChannelAndSocketIfPortIsFree.
@Test
public void shouldReturnChannelAndSocketIfPortIsFree() {
// given
HostnamePort localhost = new HostnamePort("localhost", 9000);
ServerBootstrap bootstrap = mock(ServerBootstrap.class);
Channel channel = mock(Channel.class);
when(bootstrap.bind(new InetSocketAddress("localhost", 9000))).thenReturn(channel);
// when
Connection connection = new PortRangeSocketBinder(bootstrap).bindToFirstAvailablePortInRange(localhost);
//then
assertEquals(channel, connection.getChannel());
assertEquals(new InetSocketAddress("localhost", 9000), connection.getSocketAddress());
}
use of org.jboss.netty.channel.Channel in project graylog2-server by Graylog2.
the class GELFHttpHandlerTest method setUp.
@Before
public void setUp() throws Exception {
ChannelBuffer channelBuffer = ChannelBuffers.copiedBuffer("{}", StandardCharsets.UTF_8);
when(headers.get(HttpHeaders.Names.CONNECTION)).thenReturn(HttpHeaders.Values.CLOSE);
when(request.getMethod()).thenReturn(HttpMethod.POST);
when(request.headers()).thenReturn(headers);
when(request.getProtocolVersion()).thenReturn(HttpVersion.HTTP_1_1);
when(request.getContent()).thenReturn(channelBuffer);
when(request.getUri()).thenReturn("/gelf");
when(ctx.getChannel()).thenReturn(mock(Channel.class));
ChannelFuture channelFuture = mock(ChannelFuture.class);
when(channel.write(any())).thenReturn(channelFuture);
when(evt.getMessage()).thenReturn(request);
when(evt.getChannel()).thenReturn(channel);
}
use of org.jboss.netty.channel.Channel in project crate by crate.
the class PostgresNetty method doStop.
@Override
protected void doStop() {
synchronized (serverChannels) {
if (serverChannels != null) {
for (Channel channel : serverChannels) {
channel.close().awaitUninterruptibly();
}
serverChannels = null;
}
}
if (bootstrap != null) {
bootstrap.releaseExternalResources();
bootstrap = null;
}
}
Aggregations