summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/CassandraConfigurationManagerTest.java
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2021-06-04 17:49:31 +0200
committerAndr� Schmid <andre.schmid@est.tech>2021-06-09 17:48:27 +0000
commit3fdd800133ad5f07aadc90f9731cca28e96896d9 (patch)
treec35caa9fbd5b529fd4e1e12fbf8708eb1e6d2830 /openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/CassandraConfigurationManagerTest.java
parentc65578b5c01651975d218d81e0f4856746641298 (diff)
Create a common ConfigurationManager class
Create a common ConfigurationManager class as some classes have the same logic Issue-ID: SDC-3616 Signed-off-by: sebdet <sebastien.determe@intl.att.com> Change-Id: I44aeb3a4baf45753c3c43f7b4d202253ae4186eb
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/CassandraConfigurationManagerTest.java')
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/CassandraConfigurationManagerTest.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/CassandraConfigurationManagerTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/CassandraConfigurationManagerTest.java
new file mode 100644
index 0000000000..021f1c715b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/CassandraConfigurationManagerTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ * ================================================================================
+ * Modifications Copyright (C) 2021 AT&T.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.core.nosqldb.util;
+
+import java.io.FileNotFoundException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * @author EVITALIY
+ * @since 22 Oct 17
+ */
+public class CassandraConfigurationManagerTest {
+
+ private static final String NON_EXISTENT = "unexistentfile";
+
+ @AfterEach
+ public void resetSystemVar() {
+ System.clearProperty(CassandraConfigurationManager.JVM_PARAM_CONFIGURATION_FILE);
+ }
+
+ @Test
+ public void testGetInstanceSystemProperty() throws Throwable {
+ System.setProperty(CassandraConfigurationManager.JVM_PARAM_CONFIGURATION_FILE, NON_EXISTENT);
+ RuntimeException e = Assertions.assertThrows(RuntimeException.class,()-> {
+ CassandraConfigurationManager.getInstance();
+ });
+ Assertions.assertTrue(e.getCause() instanceof FileNotFoundException);
+ Assertions.assertEquals("Failed to read configuration unexistentfile",e.getMessage());
+ }
+
+ @Test()
+ public void testGetInstanceDefault() {
+ // Do not set the JVM param for config file, by default code will get it from Resource
+ CassandraConfigurationManager manager = CassandraConfigurationManager.getInstance();
+ Assertions.assertArrayEquals(new String[] {"127.0.0.1"}, manager.getAddresses());
+ Assertions.assertEquals(9042, manager.getCassandraPort());
+ Assertions.assertEquals("dox", manager.getKeySpace());
+ Assertions.assertEquals("LOCAL_QUORUM", manager.getConsistencyLevel());
+ Assertions.assertEquals(null, manager.getLocalDataCenter());
+ Assertions.assertEquals("Aa1234%^!", manager.getPassword());
+ Assertions.assertEquals(30000L, manager.getReconnectTimeout().longValue());
+ Assertions.assertEquals("/path/path", manager.getTruststorePath());
+ Assertions.assertEquals("Aa123456", manager.getTruststorePassword());
+ Assertions.assertFalse(manager.isSsl());
+ Assertions.assertFalse(manager.isAuthenticate());
+ }
+}