Search in sources :

Example 1 with ChannelFutureListener

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

the class KeyValueChannelIntegrationTest method assertAuthenticationFailure.

/**
 * Helper method to assert authentication failure in different scenarios.
 */
private void assertAuthenticationFailure(final Bootstrap bootstrap, final String msg) throws Exception {
    CountDownLatch latch = new CountDownLatch(1);
    bootstrap.connect().addListener((ChannelFutureListener) future -> {
        try {
            assertFalse(future.isSuccess());
            Throwable ex = future.cause();
            assertTrue(ex instanceof AuthenticationFailureException);
            assertEquals(msg, ex.getMessage());
        } finally {
            latch.countDown();
        }
    });
    latch.await();
}
Also used : ChannelFutureListener(com.couchbase.client.core.deps.io.netty.channel.ChannelFutureListener) KeyValueEndpoint(com.couchbase.client.core.endpoint.KeyValueEndpoint) AuthenticationFailureException(com.couchbase.client.core.error.AuthenticationFailureException) ClusterType(com.couchbase.client.test.ClusterType) NoopRequest(com.couchbase.client.core.msg.kv.NoopRequest) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) AfterAll(org.junit.jupiter.api.AfterAll) PasswordAuthenticator(com.couchbase.client.core.env.PasswordAuthenticator) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) ServiceType(com.couchbase.client.core.service.ServiceType) Duration(java.time.Duration) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) NioEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.nio.NioEventLoopGroup) Channel(com.couchbase.client.core.deps.io.netty.channel.Channel) ChannelInitializer(com.couchbase.client.core.deps.io.netty.channel.ChannelInitializer) Assert.assertTrue(org.junit.Assert.assertTrue) CoreEnvironment(com.couchbase.client.core.env.CoreEnvironment) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) Services(com.couchbase.client.test.Services) Test(org.junit.jupiter.api.Test) TimeUnit(java.util.concurrent.TimeUnit) SimpleEventBus(com.couchbase.client.core.cnc.SimpleEventBus) CountDownLatch(java.util.concurrent.CountDownLatch) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) NoopResponse(com.couchbase.client.core.msg.kv.NoopResponse) Optional(java.util.Optional) CollectionIdentifier(com.couchbase.client.core.io.CollectionIdentifier) Core(com.couchbase.client.core.Core) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) HostAndPort(com.couchbase.client.core.util.HostAndPort) Assert.assertEquals(org.junit.Assert.assertEquals) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) AuthenticationFailureException(com.couchbase.client.core.error.AuthenticationFailureException) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Core (com.couchbase.client.core.Core)1 SimpleEventBus (com.couchbase.client.core.cnc.SimpleEventBus)1 Bootstrap (com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap)1 Channel (com.couchbase.client.core.deps.io.netty.channel.Channel)1 ChannelFutureListener (com.couchbase.client.core.deps.io.netty.channel.ChannelFutureListener)1 ChannelInitializer (com.couchbase.client.core.deps.io.netty.channel.ChannelInitializer)1 NioEventLoopGroup (com.couchbase.client.core.deps.io.netty.channel.nio.NioEventLoopGroup)1 SocketChannel (com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel)1 NioSocketChannel (com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel)1 EndpointContext (com.couchbase.client.core.endpoint.EndpointContext)1 KeyValueEndpoint (com.couchbase.client.core.endpoint.KeyValueEndpoint)1 CoreEnvironment (com.couchbase.client.core.env.CoreEnvironment)1 PasswordAuthenticator (com.couchbase.client.core.env.PasswordAuthenticator)1 AuthenticationFailureException (com.couchbase.client.core.error.AuthenticationFailureException)1 CollectionIdentifier (com.couchbase.client.core.io.CollectionIdentifier)1 NoopRequest (com.couchbase.client.core.msg.kv.NoopRequest)1 NoopResponse (com.couchbase.client.core.msg.kv.NoopResponse)1 ServiceType (com.couchbase.client.core.service.ServiceType)1 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)1 HostAndPort (com.couchbase.client.core.util.HostAndPort)1