Search in sources :

Example 1 with BaseEndpoint

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

the class ManagerMessageHandlerTest method disconnectsEndpointOnRedialTimeout.

/**
 * When a http streaming connection is outstanding, the handler needs to notify the endpoint that it disconnects
 * itself in an orderly manner.
 */
@Test
void disconnectsEndpointOnRedialTimeout() throws Exception {
    CoreEnvironment env = CoreEnvironment.builder().ioConfig(IoConfig.configIdleRedialTimeout(Duration.ofSeconds(2))).build();
    try {
        CoreContext ctx = new CoreContext(mock(Core.class), 1, env, PasswordAuthenticator.create(USER, PASS));
        BaseEndpoint endpoint = mock(BaseEndpoint.class);
        EndpointContext endpointContext = mock(EndpointContext.class);
        when(endpointContext.environment()).thenReturn(env);
        when(endpoint.context()).thenReturn(endpointContext);
        EmbeddedChannel channel = new EmbeddedChannel(new ManagerMessageHandler(endpoint, ctx));
        BucketConfigStreamingRequest request = new BucketConfigStreamingRequest(Duration.ofSeconds(1), ctx, BestEffortRetryStrategy.INSTANCE, "bucket", ctx.authenticator());
        channel.write(request);
        HttpRequest outboundHeader = channel.readOutbound();
        assertEquals(HttpMethod.GET, outboundHeader.method());
        assertEquals("/pools/default/bs/bucket", outboundHeader.uri());
        assertEquals(HttpVersion.HTTP_1_1, outboundHeader.protocolVersion());
        HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        HttpContent httpContent = new DefaultHttpContent(Unpooled.copiedBuffer("{}\n\n\n\n", StandardCharsets.UTF_8));
        channel.writeInbound(httpResponse, httpContent);
        BucketConfigStreamingResponse response = request.response().get();
        assertEquals("{}", response.configs().blockFirst());
        waitUntilCondition(() -> {
            channel.runPendingTasks();
            MockingDetails mockingDetails = Mockito.mockingDetails(endpoint);
            return mockingDetails.getInvocations().stream().anyMatch(i -> i.getMethod().getName().equals("disconnect"));
        });
        channel.finish();
    } finally {
        env.shutdown();
    }
}
Also used : HttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpRequest) CoreContext(com.couchbase.client.core.CoreContext) BucketConfigStreamingResponse(com.couchbase.client.core.msg.manager.BucketConfigStreamingResponse) CoreEnvironment(com.couchbase.client.core.env.CoreEnvironment) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) DefaultHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) HttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) MockingDetails(org.mockito.MockingDetails) BucketConfigStreamingRequest(com.couchbase.client.core.msg.manager.BucketConfigStreamingRequest) BaseEndpoint(com.couchbase.client.core.endpoint.BaseEndpoint) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) DefaultHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent) DefaultLastHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent) HttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpContent) Core(com.couchbase.client.core.Core) Test(org.junit.jupiter.api.Test)

Example 2 with BaseEndpoint

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

the class QueryMessageHandlerTest method reportsCompletionOnlyOnceStreamingEnds.

/**
 * To avoid accidentally pipelining requests, we need to make sure that the handler only reports completion
 * once the streaming is fully completed, and not just the response completable future initially completed.
 *
 * <p>We send a request, make sure it is encoded correctly and then stream back the chunks, making sure the
 * final completion is only signaled once the last chunk arrived.</p>
 */
@Test
void reportsCompletionOnlyOnceStreamingEnds() {
    BaseEndpoint endpoint = mock(BaseEndpoint.class);
    EmbeddedChannel channel = new EmbeddedChannel(new QueryMessageHandler(endpoint, ENDPOINT_CTX));
    byte[] query = "doesn'tmatter".getBytes(CharsetUtil.UTF_8);
    QueryRequest request = new QueryRequest(ENV.timeoutConfig().queryTimeout(), CORE_CTX, ENV.retryStrategy(), CORE_CTX.authenticator(), "statement", query, false, null, null, null, null, null);
    channel.writeAndFlush(request);
    FullHttpRequest encodedRequest = channel.readOutbound();
    assertEquals("doesn'tmatter", encodedRequest.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.release(encodedRequest);
    verify(endpoint, never()).markRequestCompletion();
    assertFalse(request.response().isDone());
    ByteBuf fullResponse = Unpooled.copiedBuffer(readResource("success_response.json", QueryMessageHandlerTest.class), CharsetUtil.UTF_8);
    // send the header back first
    HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    channel.writeInbound(response);
    assertFalse(request.response().isDone());
    // send first chunk, should complete the future but not mark the endpoint completion
    HttpContent firstChunk = new DefaultHttpContent(fullResponse.readBytes(500));
    channel.writeInbound(firstChunk);
    assertTrue(request.response().isDone());
    verify(endpoint, never()).markRequestCompletion();
    // send the second chunk, no change
    HttpContent secondChunk = new DefaultHttpContent(fullResponse.readBytes(500));
    channel.writeInbound(secondChunk);
    verify(endpoint, never()).markRequestCompletion();
    // send the last chunk, mark for completion finally
    LastHttpContent lastChunk = new DefaultLastHttpContent(fullResponse.readBytes(fullResponse.readableBytes()));
    channel.writeInbound(lastChunk);
    verify(endpoint, times(1)).markRequestCompletion();
    channel.finishAndReleaseAll();
}
Also used : FullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest) QueryRequest(com.couchbase.client.core.msg.query.QueryRequest) DefaultHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) HttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) LastHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.LastHttpContent) DefaultLastHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent) DefaultLastHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent) BaseEndpoint(com.couchbase.client.core.endpoint.BaseEndpoint) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) LastHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.LastHttpContent) DefaultHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent) DefaultLastHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent) HttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpContent) Test(org.junit.jupiter.api.Test)

Example 3 with BaseEndpoint

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

the class ManagerMessageHandlerTest method closesStreamIfChannelClosed.

/**
 * When a config stream is being processed and the underlying channel closes, the stream should also be closed
 * so the upper level can re-establish a new one.
 */
@Test
void closesStreamIfChannelClosed() throws Exception {
    CoreContext ctx = new CoreContext(mock(Core.class), 1, ENV, PasswordAuthenticator.create(USER, PASS));
    BaseEndpoint endpoint = mock(BaseEndpoint.class);
    EndpointContext endpointContext = mock(EndpointContext.class);
    when(endpointContext.environment()).thenReturn(ENV);
    when(endpoint.context()).thenReturn(endpointContext);
    EmbeddedChannel channel = new EmbeddedChannel(new ManagerMessageHandler(endpoint, ctx));
    BucketConfigStreamingRequest request = new BucketConfigStreamingRequest(Duration.ofSeconds(1), ctx, BestEffortRetryStrategy.INSTANCE, "bucket", ctx.authenticator());
    channel.write(request);
    HttpRequest outboundHeader = channel.readOutbound();
    assertEquals(HttpMethod.GET, outboundHeader.method());
    assertEquals("/pools/default/bs/bucket", outboundHeader.uri());
    assertEquals(HttpVersion.HTTP_1_1, outboundHeader.protocolVersion());
    CompletableFuture<BucketConfigStreamingResponse> response = request.response();
    assertFalse(response.isDone());
    HttpResponse inboundResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    channel.writeInbound(inboundResponse);
    BucketConfigStreamingResponse completedResponse = request.response().get();
    final AtomicBoolean terminated = new AtomicBoolean(false);
    Thread listener = new Thread(() -> completedResponse.configs().subscribe((v) -> {
    }, (e) -> {
    }, () -> terminated.set(true)));
    listener.setDaemon(true);
    listener.start();
    assertFalse(terminated.get());
    channel.close().awaitUninterruptibly();
    waitUntilCondition(terminated::get);
    channel.finish();
}
Also used : HttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpRequest) BucketConfigStreamingResponse(com.couchbase.client.core.msg.manager.BucketConfigStreamingResponse) HttpVersion(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpVersion) ReferenceCountUtil(com.couchbase.client.core.deps.io.netty.util.ReferenceCountUtil) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BestEffortRetryStrategy(com.couchbase.client.core.retry.BestEffortRetryStrategy) Random(java.util.Random) CompletableFuture(java.util.concurrent.CompletableFuture) DefaultHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent) HttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) ArrayList(java.util.ArrayList) BucketConfigStreamingRequest(com.couchbase.client.core.msg.manager.BucketConfigStreamingRequest) AfterAll(org.junit.jupiter.api.AfterAll) DefaultLastHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent) PasswordAuthenticator(com.couchbase.client.core.env.PasswordAuthenticator) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) CoreContext(com.couchbase.client.core.CoreContext) ResourceLeakDetector(com.couchbase.client.core.deps.io.netty.util.ResourceLeakDetector) Duration(java.time.Duration) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) HttpResponseStatus(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponseStatus) MockingDetails(org.mockito.MockingDetails) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Util.waitUntilCondition(com.couchbase.client.test.Util.waitUntilCondition) Unpooled(com.couchbase.client.core.deps.io.netty.buffer.Unpooled) HttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpContent) HttpMethod(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpMethod) BaseEndpoint(com.couchbase.client.core.endpoint.BaseEndpoint) CoreEnvironment(com.couchbase.client.core.env.CoreEnvironment) Mockito.when(org.mockito.Mockito.when) StandardCharsets(java.nio.charset.StandardCharsets) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) List(java.util.List) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) HttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpRequest) Util.readResource(com.couchbase.client.test.Util.readResource) Core(com.couchbase.client.core.Core) Collections(java.util.Collections) IoConfig(com.couchbase.client.core.env.IoConfig) Mockito.mock(org.mockito.Mockito.mock) CoreContext(com.couchbase.client.core.CoreContext) BucketConfigStreamingResponse(com.couchbase.client.core.msg.manager.BucketConfigStreamingResponse) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) HttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) BucketConfigStreamingRequest(com.couchbase.client.core.msg.manager.BucketConfigStreamingRequest) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BaseEndpoint(com.couchbase.client.core.endpoint.BaseEndpoint) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) Core(com.couchbase.client.core.Core) Test(org.junit.jupiter.api.Test)

Example 4 with BaseEndpoint

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

the class ManagerMessageHandlerTest method returnsNewConfigsWhenChunked.

/**
 * Configs can come in all shapes and sizes chunked, but only after the 4 newlines are pushed by the cluster
 * the config should be propagated into the flux.
 */
@Test
void returnsNewConfigsWhenChunked() throws Exception {
    CoreContext ctx = new CoreContext(mock(Core.class), 1, ENV, PasswordAuthenticator.create(USER, PASS));
    BaseEndpoint endpoint = mock(BaseEndpoint.class);
    EndpointContext endpointContext = mock(EndpointContext.class);
    when(endpointContext.environment()).thenReturn(ENV);
    when(endpoint.context()).thenReturn(endpointContext);
    EmbeddedChannel channel = new EmbeddedChannel(new ManagerMessageHandler(endpoint, ctx));
    BucketConfigStreamingRequest request = new BucketConfigStreamingRequest(Duration.ofSeconds(1), ctx, BestEffortRetryStrategy.INSTANCE, "bucket", ctx.authenticator());
    channel.write(request);
    HttpRequest outboundHeader = channel.readOutbound();
    assertEquals(HttpMethod.GET, outboundHeader.method());
    assertEquals("/pools/default/bs/bucket", outboundHeader.uri());
    assertEquals(HttpVersion.HTTP_1_1, outboundHeader.protocolVersion());
    CompletableFuture<BucketConfigStreamingResponse> response = request.response();
    assertFalse(response.isDone());
    HttpResponse inboundResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    channel.writeInbound(inboundResponse);
    BucketConfigStreamingResponse completedResponse = request.response().get();
    final List<String> configsPushed = Collections.synchronizedList(new ArrayList<>());
    final AtomicBoolean terminated = new AtomicBoolean(false);
    Thread listener = new Thread(() -> completedResponse.configs().subscribe(configsPushed::add, (e) -> {
    }, () -> terminated.set(true)));
    listener.setDaemon(true);
    listener.start();
    ByteBuf fullContent = Unpooled.copiedBuffer(readResource("terse_stream_two_configs.json", ManagerMessageHandlerTest.class), StandardCharsets.UTF_8);
    while (fullContent.readableBytes() > 0) {
        int len = new Random().nextInt(fullContent.readableBytes() + 1);
        if (len == 0) {
            continue;
        }
        channel.writeInbound(new DefaultHttpContent(fullContent.readBytes(len)));
    }
    waitUntilCondition(() -> configsPushed.size() >= 1);
    for (String config : configsPushed) {
        assertTrue(config.startsWith("{"));
        assertTrue(config.endsWith("}"));
    }
    assertFalse(terminated.get());
    channel.writeInbound(new DefaultLastHttpContent());
    waitUntilCondition(terminated::get);
    ReferenceCountUtil.release(fullContent);
    channel.close().awaitUninterruptibly();
}
Also used : BucketConfigStreamingResponse(com.couchbase.client.core.msg.manager.BucketConfigStreamingResponse) HttpVersion(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpVersion) ReferenceCountUtil(com.couchbase.client.core.deps.io.netty.util.ReferenceCountUtil) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BestEffortRetryStrategy(com.couchbase.client.core.retry.BestEffortRetryStrategy) Random(java.util.Random) CompletableFuture(java.util.concurrent.CompletableFuture) DefaultHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent) HttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) ArrayList(java.util.ArrayList) BucketConfigStreamingRequest(com.couchbase.client.core.msg.manager.BucketConfigStreamingRequest) AfterAll(org.junit.jupiter.api.AfterAll) DefaultLastHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent) PasswordAuthenticator(com.couchbase.client.core.env.PasswordAuthenticator) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) CoreContext(com.couchbase.client.core.CoreContext) ResourceLeakDetector(com.couchbase.client.core.deps.io.netty.util.ResourceLeakDetector) Duration(java.time.Duration) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) HttpResponseStatus(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponseStatus) MockingDetails(org.mockito.MockingDetails) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Util.waitUntilCondition(com.couchbase.client.test.Util.waitUntilCondition) Unpooled(com.couchbase.client.core.deps.io.netty.buffer.Unpooled) HttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpContent) HttpMethod(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpMethod) BaseEndpoint(com.couchbase.client.core.endpoint.BaseEndpoint) CoreEnvironment(com.couchbase.client.core.env.CoreEnvironment) Mockito.when(org.mockito.Mockito.when) StandardCharsets(java.nio.charset.StandardCharsets) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) List(java.util.List) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) HttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpRequest) Util.readResource(com.couchbase.client.test.Util.readResource) Core(com.couchbase.client.core.Core) Collections(java.util.Collections) IoConfig(com.couchbase.client.core.env.IoConfig) Mockito.mock(org.mockito.Mockito.mock) CoreContext(com.couchbase.client.core.CoreContext) BucketConfigStreamingResponse(com.couchbase.client.core.msg.manager.BucketConfigStreamingResponse) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) DefaultHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent) ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) Random(java.util.Random) DefaultLastHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent) Core(com.couchbase.client.core.Core) HttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpRequest) EmbeddedChannel(com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel) HttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) BucketConfigStreamingRequest(com.couchbase.client.core.msg.manager.BucketConfigStreamingRequest) BaseEndpoint(com.couchbase.client.core.endpoint.BaseEndpoint) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BaseEndpoint(com.couchbase.client.core.endpoint.BaseEndpoint) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) Test(org.junit.jupiter.api.Test)

Example 5 with BaseEndpoint

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

the class QueryMessageHandlerBackpressureTest method requestRecordsExplicitly.

/**
 * This test makes sure that even if the server returns a good bunch of data, each individual
 * chunk is requested by the caller explicitly.
 */
@Test
void requestRecordsExplicitly() throws Exception {
    EndpointContext endpointContext = new EndpointContext(core.context(), new HostAndPort("127.0.0.1", 1234), NoopCircuitBreaker.INSTANCE, ServiceType.QUERY, Optional.empty(), Optional.empty(), Optional.empty());
    BaseEndpoint endpoint = mock(BaseEndpoint.class);
    when(endpoint.pipelined()).thenReturn(false);
    Bootstrap client = new Bootstrap().channel(LocalChannel.class).group(new DefaultEventLoopGroup()).remoteAddress(new LocalAddress("s1")).handler(new ChannelInitializer<LocalChannel>() {

        @Override
        protected void initChannel(LocalChannel ch) {
            ch.pipeline().addLast(new HttpClientCodec()).addLast(new QueryMessageHandler(endpoint, endpointContext));
        }
    });
    Channel channel = client.connect().awaitUninterruptibly().channel();
    final List<byte[]> rows = Collections.synchronizedList(new ArrayList<>());
    QueryRequest request = new QueryRequest(Duration.ofSeconds(1), endpointContext, BestEffortRetryStrategy.INSTANCE, endpointContext.authenticator(), "select 1=1", "myquery".getBytes(UTF_8), true, null, null, null, null, null);
    channel.writeAndFlush(request);
    final QueryResponse response = request.response().get();
    assertEquals(0, rows.size());
    StepVerifier.create(response.rows().map(v -> new String(v.data(), UTF_8)), 0).thenRequest(1).expectNext("{\"foo\":1}").thenRequest(1).expectNext("{\"bar\":1}").thenRequest(2).expectNext("{\"faz\":1}", "{\"baz\":1}").thenRequest(4).expectNext("{\"fazz\":1}", "{\"bazz\":1}", "{\"fizz\":1}", "{\"bizz\":1}").expectComplete().verify();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) StepVerifier(reactor.test.StepVerifier) QueryRequest(com.couchbase.client.core.msg.query.QueryRequest) HttpHeaderNames(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpHeaderNames) ReferenceCountUtil(com.couchbase.client.core.deps.io.netty.util.ReferenceCountUtil) BestEffortRetryStrategy(com.couchbase.client.core.retry.BestEffortRetryStrategy) ServerBootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.ServerBootstrap) AfterAll(org.junit.jupiter.api.AfterAll) PasswordAuthenticator(com.couchbase.client.core.env.PasswordAuthenticator) ChannelInboundHandlerAdapter(com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter) BeforeAll(org.junit.jupiter.api.BeforeAll) ServiceType(com.couchbase.client.core.service.ServiceType) Duration(java.time.Duration) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) Channel(com.couchbase.client.core.deps.io.netty.channel.Channel) ChannelHandlerContext(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext) Unpooled(com.couchbase.client.core.deps.io.netty.buffer.Unpooled) BaseEndpoint(com.couchbase.client.core.endpoint.BaseEndpoint) LocalServerChannel(com.couchbase.client.core.deps.io.netty.channel.local.LocalServerChannel) CoreEnvironment(com.couchbase.client.core.env.CoreEnvironment) DefaultHttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse) DefaultEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.DefaultEventLoopGroup) Test(org.junit.jupiter.api.Test) List(java.util.List) Optional(java.util.Optional) HostAndPort(com.couchbase.client.core.util.HostAndPort) Mockito.mock(org.mockito.Mockito.mock) QueryResponse(com.couchbase.client.core.msg.query.QueryResponse) HttpVersion(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpVersion) DefaultHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent) SeedNode(com.couchbase.client.core.env.SeedNode) HttpResponse(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse) HttpServerCodec(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpServerCodec) ArrayList(java.util.ArrayList) LocalAddress(com.couchbase.client.core.deps.io.netty.channel.local.LocalAddress) DefaultLastHttpContent(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent) LocalChannel(com.couchbase.client.core.deps.io.netty.channel.local.LocalChannel) NoopCircuitBreaker(com.couchbase.client.core.endpoint.NoopCircuitBreaker) HttpResponseStatus(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponseStatus) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ChannelInitializer(com.couchbase.client.core.deps.io.netty.channel.ChannelInitializer) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Mockito.when(org.mockito.Mockito.when) EventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup) TimeUnit(java.util.concurrent.TimeUnit) HttpClientCodec(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpClientCodec) AfterEach(org.junit.jupiter.api.AfterEach) Core(com.couchbase.client.core.Core) Collections(java.util.Collections) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) LocalAddress(com.couchbase.client.core.deps.io.netty.channel.local.LocalAddress) QueryRequest(com.couchbase.client.core.msg.query.QueryRequest) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) LocalChannel(com.couchbase.client.core.deps.io.netty.channel.local.LocalChannel) Channel(com.couchbase.client.core.deps.io.netty.channel.Channel) LocalServerChannel(com.couchbase.client.core.deps.io.netty.channel.local.LocalServerChannel) LocalChannel(com.couchbase.client.core.deps.io.netty.channel.local.LocalChannel) HttpClientCodec(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpClientCodec) DefaultEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.DefaultEventLoopGroup) HostAndPort(com.couchbase.client.core.util.HostAndPort) BaseEndpoint(com.couchbase.client.core.endpoint.BaseEndpoint) QueryResponse(com.couchbase.client.core.msg.query.QueryResponse) ServerBootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.ServerBootstrap) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) Test(org.junit.jupiter.api.Test)

Aggregations

BaseEndpoint (com.couchbase.client.core.endpoint.BaseEndpoint)7 EmbeddedChannel (com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel)6 DefaultHttpResponse (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse)6 DefaultLastHttpContent (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent)6 HttpResponse (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse)6 Test (org.junit.jupiter.api.Test)6 Core (com.couchbase.client.core.Core)5 DefaultHttpContent (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent)5 HttpContent (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpContent)5 EndpointContext (com.couchbase.client.core.endpoint.EndpointContext)5 CoreEnvironment (com.couchbase.client.core.env.CoreEnvironment)5 CoreContext (com.couchbase.client.core.CoreContext)4 ByteBuf (com.couchbase.client.core.deps.io.netty.buffer.ByteBuf)4 Unpooled (com.couchbase.client.core.deps.io.netty.buffer.Unpooled)3 HttpRequest (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpRequest)3 HttpResponseStatus (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponseStatus)3 HttpVersion (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpVersion)3 ReferenceCountUtil (com.couchbase.client.core.deps.io.netty.util.ReferenceCountUtil)3 PasswordAuthenticator (com.couchbase.client.core.env.PasswordAuthenticator)3 BucketConfigStreamingRequest (com.couchbase.client.core.msg.manager.BucketConfigStreamingRequest)3