Search in sources :

Example 6 with EmbeddedChannel

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

the class NonChunkedHttpMessageHandlerTest method setup.

@BeforeEach
void setup() {
    endpoint = mock(BaseEndpoint.class);
    EndpointContext endpointContext = mock(EndpointContext.class);
    when(endpointContext.environment()).thenReturn(env);
    when(endpointContext.authenticator()).thenReturn(PasswordAuthenticator.create("user", "pass"));
    when(endpoint.context()).thenReturn(endpointContext);
    channel = new EmbeddedChannel();
}
Also used : BaseEndpoint(com.couchbase.client.core.endpoint.BaseEndpoint) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with EmbeddedChannel

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

the class AbstractKeyValueEmbeddedChannelTest method beforeEach.

@BeforeEach
protected void beforeEach() {
    channel = new EmbeddedChannel();
    eventBus = new SimpleEventBus(true);
}
Also used : SimpleEventBus(com.couchbase.client.core.cnc.SimpleEventBus) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with EmbeddedChannel

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

the class BaseEndpointTest method disconnectAfterBeingConnected.

/**
 * This test tests the happy path, after being connected properly eventually a disconnect
 * signal comes along.
 */
@Test
void disconnectAfterBeingConnected() {
    EmbeddedChannel channel = new EmbeddedChannel();
    InstrumentedEndpoint endpoint = connectSuccessfully(channel);
    assertTrue(channel.isOpen());
    assertTrue(channel.isActive());
    endpoint.disconnect();
    waitUntilCondition(() -> endpoint.state() == EndpointState.DISCONNECTED);
    assertFalse(channel.isOpen());
    assertFalse(channel.isActive());
    assertEquals(2, eventBus.publishedEvents().size());
    assertTrue(eventBus.publishedEvents().get(0) instanceof EndpointConnectedEvent);
    assertTrue(eventBus.publishedEvents().get(1) instanceof EndpointDisconnectedEvent);
}
Also used : EndpointDisconnectedEvent(com.couchbase.client.core.cnc.events.endpoint.EndpointDisconnectedEvent) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) EndpointConnectedEvent(com.couchbase.client.core.cnc.events.endpoint.EndpointConnectedEvent) Test(org.junit.jupiter.api.Test)

Example 9 with EmbeddedChannel

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

the class PasswordAuthenticatorTest method ldapCompatibleOnlyEnablesPlain.

@Test
void ldapCompatibleOnlyEnablesPlain() {
    PasswordAuthenticator authenticator = PasswordAuthenticator.ldapCompatible("user", "pass");
    EndpointContext ctx = mock(EndpointContext.class);
    when(ctx.environment()).thenReturn(ENV);
    EmbeddedChannel channel = new EmbeddedChannel();
    authenticator.authKeyValueConnection(ctx, channel.pipeline());
    SaslAuthenticationHandler handler = channel.pipeline().get(SaslAuthenticationHandler.class);
    assertEquals(EnumSet.of(SaslMechanism.PLAIN), handler.allowedMechanisms());
}
Also used : SaslAuthenticationHandler(com.couchbase.client.core.io.netty.kv.SaslAuthenticationHandler) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) Test(org.junit.jupiter.api.Test)

Example 10 with EmbeddedChannel

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

the class PasswordAuthenticatorTest method allowsToEnablePlainInAddition.

@Test
void allowsToEnablePlainInAddition() {
    PasswordAuthenticator authenticator = PasswordAuthenticator.builder().username("user").password("pass").enablePlainSaslMechanism().build();
    EndpointContext ctx = mock(EndpointContext.class);
    when(ctx.environment()).thenReturn(ENV);
    EmbeddedChannel channel = new EmbeddedChannel();
    authenticator.authKeyValueConnection(ctx, channel.pipeline());
    SaslAuthenticationHandler handler = channel.pipeline().get(SaslAuthenticationHandler.class);
    assertEquals(EnumSet.allOf(SaslMechanism.class), handler.allowedMechanisms());
}
Also used : SaslAuthenticationHandler(com.couchbase.client.core.io.netty.kv.SaslAuthenticationHandler) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) Test(org.junit.jupiter.api.Test)

Aggregations

EmbeddedChannel (com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel)32 Test (org.junit.jupiter.api.Test)23 EndpointContext (com.couchbase.client.core.endpoint.EndpointContext)15 ByteBuf (com.couchbase.client.core.deps.io.netty.buffer.ByteBuf)13 Core (com.couchbase.client.core.Core)8 CoreContext (com.couchbase.client.core.CoreContext)8 CoreEnvironment (com.couchbase.client.core.env.CoreEnvironment)8 BaseEndpoint (com.couchbase.client.core.endpoint.BaseEndpoint)7 SimpleEventBus (com.couchbase.client.core.cnc.SimpleEventBus)6 GetRequest (com.couchbase.client.core.msg.kv.GetRequest)6 DefaultHttpResponse (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse)5 DefaultLastHttpContent (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent)5 HttpContent (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpContent)5 HttpResponse (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 EndpointDisconnectedEvent (com.couchbase.client.core.cnc.events.endpoint.EndpointDisconnectedEvent)4 DefaultHttpContent (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent)4 HostAndPort (com.couchbase.client.core.util.HostAndPort)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 MethodSource (org.junit.jupiter.params.provider.MethodSource)4