From c4d387d216e72911f80c1ebee91b73aba191b91b Mon Sep 17 00:00:00 2001 From: Tal Gitelman Date: Thu, 28 Mar 2019 11:00:54 +0200 Subject: Make Cassandra port configurable. SDC-BE & Onboarding - BE. Reviewer: Evgenia A & Areli F. Change-Id: Iaf86d647b0560764ef65d9148c85bffaf934992d Issue-ID: SDC-2077 Signed-off-by: Tal Gitelman --- .../be/dao/cassandra/schema/SdcSchemaUtilsTest.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'catalog-dao/src/test/java') diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtilsTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtilsTest.java index ca8bdea30a..39a19641f0 100644 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtilsTest.java +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtilsTest.java @@ -37,6 +37,7 @@ public class SdcSchemaUtilsTest { private static final String SINGLE_STATEMENT = "SELECT COUNT(*) FROM system.peers"; private static final String[] MULTIPLE_STATEMENTS = new String[] {SINGLE_STATEMENT, SINGLE_STATEMENT}; private static final List CASSANDRA_HOSTS = Collections.singletonList(CassandraTestHelper.SERVER); + private static final Integer CASSANDRA_PORT = 9042; private static final String CASSANDRA_USERNAME = "username"; private static final String CASSANDRA_PASSWORD = "password"; private static final String TRUSTSTORE_PATH = "pathToTruststore"; @@ -80,6 +81,7 @@ public class SdcSchemaUtilsTest { public void testCreateClusterNoAuthNoSsl() { Configuration.CassandrConfig cfg = new Configuration.CassandrConfig(); cfg.setCassandraHosts(CASSANDRA_HOSTS); + cfg.setCassandraPort(CASSANDRA_PORT); SdcSchemaUtils sdcSchemaUtils = Mockito.mock(SdcSchemaUtils.class); when(sdcSchemaUtils.getCassandraConfig()).thenReturn(cfg); @@ -104,11 +106,27 @@ public class SdcSchemaUtilsTest { } } + @Test + public void testCreateClusterWithDefaultOnLackOfCassandraPort() { + Configuration.CassandrConfig cfg = new Configuration.CassandrConfig(); + cfg.setCassandraHosts(CASSANDRA_HOSTS); + cfg.setCassandraPort(null); + + SdcSchemaUtils sdcSchemaUtils = Mockito.mock(SdcSchemaUtils.class); + when(sdcSchemaUtils.getCassandraConfig()).thenReturn(cfg); + when(sdcSchemaUtils.createCluster()).thenCallRealMethod(); + + try(Cluster cluster = sdcSchemaUtils.createCluster()) { + Assert.assertNotNull(cluster); + } + } + @Test public void testCreateClusterFailOnAuthEnabledWithNoCredentials() { Configuration.CassandrConfig cfg = new Configuration.CassandrConfig(); cfg.setAuthenticate(true); cfg.setCassandraHosts(CASSANDRA_HOSTS); + cfg.setCassandraPort(CASSANDRA_PORT); cfg.setUsername(null); cfg.setPassword(null); @@ -125,6 +143,7 @@ public class SdcSchemaUtilsTest { public void testCreateClusterFailOnSSLWithNoCredentials() { Configuration.CassandrConfig cfg = new Configuration.CassandrConfig(); cfg.setCassandraHosts(CASSANDRA_HOSTS); + cfg.setCassandraPort(CASSANDRA_PORT); cfg.setSsl(true); cfg.setTruststorePath(null); cfg.setTruststorePassword(null); @@ -143,6 +162,7 @@ public class SdcSchemaUtilsTest { Configuration.CassandrConfig cfg = new Configuration.CassandrConfig(); cfg.setAuthenticate(true); cfg.setCassandraHosts(CASSANDRA_HOSTS); + cfg.setCassandraPort(CASSANDRA_PORT); cfg.setUsername(CASSANDRA_USERNAME); cfg.setPassword(CASSANDRA_PASSWORD); cfg.setSsl(true); -- cgit 1.2.3-korg