use of io.netty.channel.local.LocalChannel in project netty by netty.
the class DefaultChannelPipelineTest method testAddReplaceHandlerNotRegistered.
@Test
public void testAddReplaceHandlerNotRegistered() throws Throwable {
final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
ChannelHandler handler = new ErrorChannelHandler(error);
ChannelPipeline pipeline = new LocalChannel().pipeline();
pipeline.addFirst(handler);
pipeline.replace(handler, null, new ErrorChannelHandler(error));
Throwable cause = error.get();
if (cause != null) {
throw cause;
}
}
use of io.netty.channel.local.LocalChannel in project netty by netty.
the class DefaultChannelPipelineTest method testUnexpectedVoidChannelPromiseCloseFuture.
@Test(expected = IllegalArgumentException.class)
public void testUnexpectedVoidChannelPromiseCloseFuture() throws Exception {
ChannelPipeline pipeline = new LocalChannel().pipeline();
group.register(pipeline.channel()).sync();
try {
ChannelPromise promise = (ChannelPromise) pipeline.channel().closeFuture();
pipeline.close(promise);
} finally {
pipeline.close();
}
}
use of io.netty.channel.local.LocalChannel in project netty by netty.
the class DefaultChannelPipelineTest method testFirstContextEmptyPipeline.
@Test
public void testFirstContextEmptyPipeline() throws Exception {
ChannelPipeline pipeline = new LocalChannel().pipeline();
assertNull(pipeline.firstContext());
}
use of io.netty.channel.local.LocalChannel in project netty by netty.
the class DefaultChannelPipelineTest method testAddRemoveHandlerCalledOnceRegistered.
@Test(timeout = 2000)
public void testAddRemoveHandlerCalledOnceRegistered() throws Throwable {
ChannelPipeline pipeline = new LocalChannel().pipeline();
CallbackCheckHandler handler = new CallbackCheckHandler();
pipeline.addFirst(handler);
pipeline.remove(handler);
assertNull(handler.addedHandler.getNow());
assertNull(handler.removedHandler.getNow());
group.register(pipeline.channel()).syncUninterruptibly();
Throwable cause = handler.error.get();
if (cause != null) {
throw cause;
}
assertTrue(handler.addedHandler.get());
assertTrue(handler.removedHandler.get());
}
use of io.netty.channel.local.LocalChannel in project netty by netty.
the class DefaultChannelPipelineTest method testCancelWriteAndFlush.
@Test
public void testCancelWriteAndFlush() throws Exception {
ChannelPipeline pipeline = new LocalChannel().pipeline();
group.register(pipeline.channel());
ChannelPromise promise = pipeline.channel().newPromise();
assertTrue(promise.cancel(false));
ByteBuf buffer = Unpooled.buffer();
assertEquals(1, buffer.refCnt());
ChannelFuture future = pipeline.writeAndFlush(buffer, promise);
assertTrue(future.isCancelled());
assertEquals(0, buffer.refCnt());
}
Aggregations