use of com.couchbase.client.core.error.RequestCanceledException in project couchbase-jvm-clients by couchbase.
the class ReactorTest method completesWithErrorBeforeSubscription.
@Test
void completesWithErrorBeforeSubscription() {
NoopRequest request = new NoopRequest(Duration.ZERO, mock(RequestContext.class), mock(RetryStrategy.class), mock(CollectionIdentifier.class));
RequestCanceledException exception = mock(RequestCanceledException.class);
request.fail(exception);
Mono<NoopResponse> mono = Reactor.wrap(request, request.response(), true);
StepVerifier verifier = StepVerifier.create(mono).expectError(RequestCanceledException.class);
verifier.verify();
}
use of com.couchbase.client.core.error.RequestCanceledException in project couchbase-jvm-clients by couchbase.
the class ReactorTest method noErrorDroppedWhenCancelledViaCompletionException.
@Test
void noErrorDroppedWhenCancelledViaCompletionException() {
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 multi-step CompleteableFuture, the RequestCanceledException will be wrapped in a
// CompletionException in the internals. It will be unwrapped by the time it is raised to the app.
Mono<NoopResponse> mono = Reactor.wrap(request, request.response().thenApply(v -> v), true);
Disposable subscriber = mono.subscribe();
StepVerifier verifier = StepVerifier.create(mono).expectError(RequestCanceledException.class);
subscriber.dispose();
verifier.verify();
assertEquals(0, droppedErrors.get());
}
Aggregations