use of com.couchbase.client.core.msg.kv.NoopResponse in project couchbase-jvm-clients by couchbase.
the class KeyValueChannelIntegrationTest method connectNoopAndDisconnect.
/**
* This is the most simple kv test case one can do in a full-stack manner.
*
* <p>It connects to a kv socket, including all auth and bucket selection. It then
* checks that the channel is opened properly and performs a NOOP and checks for a
* successful result. Then it shuts everything down.</p>
*
* @throws Exception if waiting on the response fails.
*/
@Test
void connectNoopAndDisconnect() throws Exception {
TestNodeConfig node = config().nodes().get(0);
Bootstrap bootstrap = new Bootstrap().remoteAddress(node.hostname(), node.ports().get(Services.KV)).group(eventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
new KeyValueEndpoint.KeyValuePipelineInitializer(endpointContext, Optional.of(config().bucketname()), endpointContext.authenticator()).init(null, ch.pipeline());
}
});
Channel channel = bootstrap.connect().awaitUninterruptibly().channel();
assertTrue(channel.isActive());
assertTrue(channel.isOpen());
NoopRequest request = new NoopRequest(Duration.ZERO, endpointContext, null, CollectionIdentifier.fromDefault(config().bucketname()));
channel.writeAndFlush(request);
NoopResponse response = request.response().get(1, TimeUnit.SECONDS);
assertTrue(response.status().success());
channel.close().awaitUninterruptibly();
}
use of com.couchbase.client.core.msg.kv.NoopResponse 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.msg.kv.NoopResponse 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());
}
use of com.couchbase.client.core.msg.kv.NoopResponse in project couchbase-jvm-clients by couchbase.
the class ReactorTest method completesWithSuccessBeforeSubscription.
@Test
void completesWithSuccessBeforeSubscription() {
NoopRequest request = new NoopRequest(Duration.ZERO, mock(RequestContext.class), mock(RetryStrategy.class), mock(CollectionIdentifier.class));
NoopResponse response = mock(NoopResponse.class);
request.succeed(response);
Mono<NoopResponse> mono = Reactor.wrap(request, request.response(), true);
StepVerifier verifier = StepVerifier.create(mono).expectNext(response).expectComplete();
verifier.verify();
}
use of com.couchbase.client.core.msg.kv.NoopResponse in project couchbase-jvm-clients by couchbase.
the class ReactorTest method ignoresCancellationPropagation.
@Test
void ignoresCancellationPropagation() {
NoopRequest request = new NoopRequest(Duration.ZERO, mock(RequestContext.class), mock(RetryStrategy.class), mock(CollectionIdentifier.class));
Mono<NoopResponse> mono = Reactor.wrap(request, request.response(), false);
assertThrows(Exception.class, () -> mono.timeout(Duration.ofMillis(10)).block());
assertFalse(request.response().isCompletedExceptionally());
assertFalse(request.response().isDone());
}
Aggregations