diff options
Diffstat (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test')
2 files changed, 79 insertions, 9 deletions
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java index be0535f64..1694529f4 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java @@ -26,6 +26,8 @@ package org.openecomp.appc.adapter.iaas.impl; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.util.Properties; @@ -48,10 +50,55 @@ public class TestIdentityUrl { * Test that we can parse and interpret valid URLs */ @Test - public void testValidURLs() { + public void testValidURL1() { URL = "http://192.168.1.1:5000/v2.0/"; IdentityURL idurl = IdentityURL.parseURL(URL); assertNotNull(idurl); - System.out.println(idurl.getVersion()); + assertTrue(idurl.getScheme().equals("http")); + assertTrue(idurl.getHost().equals("192.168.1.1")); + assertTrue(idurl.getPort().equals("5000")); + assertNull(idurl.getPath()); + assertTrue(idurl.getVersion().equals("v2.0")); + assertTrue(idurl.toString().equals("http://192.168.1.1:5000/v2.0")); + } + + @Test + public void testValidURL2() { + URL = "https://192.168.1.1:5000/v3/"; + IdentityURL idurl = IdentityURL.parseURL(URL); + assertNotNull(idurl); + assertTrue(idurl.getScheme().equals("https")); + assertTrue(idurl.getHost().equals("192.168.1.1")); + assertTrue(idurl.getPort().equals("5000")); + assertNull(idurl.getPath()); + assertTrue(idurl.getVersion().equals("v3")); + assertTrue(idurl.toString().equals("https://192.168.1.1:5000/v3")); + } + + @Test + public void testValidURL3() { + URL = "http://192.168.1.1/v2.0/"; + IdentityURL idurl = IdentityURL.parseURL(URL); + assertNotNull(idurl); + assertTrue(idurl.getScheme().equals("http")); + assertTrue(idurl.getHost().equals("192.168.1.1")); + assertNull(idurl.getPort()); + assertNull(idurl.getPath()); + assertTrue(idurl.getVersion().equals("v2.0")); + System.out.println(idurl.toString()); + assertTrue(idurl.toString().equals("http://192.168.1.1/v2.0")); + } + + @Test + public void testValidURL4() { + URL = "http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3"; + IdentityURL idurl = IdentityURL.parseURL(URL); + assertNotNull(idurl); + assertTrue(idurl.getScheme().equals("http")); + assertTrue(idurl.getHost().equals("msb.onap.org")); + assertTrue(idurl.getPort().equals("80")); + assertTrue(idurl.getPath().equals("/api/multicloud/v0/cloudowner_region/identity")); + assertTrue(idurl.getVersion().equals("v3")); + assertTrue(idurl.toString().equals("http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3")); } } diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java index 2173d5c74..c1434273d 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java @@ -27,6 +27,7 @@ package org.openecomp.appc.adapter.iaas.impl; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import java.util.Properties; @@ -46,18 +47,19 @@ public class TestVMURL { @BeforeClass public static void before() { - IP = "192.168.1.2"; - PORT = "5000"; - TENANTID = "abcde12345fghijk6789lmnopq123rst"; - VMID = "abc12345-1234-5678-890a-abcdefg12345"; - URL = String.format("http://%s:%s/v2/%s/servers/%s", IP, PORT, TENANTID, VMID); + Properties props = ConfigurationFactory.getConfiguration().getProperties(); + IP = props.getProperty("test.ip"); + PORT = props.getProperty("test.port"); + TENANTID = props.getProperty("test.tenantid"); + VMID = props.getProperty("test.vmid"); } /** * Test that we can parse and interpret valid URLs */ @Test - public void testValidURLs() { + public void testValidURL1() { + URL = String.format("http://%s:%s/v2/%s/servers/%s", IP, PORT, TENANTID, VMID); VMURL url = VMURL.parseURL(URL); assertEquals("http", url.getScheme()); @@ -65,13 +67,34 @@ public class TestVMURL { assertEquals(PORT, url.getPort()); assertEquals(TENANTID, url.getTenantId()); assertEquals(VMID, url.getServerId()); + assertEquals(url.toString(), URL); + } - url = VMURL.parseURL(String.format("http://%s/v2/%s/servers/%s", IP, TENANTID, VMID)); + @Test + public void testValidURL2() { + URL = String.format("http://%s/v2/%s/servers/%s", IP, TENANTID, VMID); + VMURL url = VMURL.parseURL(URL); assertEquals("http", url.getScheme()); assertEquals(IP, url.getHost()); assertNull(url.getPort()); + assertNull(url.getPath()); + assertEquals(TENANTID, url.getTenantId()); + assertEquals(VMID, url.getServerId()); + assertEquals(url.toString(), URL); + } + + @Test + public void testValidURL3() { + URL = "http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345"; + VMURL url = VMURL.parseURL(URL); + assertNotNull(url); + assertEquals("http", url.getScheme()); + assertEquals("msb.onap.org", url.getHost()); + assertEquals("80", url.getPort()); + assertEquals("/api/multicloud/v0/cloudowner_region", url.getPath()); assertEquals(TENANTID, url.getTenantId()); assertEquals(VMID, url.getServerId()); + assertEquals(url.toString(), URL); } /** |