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=========================================================
24 package org.onap.appc.adapter.iaas.impl;
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;
34 public class TestIdentityUrl {
36 private static String URL;
39 public static void before() {
40 Properties props = ConfigurationFactory.getConfiguration().getProperties();
41 URL = props.getProperty("");
45 * Test that we can parse and interpret valid URLs
48 public void testValidURL1() {
49 URL = "http://192.168.1.1:5000/v2.0/";
50 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));
61 public void testValidURL2() {
62 URL = "https://192.168.1.1:5000/v3/";
63 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));
74 public void testValidURL3() {
75 URL = "http://192.168.1.1/v2.0/";
76 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));
88 public void testValidURL4() {
89 URL = "http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3";
90 IdentityURL idurl = IdentityURL.parseURL(URL);
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"));