List of usage examples for io.netty.util.concurrent DefaultEventExecutor DefaultEventExecutor
public DefaultEventExecutor()
From source file:org.restcomm.media.network.netty.NettyNetworkManagerTest.java
License:Open Source License
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test/*from ww w . jav a 2 s . c o m*/
public void testCloseAsyncFailure() {
// given
final EventLoopGroup eventLoopGroup = mock(EventLoopGroup.class);
final Bootstrap bootstrap = PowerMockito.mock(Bootstrap.class);
PowerMockito.when(bootstrap.group()).thenReturn(eventLoopGroup);
final NettyNetworkManager networkManager = new NettyNetworkManager(bootstrap);
final FutureCallback<Void> callback = mock(FutureCallback.class);
final Exception exception = new RuntimeException("Testing purposes!");
this.eventExecutor = new DefaultEventExecutor();
final Future shutdownFuture = new FailedFuture<>(this.eventExecutor, exception);
// when
when(eventLoopGroup.shutdownGracefully(any(Long.class), any(Long.class), any(TimeUnit.class)))
.thenReturn(shutdownFuture);
networkManager.close(callback);
// then
verify(callback, timeout(100)).onFailure(exception);
}
From source file:org.restcomm.media.network.netty.NettyNetworkManagerTest.java
License:Open Source License
@SuppressWarnings({ "unchecked" })
@Test/* w w w . ja va 2s. c o m*/
public void testOpenChannelAsync() throws Exception {
// given
this.eventLoopGroup = new NioEventLoopGroup(1);
final ChannelHandler channelHandler = mock(ChannelHandler.class);
final Bootstrap bootstrap = new Bootstrap().group(eventLoopGroup).channel(NioDatagramChannel.class)
.handler(channelHandler);
this.eventExecutor = new DefaultEventExecutor();
final FutureCallback<Channel> callback = mock(FutureCallback.class);
final ArgumentCaptor<Channel> captor = ArgumentCaptor.forClass(Channel.class);
try (final NettyNetworkManager networkManager = new NettyNetworkManager(bootstrap)) {
// when
networkManager.openChannel(callback);
// then
verify(callback, timeout(100)).onSuccess(captor.capture());
assertTrue(captor.getValue().isOpen());
assertTrue(captor.getValue().isRegistered());
assertFalse(captor.getValue().isActive());
}
}
From source file:org.restcomm.media.network.netty.NettyNetworkManagerTest.java
License:Open Source License
@SuppressWarnings("unchecked") @Test//ww w . j a va2 s .c om public void testOpenChannelAsyncFailure() throws Exception { // given this.eventLoopGroup = new NioEventLoopGroup(1); final Bootstrap bootstrap = PowerMockito.mock(Bootstrap.class); PowerMockito.when(bootstrap.group()).thenReturn(eventLoopGroup); this.eventExecutor = new DefaultEventExecutor(); final FutureCallback<Channel> callback = mock(FutureCallback.class); final Channel channel = mock(Channel.class); final ChannelPromise promise = new DefaultChannelProgressivePromise(channel, eventExecutor); final Exception exception = new RuntimeException("Testing purposes!"); try (final NettyNetworkManager networkManager = new NettyNetworkManager(bootstrap)) { // when when(bootstrap.clone()).thenReturn(bootstrap); when(bootstrap.register()).thenReturn(promise); promise.setFailure(exception); networkManager.openChannel(callback); // then verify(callback, timeout(100)).onFailure(exception); } }
From source file:org.waarp.commandexec.client.LocalExecClientInitializer.java
License:Open Source License
public LocalExecClientInitializer() { channelGroup = new DefaultChannelGroup("LocalExecClient", new DefaultEventExecutor()); }