diff options
Diffstat (limited to 'adapters/mso-adapter-utils/src/test/java/org')
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); |