2 * ============LICENSE_START=======================================================
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
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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
26 package org.onap.appc.adapter.iaas.impl;
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;
37 public class TestIdentityUrl {
39 private static String URL;
42 public static void before() {
43 Properties props = ConfigurationFactory.getConfiguration().getProperties();
44 URL = props.getProperty("");
48 * Test that we can parse and interpret valid URLs
51 public void testValidURL1() {
52 URL = "http://192.168.1.1:5000/v2.0/";
53 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));
64 public void testValidURL2() {
65 URL = "https://192.168.1.1:5000/v3/";
66 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));
77 public void testValidURL3() {
78 URL = "http://192.168.1.1/v2.0/";
79 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));
91 public void testValidURL4() {
92 URL = "http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3";
93 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));