summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test/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
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')
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java41
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java3
2 files changed, 40 insertions, 4 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 6be668c056..03771e7667 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());
+
+ }
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java
index 3427e42304..b620ddc192 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java
@@ -27,6 +27,7 @@ import org.junit.Test;
import org.openecomp.mso.cloud.CloudConfigFactory;
import org.openecomp.mso.openstack.exceptions.MsoAdapterException;
+import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
import org.openecomp.mso.openstack.exceptions.MsoException;
import org.openecomp.mso.openstack.exceptions.MsoIOException;
@@ -49,7 +50,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils {
public static MsoHeatUtils msoHeatUtils;
@BeforeClass
- public static final void loadClasses() {
+ public static final void loadClasses() throws MsoCloudIdentityNotFound {
ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
String config = classLoader.getResource("cloud_config.json").toString().substring(5);
cloudConfigFactory.initializeCloudConfig(config, 1);