Search in sources :

Example 1 with ChannelDuplexHandler

use of com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler 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());
}
Also used : ChannelFuture(com.couchbase.client.core.deps.io.netty.channel.ChannelFuture) InetSocketAddress(java.net.InetSocketAddress) ChannelDuplexHandler(com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler) ChannelHandlerContext(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext) ChannelPromise(com.couchbase.client.core.deps.io.netty.channel.ChannelPromise) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.jupiter.api.Test)

Example 2 with ChannelDuplexHandler

use of com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler 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());
}
Also used : ChannelFuture(com.couchbase.client.core.deps.io.netty.channel.ChannelFuture) InetSocketAddress(java.net.InetSocketAddress) ChannelDuplexHandler(com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler) ChannelHandlerContext(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext) ChannelPromise(com.couchbase.client.core.deps.io.netty.channel.ChannelPromise) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) AuthenticationFailureException(com.couchbase.client.core.error.AuthenticationFailureException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.jupiter.api.Test)

Example 3 with ChannelDuplexHandler

use of com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler 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());
}
Also used : ChannelFuture(com.couchbase.client.core.deps.io.netty.channel.ChannelFuture) InetSocketAddress(java.net.InetSocketAddress) ChannelDuplexHandler(com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler) ChannelHandlerContext(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext) ChannelPromise(com.couchbase.client.core.deps.io.netty.channel.ChannelPromise) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.jupiter.api.Test)

Example 4 with ChannelDuplexHandler

use of com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler in project couchbase-jvm-clients by couchbase.

the class FeatureNegotiatingHandlerTest 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);
        }
    };
    FeatureNegotiatingHandler handler = new FeatureNegotiatingHandler(endpointContext, Collections.singleton(ServerFeature.TRACING));
    channel.pipeline().addLast(failingHandler).addLast(handler);
    ChannelFuture connect = channel.connect(new InetSocketAddress("1.2.3.4", 1234));
    assertEquals(connectException, connect.awaitUninterruptibly().cause());
}
Also used : ChannelFuture(com.couchbase.client.core.deps.io.netty.channel.ChannelFuture) InetSocketAddress(java.net.InetSocketAddress) ChannelDuplexHandler(com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler) ChannelHandlerContext(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext) ChannelPromise(com.couchbase.client.core.deps.io.netty.channel.ChannelPromise) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ChannelDuplexHandler (com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler)4 ChannelFuture (com.couchbase.client.core.deps.io.netty.channel.ChannelFuture)4 ChannelHandlerContext (com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext)4 ChannelPromise (com.couchbase.client.core.deps.io.netty.channel.ChannelPromise)4 InetSocketAddress (java.net.InetSocketAddress)4 SocketAddress (java.net.SocketAddress)4 TimeoutException (java.util.concurrent.TimeoutException)4 Test (org.junit.jupiter.api.Test)4 AuthenticationFailureException (com.couchbase.client.core.error.AuthenticationFailureException)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1