Search in sources :

Example 1 with CassandraServiceInfo

use of org.springframework.cloud.service.common.CassandraServiceInfo in project spring-cloud-connectors by spring-cloud.

the class CassandraServiceInfoCreatorTests method shouldCreateServiceInfoWithCredentials.

@Test
public void shouldCreateServiceInfoWithCredentials() throws Exception {
    CassandraServiceInfoCreator creator = new CassandraServiceInfoCreator();
    Map services = readServiceData("test-cassandra-with-credentials.json");
    Map<String, Object> serviceData = getServiceData(services, "p-dse-cassandra-acceptance");
    CassandraServiceInfo info = creator.createServiceInfo(serviceData);
    assertThat(info.getContactPoints(), hasItems("1.2.3.4"));
    assertThat(info.getPort(), is(equalTo(9042)));
    assertThat(info.getUsername(), is(equalTo("user")));
    assertThat(info.getPassword(), is(equalTo("pass")));
}
Also used : CassandraServiceInfo(org.springframework.cloud.service.common.CassandraServiceInfo) Map(java.util.Map) Test(org.junit.Test)

Example 2 with CassandraServiceInfo

use of org.springframework.cloud.service.common.CassandraServiceInfo in project spring-cloud-connectors by spring-cloud.

the class CassandraClusterCreatorTest method shouldCreateCluster.

@Test
public void shouldCreateCluster() throws Exception {
    CassandraServiceInfo info = new CassandraServiceInfo("local", Collections.singletonList("127.0.0.1"), 9142);
    Cluster cluster = creator.create(info, null);
    Configuration configuration = cluster.getConfiguration();
    assertThat(configuration.getProtocolOptions().getAuthProvider(), is(AuthProvider.NONE));
}
Also used : Configuration(com.datastax.driver.core.Configuration) CassandraServiceInfo(org.springframework.cloud.service.common.CassandraServiceInfo) Cluster(com.datastax.driver.core.Cluster) Test(org.junit.Test)

Example 3 with CassandraServiceInfo

use of org.springframework.cloud.service.common.CassandraServiceInfo in project spring-cloud-connectors by spring-cloud.

the class CassandraClusterCreatorTest method shouldCreateClusterWithAuthentication.

@Test
public void shouldCreateClusterWithAuthentication() throws Exception {
    CassandraServiceInfo info = new CassandraServiceInfo("local", Collections.singletonList("127.0.0.1"), 9142, "walter", "white");
    Cluster cluster = creator.create(info, null);
    Configuration configuration = cluster.getConfiguration();
    assertThat(configuration.getProtocolOptions().getAuthProvider(), is(instanceOf(PlainTextAuthProvider.class)));
}
Also used : Configuration(com.datastax.driver.core.Configuration) CassandraServiceInfo(org.springframework.cloud.service.common.CassandraServiceInfo) Cluster(com.datastax.driver.core.Cluster) Test(org.junit.Test)

Example 4 with CassandraServiceInfo

use of org.springframework.cloud.service.common.CassandraServiceInfo in project spring-cloud-connectors by spring-cloud.

the class CassandraClusterCreatorTest method shouldCreateClusterWithConfig.

@Test
public void shouldCreateClusterWithConfig() throws Exception {
    CassandraServiceInfo info = new CassandraServiceInfo("local", Collections.singletonList("127.0.0.1"), 9142);
    CassandraClusterConfig config = new CassandraClusterConfig();
    config.setCompression(ProtocolOptions.Compression.NONE);
    config.setPoolingOptions(new PoolingOptions().setPoolTimeoutMillis(1234));
    config.setQueryOptions(new QueryOptions());
    config.setProtocolVersion(ProtocolVersion.NEWEST_SUPPORTED);
    config.setLoadBalancingPolicy(new RoundRobinPolicy());
    config.setReconnectionPolicy(new ConstantReconnectionPolicy(1));
    config.setRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
    config.setSocketOptions(new SocketOptions());
    Cluster cluster = creator.create(info, config);
    Configuration configuration = cluster.getConfiguration();
    assertThat(configuration.getProtocolOptions().getCompression(), is(config.getCompression()));
    assertThat(configuration.getQueryOptions(), is(config.getQueryOptions()));
    assertThat(configuration.getSocketOptions(), is(config.getSocketOptions()));
    Policies policies = configuration.getPolicies();
    assertThat(policies.getLoadBalancingPolicy(), is(config.getLoadBalancingPolicy()));
    assertThat(policies.getReconnectionPolicy(), is(config.getReconnectionPolicy()));
    assertThat(policies.getRetryPolicy(), is(config.getRetryPolicy()));
}
Also used : Policies(com.datastax.driver.core.policies.Policies) Configuration(com.datastax.driver.core.Configuration) CassandraServiceInfo(org.springframework.cloud.service.common.CassandraServiceInfo) SocketOptions(com.datastax.driver.core.SocketOptions) PoolingOptions(com.datastax.driver.core.PoolingOptions) Cluster(com.datastax.driver.core.Cluster) QueryOptions(com.datastax.driver.core.QueryOptions) RoundRobinPolicy(com.datastax.driver.core.policies.RoundRobinPolicy) ConstantReconnectionPolicy(com.datastax.driver.core.policies.ConstantReconnectionPolicy) Test(org.junit.Test)

Example 5 with CassandraServiceInfo

use of org.springframework.cloud.service.common.CassandraServiceInfo in project spring-cloud-connectors by spring-cloud.

the class CassandraServiceInfoCreatorTests method shouldCreateServiceInfo.

@Test
public void shouldCreateServiceInfo() throws Exception {
    CassandraServiceInfoCreator creator = new CassandraServiceInfoCreator();
    Map services = readServiceData("test-cassandra-service.json");
    Map<String, Object> serviceData = getServiceData(services, "p-dse-cassandra-acceptance");
    CassandraServiceInfo info = creator.createServiceInfo(serviceData);
    assertThat(info.getContactPoints(), hasItems("1.2.3.4", "5.6.7.8"));
    assertThat(info.getPort(), is(equalTo(9042)));
    assertThat(info.getUsername(), is(nullValue()));
    assertThat(info.getPassword(), is(nullValue()));
}
Also used : CassandraServiceInfo(org.springframework.cloud.service.common.CassandraServiceInfo) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 CassandraServiceInfo (org.springframework.cloud.service.common.CassandraServiceInfo)5 Cluster (com.datastax.driver.core.Cluster)3 Configuration (com.datastax.driver.core.Configuration)3 Map (java.util.Map)2 PoolingOptions (com.datastax.driver.core.PoolingOptions)1 QueryOptions (com.datastax.driver.core.QueryOptions)1 SocketOptions (com.datastax.driver.core.SocketOptions)1 ConstantReconnectionPolicy (com.datastax.driver.core.policies.ConstantReconnectionPolicy)1 Policies (com.datastax.driver.core.policies.Policies)1 RoundRobinPolicy (com.datastax.driver.core.policies.RoundRobinPolicy)1