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