Search in sources :

Example 1 with BucketConfigResponse

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);
}
Also used : BucketConfigResponse(com.couchbase.client.core.msg.manager.BucketConfigResponse) BucketConfigRequest(com.couchbase.client.core.msg.manager.BucketConfigRequest) Test(org.junit.jupiter.api.Test)

Example 2 with BucketConfigResponse

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);
}
Also used : TestNodeConfig(com.couchbase.client.test.TestNodeConfig) BucketConfigResponse(com.couchbase.client.core.msg.manager.BucketConfigResponse) BucketConfigRequest(com.couchbase.client.core.msg.manager.BucketConfigRequest) ClusterAwareIntegrationTest(com.couchbase.client.test.ClusterAwareIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with BucketConfigResponse

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());
}
Also used : BucketConfigResponse(com.couchbase.client.core.msg.manager.BucketConfigResponse) BucketConfigRequest(com.couchbase.client.core.msg.manager.BucketConfigRequest) Test(org.junit.jupiter.api.Test)

Aggregations

BucketConfigRequest (com.couchbase.client.core.msg.manager.BucketConfigRequest)3 BucketConfigResponse (com.couchbase.client.core.msg.manager.BucketConfigResponse)3 Test (org.junit.jupiter.api.Test)3 ClusterAwareIntegrationTest (com.couchbase.client.test.ClusterAwareIntegrationTest)1 TestNodeConfig (com.couchbase.client.test.TestNodeConfig)1