use of com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext in project couchbase-jvm-clients by couchbase.
the class ErrorMapLoadingHandlerTest method propagateConnectFailureFromDownstream.
/**
* This test verifies that if a downstream promise fails that the error
* is propagated through the captured promise.
*/
@Test
void propagateConnectFailureFromDownstream() {
final Exception connectException = new Exception("I failed");
ChannelDuplexHandler failingHandler = new ChannelDuplexHandler() {
@Override
public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) {
promise.setFailure(connectException);
}
};
ErrorMapLoadingHandler handler = new ErrorMapLoadingHandler(endpointContext);
channel.pipeline().addLast(failingHandler).addLast(handler);
ChannelFuture connect = channel.connect(new InetSocketAddress("1.2.3.4", 1234));
assertEquals(connectException, connect.awaitUninterruptibly().cause());
}
use of com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext in project couchbase-jvm-clients by couchbase.
the class SaslListMechanismsHandlerTest method propagatesChannelActiveAfterSendingInitialRequest.
/**
* This test makes sure that after the initial request is sent, the channel active signal is
* propagated so that we do not regress bootstrap pipelining functionality.
*/
@Test
void propagatesChannelActiveAfterSendingInitialRequest() {
final SaslListMechanismsHandler handler = new SaslListMechanismsHandler(endpointContext);
final AtomicBoolean channelActiveFired = new AtomicBoolean();
channel.pipeline().addLast(handler).addLast(new SimpleChannelInboundHandler<ByteBuf>() {
@Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) {
}
@Override
public void channelActive(ChannelHandlerContext ctx) {
channelActiveFired.set(true);
}
});
assertEquals(handler, channel.pipeline().get(SaslListMechanismsHandler.class));
channel.connect(new InetSocketAddress("1.2.3.4", 1234));
channel.pipeline().fireChannelActive();
channel.runPendingTasks();
waitUntilCondition(channelActiveFired::get);
}
use of com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext in project couchbase-jvm-clients by couchbase.
the class SaslListMechanismsHandlerTest method propagateConnectFailureFromDownstream.
/**
* This test verifies that if a downstream promise fails that the error
* is propagated through the captured promise.
*/
@Test
void propagateConnectFailureFromDownstream() {
final Exception connectException = new Exception("I failed");
ChannelDuplexHandler failingHandler = new ChannelDuplexHandler() {
@Override
public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) {
promise.setFailure(connectException);
}
};
SaslListMechanismsHandler handler = new SaslListMechanismsHandler(endpointContext);
channel.pipeline().addLast(failingHandler).addLast(handler);
ChannelFuture connect = channel.connect(new InetSocketAddress("1.2.3.4", 1234));
assertEquals(connectException, connect.awaitUninterruptibly().cause());
}
use of com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext in project couchbase-jvm-clients by couchbase.
the class BaseEndpointIntegrationTest method startLocalServer.
private LocalServerController startLocalServer(final DefaultEventLoopGroup eventLoopGroup) {
final LocalServerController localServerController = new LocalServerController();
ServerBootstrap bootstrap = new ServerBootstrap().group(eventLoopGroup).localAddress(new LocalAddress("server")).childHandler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
ch.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() {
@Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) {
}
@Override
public void channelActive(ChannelHandlerContext ctx) {
localServerController.channel.set(ctx.channel());
localServerController.connectAttempts.incrementAndGet();
ctx.fireChannelActive();
}
});
}
}).channel(LocalServerChannel.class);
bootstrap.bind().awaitUninterruptibly();
return localServerController;
}
use of com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext in project couchbase-jvm-clients by couchbase.
the class SelectBucketHandlerTest method propagateConnectFailureFromDownstream.
/**
* This test verifies that if a downstream promise fails that the error
* is propagated through the captured promise.
*/
@Test
void propagateConnectFailureFromDownstream() {
final Exception connectException = new Exception("I failed");
ChannelDuplexHandler failingHandler = new ChannelDuplexHandler() {
@Override
public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) {
promise.setFailure(connectException);
}
};
SelectBucketHandler handler = new SelectBucketHandler(endpointContext, "bucket");
channel.pipeline().addLast(failingHandler).addLast(handler);
ChannelFuture connect = channel.connect(new InetSocketAddress("1.2.3.4", 1234));
assertEquals(connectException, connect.awaitUninterruptibly().cause());
}
Aggregations