2b13d07aef7cd9e0f24c0eff1136dd391d76a75d
[appc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 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  * ============LICENSE_END=========================================================
22  */
23
24
25 package org.onap.appc.adapter.iaas.impl;
26
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertNull;
29 import static org.junit.Assert.assertTrue;
30 import java.util.Properties;
31 import org.junit.BeforeClass;
32 import org.junit.Test;
33 import org.onap.appc.adapter.iaas.impl.IdentityURL;
34 import org.onap.appc.configuration.ConfigurationFactory;
35
36 public class TestIdentityUrl {
37
38     private static String URL;
39
40     @BeforeClass
41     public static void before() {
42         Properties props = ConfigurationFactory.getConfiguration().getProperties();
43         URL = props.getProperty("");
44     }
45
46     /**
47      * Test that we can parse and interpret valid URLs
48      */
49     @Test
50     public void testValidURL1() {
51         URL = "http://192.168.1.1:5000/v2.0/";
52         IdentityURL idurl = IdentityURL.parseURL(URL);
53         assertNotNull(idurl);
54         assertTrue(idurl.getScheme().equals("http"));
55         assertTrue(idurl.getHost().equals("192.168.1.1"));
56         assertTrue(idurl.getPort().equals("5000"));
57         assertNull(idurl.getPath());
58         assertTrue(idurl.getVersion().equals("v2.0"));
59         assertTrue(idurl.toString().equals("http://192.168.1.1:5000/v2.0"));
60     }
61
62     @Test
63     public void testValidURL2() {
64         URL = "https://192.168.1.1:5000/v3/";
65         IdentityURL idurl = IdentityURL.parseURL(URL);
66         assertNotNull(idurl);
67         assertTrue(idurl.getScheme().equals("https"));
68         assertTrue(idurl.getHost().equals("192.168.1.1"));
69         assertTrue(idurl.getPort().equals("5000"));
70         assertNull(idurl.getPath());
71         assertTrue(idurl.getVersion().equals("v3"));
72         assertTrue(idurl.toString().equals("https://192.168.1.1:5000/v3"));
73     }
74
75     @Test
76     public void testValidURL3() {
77         URL = "http://192.168.1.1/v2.0/";
78         IdentityURL idurl = IdentityURL.parseURL(URL);
79         assertNotNull(idurl);
80         assertTrue(idurl.getScheme().equals("http"));
81         assertTrue(idurl.getHost().equals("192.168.1.1"));
82         assertNull(idurl.getPort());
83         assertNull(idurl.getPath());
84         assertTrue(idurl.getVersion().equals("v2.0"));
85         System.out.println(idurl.toString());
86         assertTrue(idurl.toString().equals("http://192.168.1.1/v2.0"));
87     }
88
89     @Test
90     public void testValidURL4() {
91         URL = "http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3";
92         IdentityURL idurl = IdentityURL.parseURL(URL);
93         assertNotNull(idurl);
94         assertTrue(idurl.getScheme().equals("http"));
95         assertTrue(idurl.getHost().equals("msb.onap.org"));
96         assertTrue(idurl.getPort().equals("80"));
97         assertTrue(idurl.getPath().equals("/api/multicloud/v0/cloudowner_region/identity"));
98         assertTrue(idurl.getVersion().equals("v3"));
99         assertTrue(idurl.toString().equals("http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3"));
100     }
101 }