2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.cloud.servertype;
\r
23 import static org.junit.Assert.assertEquals;
\r
24 import static org.junit.Assert.assertNotNull;
\r
25 import static org.junit.Assert.fail;
\r
27 import org.junit.Ignore;
\r
28 import org.junit.Test;
\r
29 import org.openecomp.mso.cloud.CloudIdentity;
\r
30 import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
\r
31 import org.openecomp.mso.cloud.IdentityServerTypeAbstract;
\r
32 import org.openecomp.mso.openstack.exceptions.MsoException;
\r
34 public class ServerTypeTest {
\r
37 @Ignore // IGNORED FOR 1710 MERGE TO ONAP
\r
38 public void testKeystoneServerType() {
\r
39 IdentityServerTypeAbstract keystoneServerType = IdentityServerType.valueOf("KEYSTONE");
\r
40 assertNotNull(keystoneServerType);
\r
44 public void testNewServerType() {
\r
45 IdentityServerTypeAbstract customServerType = null;
\r
47 customServerType = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
\r
49 } catch (IllegalArgumentException e) {
\r
50 fail("An exception should not be raised when we register a new server type for the first time");
\r
52 System.out.println(IdentityServerType.values().toString());
\r
53 assertEquals(customServerType, IdentityServerType.valueOf("NewServerType"));
\r
56 // Create it a second time
\r
57 IdentityServerTypeAbstract customServerType2 = null;
\r
59 customServerType2 = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
\r
60 fail("An exception should be raised as server type does not exist");
\r
61 } catch (IllegalArgumentException e) {
\r
62 // Fail silently -- it simply indicates we already registered it
\r
63 customServerType2 = IdentityServerType.valueOf("NewServerType");
\r
65 System.out.println(IdentityServerType.values().toString());
\r
66 assertEquals(customServerType2, IdentityServerType.valueOf("NewServerType"));
\r
69 // Check the KeystoneURL for this custom TenantUtils
\r
70 CloudIdentity cloudIdentity = new CloudIdentity();
\r
71 cloudIdentity.setIdentityUrl("LocalIdentity");
\r
72 cloudIdentity.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
\r
73 cloudIdentity.setIdentityServerType((CloudIdentity.IdentityServerType) CloudIdentity.IdentityServerType.valueOf("NewServerType"));
\r
74 String regionId = "RegionA";
\r
75 String msoPropID = "12345";
\r
77 assertEquals(cloudIdentity.getKeystoneUrl(regionId, msoPropID), msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl());
\r
78 } catch (MsoException e) {
\r
79 fail("No MSO Exception should have occured here");
\r