Search in sources :

Example 46 with LocalChannel

use of io.netty.channel.local.LocalChannel in project netty by netty.

the class DefaultChannelPipelineTest method testNullName.

@Test
public void testNullName() {
    ChannelPipeline pipeline = new LocalChannel().pipeline();
    pipeline.addLast(newHandler());
    pipeline.addLast(null, newHandler());
    pipeline.addFirst(newHandler());
    pipeline.addFirst(null, newHandler());
    pipeline.addLast("test", newHandler());
    pipeline.addAfter("test", null, newHandler());
    pipeline.addBefore("test", null, newHandler());
}
Also used : LocalChannel(io.netty.channel.local.LocalChannel) Test(org.junit.Test)

Example 47 with LocalChannel

use of io.netty.channel.local.LocalChannel in project netty by netty.

the class DefaultChannelPipelineTest method testAddHandlerBeforeRegisteredThenRemove.

@Test(timeout = 3000)
public void testAddHandlerBeforeRegisteredThenRemove() {
    final EventLoop loop = group.next();
    CheckEventExecutorHandler handler = new CheckEventExecutorHandler(loop);
    ChannelPipeline pipeline = new LocalChannel().pipeline();
    pipeline.addFirst(handler);
    assertFalse(handler.addedPromise.isDone());
    group.register(pipeline.channel());
    handler.addedPromise.syncUninterruptibly();
    pipeline.remove(handler);
    handler.removedPromise.syncUninterruptibly();
}
Also used : LocalChannel(io.netty.channel.local.LocalChannel) Test(org.junit.Test)

Example 48 with LocalChannel

use of io.netty.channel.local.LocalChannel in project netty by netty.

the class DefaultChannelPipelineTest method testNotPinExecutor.

@Test
public void testNotPinExecutor() {
    EventExecutorGroup group = new DefaultEventExecutorGroup(2);
    ChannelPipeline pipeline = new LocalChannel().pipeline();
    pipeline.channel().config().setOption(ChannelOption.SINGLE_EVENTEXECUTOR_PER_GROUP, false);
    pipeline.addLast(group, "h1", new ChannelInboundHandlerAdapter());
    pipeline.addLast(group, "h2", new ChannelInboundHandlerAdapter());
    EventExecutor executor1 = pipeline.context("h1").executor();
    EventExecutor executor2 = pipeline.context("h2").executor();
    assertNotNull(executor1);
    assertNotNull(executor2);
    assertNotSame(executor1, executor2);
    group.shutdownGracefully(0, 0, TimeUnit.SECONDS);
}
Also used : DefaultEventExecutorGroup(io.netty.util.concurrent.DefaultEventExecutorGroup) EventExecutorGroup(io.netty.util.concurrent.EventExecutorGroup) EventExecutor(io.netty.util.concurrent.EventExecutor) AbstractEventExecutor(io.netty.util.concurrent.AbstractEventExecutor) ImmediateEventExecutor(io.netty.util.concurrent.ImmediateEventExecutor) UnorderedThreadPoolEventExecutor(io.netty.util.concurrent.UnorderedThreadPoolEventExecutor) DefaultEventExecutorGroup(io.netty.util.concurrent.DefaultEventExecutorGroup) LocalChannel(io.netty.channel.local.LocalChannel) Test(org.junit.Test)

Example 49 with LocalChannel

use of io.netty.channel.local.LocalChannel in project netty by netty.

the class DefaultChannelPipelineTest method testCancelConnect.

@Test
public void testCancelConnect() throws Exception {
    ChannelPipeline pipeline = new LocalChannel().pipeline();
    group.register(pipeline.channel());
    ChannelPromise promise = pipeline.channel().newPromise();
    assertTrue(promise.cancel(false));
    ChannelFuture future = pipeline.connect(new LocalAddress("test"), promise);
    assertTrue(future.isCancelled());
}
Also used : LocalAddress(io.netty.channel.local.LocalAddress) LocalChannel(io.netty.channel.local.LocalChannel) Test(org.junit.Test)

Example 50 with LocalChannel

use of io.netty.channel.local.LocalChannel in project netty by netty.

the class DefaultChannelPipelineTest method testFirstHandlerEmptyPipeline.

@Test
public void testFirstHandlerEmptyPipeline() throws Exception {
    ChannelPipeline pipeline = new LocalChannel().pipeline();
    assertNull(pipeline.first());
}
Also used : LocalChannel(io.netty.channel.local.LocalChannel) Test(org.junit.Test)

Aggregations

LocalChannel (io.netty.channel.local.LocalChannel)53 Test (org.junit.Test)49 LocalServerChannel (io.netty.channel.local.LocalServerChannel)16 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)14 LocalAddress (io.netty.channel.local.LocalAddress)14 Bootstrap (io.netty.bootstrap.Bootstrap)13 Channel (io.netty.channel.Channel)12 EventLoopGroup (io.netty.channel.EventLoopGroup)12 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)11 LocalEventLoopGroup (io.netty.channel.local.LocalEventLoopGroup)11 DefaultEventLoopGroup (io.netty.channel.DefaultEventLoopGroup)8 DefaultEventExecutorGroup (io.netty.util.concurrent.DefaultEventExecutorGroup)7 EventExecutorGroup (io.netty.util.concurrent.EventExecutorGroup)7 CountDownLatch (java.util.concurrent.CountDownLatch)7 TimeoutException (java.util.concurrent.TimeoutException)7 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)4 ExpectedException (org.junit.rules.ExpectedException)4 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)3 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)3 OioSocketChannel (io.netty.channel.socket.oio.OioSocketChannel)3