dac22eadba2d8fb40a5f0a4a2b96fab7cb7e841a
[appc.git] / appc-adapters / appc-iaas-adapter / appc-iaas-adapter-bundle / src / test / java / org / openecomp / appc / adapter / iaas / impl / TestIdentityUrl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25
26 package org.onap.appc.adapter.iaas.impl;
27
28 import static org.junit.Assert.assertNotNull;
29 import static org.junit.Assert.assertNull;
30 import static org.junit.Assert.assertTrue;
31 import java.util.Properties;
32 import org.junit.BeforeClass;
33 import org.junit.Test;
34 import org.onap.appc.adapter.iaas.impl.IdentityURL;
35 import org.onap.appc.configuration.ConfigurationFactory;
36
37 public class TestIdentityUrl {
38
39     private static String URL;
40
41     @BeforeClass
42     public static void before() {
43         Properties props = ConfigurationFactory.getConfiguration().getProperties();
44         URL = props.getProperty("");
45     }
46
47     /**
48      * Test that we can parse and interpret valid URLs
49      */
50     @Test
51     public void testValidURL1() {
52         URL = "http://192.168.1.1:5000/v2.0/";
53         IdentityURL idurl = IdentityURL.parseURL(URL);
54         assertNotNull(idurl);
55         assertTrue(idurl.getScheme().equals("http"));
56         assertTrue(idurl.getHost().equals("192.168.1.1"));
57         assertTrue(idurl.getPort().equals("5000"));
58         assertNull(idurl.getPath());
59         assertTrue(idurl.getVersion().equals("v2.0"));
60         assertTrue(idurl.toString().equals("http://192.168.1.1:5000/v2.0"));
61     }
62
63     @Test
64     public void testValidURL2() {
65         URL = "https://192.168.1.1:5000/v3/";
66         IdentityURL idurl = IdentityURL.parseURL(URL);
67         assertNotNull(idurl);
68         assertTrue(idurl.getScheme().equals("https"));
69         assertTrue(idurl.getHost().equals("192.168.1.1"));
70         assertTrue(idurl.getPort().equals("5000"));
71         assertNull(idurl.getPath());
72         assertTrue(idurl.getVersion().equals("v3"));
73         assertTrue(idurl.toString().equals("https://192.168.1.1:5000/v3"));
74     }
75
76     @Test
77     public void testValidURL3() {
78         URL = "http://192.168.1.1/v2.0/";
79         IdentityURL idurl = IdentityURL.parseURL(URL);
80         assertNotNull(idurl);
81         assertTrue(idurl.getScheme().equals("http"));
82         assertTrue(idurl.getHost().equals("192.168.1.1"));
83         assertNull(idurl.getPort());
84         assertNull(idurl.getPath());
85         assertTrue(idurl.getVersion().equals("v2.0"));
86         System.out.println(idurl.toString());
87         assertTrue(idurl.toString().equals("http://192.168.1.1/v2.0"));
88     }
89
90     @Test
91     public void testValidURL4() {
92         URL = "http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3";
93         IdentityURL idurl = IdentityURL.parseURL(URL);
94         assertNotNull(idurl);
95         assertTrue(idurl.getScheme().equals("http"));
96         assertTrue(idurl.getHost().equals("msb.onap.org"));
97         assertTrue(idurl.getPort().equals("80"));
98         assertTrue(idurl.getPath().equals("/api/multicloud/v0/cloudowner_region/identity"));
99         assertTrue(idurl.getVersion().equals("v3"));
100         assertTrue(idurl.toString().equals("http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3"));
101     }
102 }