2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * ============LICENSE_END=========================================================
25 package org.onap.appc.adapter.iaas.impl;
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;
36 public class TestIdentityUrl {
38 private static String URL;
41 public static void before() {
42 Properties props = ConfigurationFactory.getConfiguration().getProperties();
43 URL = props.getProperty("");
47 * Test that we can parse and interpret valid URLs
50 public void testValidURL1() {
51 URL = "http://192.168.1.1:5000/v2.0/";
52 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));
63 public void testValidURL2() {
64 URL = "https://192.168.1.1:5000/v3/";
65 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));
76 public void testValidURL3() {
77 URL = "http://192.168.1.1/v2.0/";
78 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));
90 public void testValidURL4() {
91 URL = "http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3";
92 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));