use of com.couchbase.client.core.msg.manager.BucketConfigResponse in project couchbase-jvm-clients by couchbase.
the class ClusterManagerBucketLoaderTest method loadsConfigSuccessfully.
@Test
void loadsConfigSuccessfully() {
byte[] expectedConfig = "config".getBytes(UTF_8);
BucketConfigResponse response = mock(BucketConfigResponse.class);
when(response.status()).thenReturn(ResponseStatus.SUCCESS);
when(response.config()).thenReturn(expectedConfig);
doAnswer(i -> {
((BucketConfigRequest) i.getArgument(0)).succeed(response);
return null;
}).when(core).send(any(BucketConfigRequest.class));
byte[] config = loader.discoverConfig(SEED, BUCKET).block();
assertArrayEquals(expectedConfig, config);
}
use of com.couchbase.client.core.msg.manager.BucketConfigResponse in project couchbase-jvm-clients by couchbase.
the class ManagerEndpointIntegrationTest method fetchTerseConfig.
/**
* This integration test attempts to load a "terse" bucket config from the cluster manager.
*
* <p>Note that the actual response is not checked here, since this handles at the higher levels. We just make sure
* that the config returned is not empty.</p>
*/
@Test
void fetchTerseConfig() throws Exception {
TestNodeConfig node = config().nodes().get(0);
ManagerEndpoint endpoint = new ManagerEndpoint(serviceContext, node.hostname(), node.ports().get(Services.MANAGER));
endpoint.connect();
waitUntilCondition(() -> endpoint.state() == EndpointState.CONNECTED);
BucketConfigRequest request = new BucketConfigRequest(Duration.ofSeconds(1), serviceContext, null, config().bucketname(), serviceContext.authenticator(), null);
assertTrue(request.id() > 0);
endpoint.send(request);
BucketConfigResponse response = request.response().get(1, TimeUnit.SECONDS);
assertTrue(response.status().success());
assertTrue(response.config().length > 0);
endpoint.disconnect();
waitUntilCondition(() -> endpoint.state() == EndpointState.DISCONNECTED);
}
use of com.couchbase.client.core.msg.manager.BucketConfigResponse in project couchbase-jvm-clients by couchbase.
the class ClusterManagerBucketLoaderTest method errorsIfNonSuccessful.
@Test
void errorsIfNonSuccessful() {
BucketConfigResponse response = mock(BucketConfigResponse.class);
when(response.status()).thenReturn(ResponseStatus.UNKNOWN);
doAnswer(i -> {
((BucketConfigRequest) i.getArgument(0)).succeed(response);
return null;
}).when(core).send(any(BucketConfigRequest.class));
assertThrows(ConfigException.class, () -> loader.discoverConfig(SEED, BUCKET).block());
}
Aggregations