Search in sources :

Example 11 with NoopResponse

use of com.couchbase.client.core.msg.kv.NoopResponse in project couchbase-jvm-clients by couchbase.

the class ReactorTest method noErrorDroppedWhenCancelledViaRequestCanceledException.

@Test
void noErrorDroppedWhenCancelledViaRequestCanceledException() {
    AtomicInteger droppedErrors = new AtomicInteger(0);
    Hooks.onErrorDropped(v -> {
        droppedErrors.incrementAndGet();
    });
    NoopRequest request = new NoopRequest(Duration.ZERO, mock(RequestContext.class), mock(RetryStrategy.class), mock(CollectionIdentifier.class));
    // Because this is a single-stage CompleteableFuture, the RequestCanceledException will raised directly in the
    // internals.
    Mono<NoopResponse> mono = Reactor.wrap(request, request.response(), true);
    Disposable subscriber = mono.subscribe();
    StepVerifier verifier = StepVerifier.create(mono).expectError(RequestCanceledException.class);
    subscriber.dispose();
    verifier.verify();
    assertEquals(0, droppedErrors.get());
}
Also used : NoopRequest(com.couchbase.client.core.msg.kv.NoopRequest) NoopResponse(com.couchbase.client.core.msg.kv.NoopResponse) Disposable(reactor.core.Disposable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RequestContext(com.couchbase.client.core.msg.RequestContext) StepVerifier(reactor.test.StepVerifier) RetryStrategy(com.couchbase.client.core.retry.RetryStrategy) CollectionIdentifier(com.couchbase.client.core.io.CollectionIdentifier) Test(org.junit.jupiter.api.Test)

Aggregations

NoopRequest (com.couchbase.client.core.msg.kv.NoopRequest)11 NoopResponse (com.couchbase.client.core.msg.kv.NoopResponse)11 Test (org.junit.jupiter.api.Test)11 CollectionIdentifier (com.couchbase.client.core.io.CollectionIdentifier)8 RequestContext (com.couchbase.client.core.msg.RequestContext)8 RetryStrategy (com.couchbase.client.core.retry.RetryStrategy)8 StepVerifier (reactor.test.StepVerifier)6 RequestCanceledException (com.couchbase.client.core.error.RequestCanceledException)3 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)3 TestNodeConfig (com.couchbase.client.test.TestNodeConfig)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Disposable (reactor.core.Disposable)2 Bootstrap (com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap)1 Channel (com.couchbase.client.core.deps.io.netty.channel.Channel)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 CancellationReason (com.couchbase.client.core.msg.CancellationReason)1 Util.waitUntilCondition (com.couchbase.client.test.Util.waitUntilCondition)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1