aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-05-09 03:55:30 -0700
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-05-09 05:18:51 -0700
commitb1e5734ef566af5d49ba17d05ca0ab7b56d6666d (patch)
tree92a232e908ae587cb244fd102e9c2c5648c66a9f /adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java
parentd4f2190943216278826f39e7010d57f872bda90d (diff)
[MSO-8] Additional fixes for the second rebase
DB fixes + BPMN flows and groovy fixes + Fix issue with CloudConfig file not reloaded properly when it's wrong (JSON error or model hierarchy mistake) at MSO startup Change-Id: I2853030b78499e2a761706b643ea210955e72de3 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com> [MSO-8] Restore files removed in patch set 2 Those groovy files must be there Change-Id: I9a47ac3d9c8fc06774a1b8f518491b1b0b00af04 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java')
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java41
1 files changed, 38 insertions, 3 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java
index 6be668c..03771e7 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java
@@ -24,13 +24,17 @@ package org.openecomp.mso.adapter_utils.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import org.junit.BeforeClass;
+
+import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import java.util.Map;
import org.openecomp.mso.cloud.CloudConfig;
import org.openecomp.mso.cloud.CloudConfigFactory;
import org.openecomp.mso.cloud.CloudIdentity;
import org.openecomp.mso.cloud.CloudSite;
+import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
+
/**
@@ -50,9 +54,10 @@ public class CloudConfigTest {
/**
* This method is called before any test occurs.
* It creates a fake tree from scratch
+ * @throws MsoCloudIdentityNotFound
*/
- @BeforeClass
- public static final void prepare () {
+ @Before
+ public final void prepare () throws MsoCloudIdentityNotFound {
ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
String config = classLoader.getResource("cloud_config.json").toString().substring(5);
@@ -168,5 +173,35 @@ public class CloudConfigTest {
CloudIdentity identity2 = con.getIdentityService("Test");
assertNull(identity2);
}
+
+ @Test (expected = MsoCloudIdentityNotFound.class)
+ public final void testLoadWithWrongFile () throws MsoCloudIdentityNotFound {
+ ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
+ String config = classLoader.getResource("cloud_config_bad.json").toString().substring(5);
+
+ cloudConfigFactory.initializeCloudConfig(config,1);
+ }
+
+ @Test
+ public final void testReloadWithWrongFile () {
+ ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
+ String config = classLoader.getResource("cloud_config_bad.json").toString().substring(5);
+
+ try {
+ cloudConfigFactory.initializeCloudConfig(config,1);
+ Assert.fail("MsoCloudIdentityNotFound was expected");
+ } catch (MsoCloudIdentityNotFound e) {
+
+ }
+ Assert.assertTrue("Should be an empty CloudConfig", cloudConfigFactory.getCloudConfig().getCloudSites().isEmpty());
+ Assert.assertTrue("Should be an empty CloudConfig", cloudConfigFactory.getCloudConfig().getIdentityServices().isEmpty());
+
+ // Now reload the right config
+ config = classLoader.getResource("cloud_config.json").toString().substring(5);
+ cloudConfigFactory.changeMsoPropertiesFilePath(config);
+ cloudConfigFactory.reloadCloudConfig();
+ Assert.assertTrue("Flag valid Config should be true now that the cloud_config is correct", cloudConfigFactory.getCloudConfig().isValidCloudConfig());
+
+ }
}