use of com.couchbase.client.core.msg.kv.NoopResponse in project couchbase-jvm-clients by couchbase.
the class ReactorTest method propagatesCancellation.
@Test
void propagatesCancellation() {
NoopRequest request = new NoopRequest(Duration.ZERO, mock(RequestContext.class), mock(RetryStrategy.class), mock(CollectionIdentifier.class));
Mono<NoopResponse> mono = Reactor.wrap(request, request.response(), true);
assertThrows(Exception.class, () -> mono.timeout(Duration.ofMillis(10)).block());
assertTrue(request.response().isCompletedExceptionally());
assertTrue(request.response().isDone());
}
use of com.couchbase.client.core.msg.kv.NoopResponse in project couchbase-jvm-clients by couchbase.
the class ReactorTest method completesWithErrorAfterSubscription.
@Test
void completesWithErrorAfterSubscription() {
NoopRequest request = new NoopRequest(Duration.ZERO, mock(RequestContext.class), mock(RetryStrategy.class), mock(CollectionIdentifier.class));
Mono<NoopResponse> mono = Reactor.wrap(request, request.response(), true);
RequestCanceledException exception = mock(RequestCanceledException.class);
StepVerifier verifier = StepVerifier.create(mono).expectError(RequestCanceledException.class);
request.fail(exception);
verifier.verify();
}
use of com.couchbase.client.core.msg.kv.NoopResponse in project couchbase-jvm-clients by couchbase.
the class ReactorTest method completesWithSuccessAfterSubscription.
@Test
void completesWithSuccessAfterSubscription() {
NoopRequest request = new NoopRequest(Duration.ZERO, mock(RequestContext.class), mock(RetryStrategy.class), mock(CollectionIdentifier.class));
Mono<NoopResponse> mono = Reactor.wrap(request, request.response(), true);
NoopResponse response = mock(NoopResponse.class);
StepVerifier verifier = StepVerifier.create(mono).expectNext(response).expectComplete();
request.succeed(response);
verifier.verify();
}
use of com.couchbase.client.core.msg.kv.NoopResponse in project couchbase-jvm-clients by couchbase.
the class KeyValueServiceIntegrationTest method connectNoopAndDisconnect.
/**
* The most simplistic end-to-end test for a KV service.
*
* <p>This integration test connects to a node and then performs a NOOP and
* waits for a successful response.</p>
*
* @throws Exception if waiting on the response fails.
*/
@Test
void connectNoopAndDisconnect() throws Exception {
TestNodeConfig node = config().nodes().get(0);
KeyValueService service = new KeyValueService(KeyValueServiceConfig.builder().build(), core.context(), node.hostname(), node.ports().get(Services.KV), Optional.of(config().bucketname()), core.context().authenticator());
service.connect();
waitUntilCondition(() -> service.state() == ServiceState.CONNECTED);
NoopRequest request = new NoopRequest(kvTimeout, core.context(), null, CollectionIdentifier.fromDefault(config().bucketname()));
assertTrue(request.id() > 0);
service.send(request);
NoopResponse response = request.response().get(1, TimeUnit.SECONDS);
assertTrue(response.status().success());
assertTrue(request.context().dispatchLatency() > 0);
service.disconnect();
waitUntilCondition(() -> service.state() == ServiceState.DISCONNECTED);
}
use of com.couchbase.client.core.msg.kv.NoopResponse in project couchbase-jvm-clients by couchbase.
the class KeyValueEndpointIntegrationTest method connectNoopAndDisconnect.
/**
* The most simplistic end-to-end test for a KV endpoint.
*
* <p>This integration test connects to a node and then performs a NOOP and
* waits for a successful response.</p>
*
* @throws Exception if waiting on the response fails.
*/
@Test
void connectNoopAndDisconnect() throws Exception {
TestNodeConfig node = config().nodes().get(0);
KeyValueEndpoint endpoint = new KeyValueEndpoint(serviceContext, node.hostname(), node.ports().get(Services.KV), Optional.of(config().bucketname()), authenticator());
endpoint.connect();
waitUntilCondition(() -> endpoint.state() == EndpointState.CONNECTED);
NoopRequest request = new NoopRequest(kvTimeout, serviceContext, null, CollectionIdentifier.fromDefault(config().bucketname()));
assertTrue(request.id() > 0);
endpoint.send(request);
NoopResponse response = request.response().get(1, TimeUnit.SECONDS);
assertTrue(response.status().success());
assertTrue(request.context().dispatchLatency() > 0);
endpoint.disconnect();
waitUntilCondition(() -> endpoint.state() == EndpointState.DISCONNECTED);
}
Aggregations