Search in sources :

Example 6 with CoreContext

use of com.couchbase.client.core.CoreContext in project couchbase-jvm-clients by couchbase.

the class FeatureNegotiatingHandlerTest method beforeEach.

@BeforeEach
@Override
protected void beforeEach() {
    super.beforeEach();
    CoreEnvironment env = mock(CoreEnvironment.class);
    timeoutConfig = mock(TimeoutConfig.class);
    when(env.eventBus()).thenReturn(eventBus);
    when(env.timeoutConfig()).thenReturn(timeoutConfig);
    when(env.userAgent()).thenReturn(new UserAgent("some", Optional.empty(), Optional.empty(), Optional.empty()));
    when(timeoutConfig.connectTimeout()).thenReturn(Duration.ofMillis(1000));
    CoreContext coreContext = new CoreContext(mock(Core.class), 1, env, mock(Authenticator.class));
    endpointContext = new EndpointContext(coreContext, new HostAndPort("127.0.0.1", 1234), null, ServiceType.KV, Optional.empty(), Optional.empty(), Optional.empty());
}
Also used : HostAndPort(com.couchbase.client.core.util.HostAndPort) CoreContext(com.couchbase.client.core.CoreContext) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) Core(com.couchbase.client.core.Core) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with CoreContext

use of com.couchbase.client.core.CoreContext in project couchbase-jvm-clients by couchbase.

the class KeyValueMessageHandlerTest method setup.

@BeforeAll
static void setup() {
    ENV = CoreEnvironment.builder().eventBus(new SimpleEventBus(true)).build();
    Core core = mock(Core.class);
    CoreContext coreContext = new CoreContext(core, 1, ENV, PasswordAuthenticator.create("foo", "bar"));
    ConfigurationProvider configurationProvider = mock(ConfigurationProvider.class);
    when(configurationProvider.collectionMap()).thenReturn(new CollectionMap());
    when(core.configurationProvider()).thenReturn(configurationProvider);
    CTX = new EndpointContext(coreContext, new HostAndPort("127.0.0.1", 1234), null, ServiceType.KV, Optional.empty(), Optional.empty(), Optional.empty());
}
Also used : HostAndPort(com.couchbase.client.core.util.HostAndPort) CoreContext(com.couchbase.client.core.CoreContext) CollectionMap(com.couchbase.client.core.io.CollectionMap) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) ConfigurationProvider(com.couchbase.client.core.config.ConfigurationProvider) SimpleEventBus(com.couchbase.client.core.cnc.SimpleEventBus) Core(com.couchbase.client.core.Core) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 8 with CoreContext

use of com.couchbase.client.core.CoreContext in project couchbase-jvm-clients by couchbase.

the class MemcacheProtocolTest method before.

@BeforeEach
void before() {
    eventBus = mock(EventBus.class);
    CoreEnvironment env = mock(CoreEnvironment.class);
    context = new CoreContext(mock(Core.class), 1, env, mock(Authenticator.class));
    when(env.eventBus()).thenReturn(eventBus);
}
Also used : CoreContext(com.couchbase.client.core.CoreContext) CoreEnvironment(com.couchbase.client.core.env.CoreEnvironment) EventBus(com.couchbase.client.core.cnc.EventBus) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with CoreContext

use of com.couchbase.client.core.CoreContext in project couchbase-jvm-clients by couchbase.

the class SaslListMechanismsHandlerTest method beforeEach.

@BeforeEach
@Override
protected void beforeEach() {
    super.beforeEach();
    CoreEnvironment env = mock(CoreEnvironment.class);
    TimeoutConfig timeoutConfig = mock(TimeoutConfig.class);
    when(env.eventBus()).thenReturn(eventBus);
    when(env.timeoutConfig()).thenReturn(timeoutConfig);
    when(timeoutConfig.connectTimeout()).thenReturn(Duration.ofMillis(1000));
    CoreContext coreContext = new CoreContext(mock(Core.class), 1, env, mock(Authenticator.class));
    endpointContext = new EndpointContext(coreContext, new HostAndPort("127.0.0.1", 1234), null, ServiceType.KV, Optional.empty(), Optional.empty(), Optional.empty());
}
Also used : HostAndPort(com.couchbase.client.core.util.HostAndPort) TimeoutConfig(com.couchbase.client.core.env.TimeoutConfig) CoreContext(com.couchbase.client.core.CoreContext) CoreEnvironment(com.couchbase.client.core.env.CoreEnvironment) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) Authenticator(com.couchbase.client.core.env.Authenticator) Core(com.couchbase.client.core.Core) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with CoreContext

use of com.couchbase.client.core.CoreContext in project couchbase-jvm-clients by couchbase.

the class RequestContextTest method requestCancellation.

@Test
void requestCancellation() {
    Request<?> request = mock(Request.class);
    Core core = mock(Core.class);
    RequestContext ctx = new RequestContext(new CoreContext(core, 1, null, mock(Authenticator.class)), request);
    ctx.cancel();
    verify(request, times(1)).cancel(CancellationReason.CANCELLED_VIA_CONTEXT);
}
Also used : CoreContext(com.couchbase.client.core.CoreContext) Core(com.couchbase.client.core.Core) Test(org.junit.jupiter.api.Test)

Aggregations

CoreContext (com.couchbase.client.core.CoreContext)52 Core (com.couchbase.client.core.Core)46 Test (org.junit.jupiter.api.Test)25 CoreEnvironment (com.couchbase.client.core.env.CoreEnvironment)22 Authenticator (com.couchbase.client.core.env.Authenticator)17 SimpleEventBus (com.couchbase.client.core.cnc.SimpleEventBus)14 BeforeEach (org.junit.jupiter.api.BeforeEach)13 EndpointContext (com.couchbase.client.core.endpoint.EndpointContext)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 ArrayList (java.util.ArrayList)10 EmbeddedChannel (com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel)9 HostAndPort (com.couchbase.client.core.util.HostAndPort)9 List (java.util.List)8 TimeoutConfig (com.couchbase.client.core.env.TimeoutConfig)7 ServiceContext (com.couchbase.client.core.service.ServiceContext)7 Duration (java.time.Duration)7 Optional (java.util.Optional)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 SeedNode (com.couchbase.client.core.env.SeedNode)6 Event (com.couchbase.client.core.cnc.Event)5