4 package org.openecomp.mso.cloud.servertype;
\r
6 import static org.junit.Assert.assertEquals;
\r
7 import static org.junit.Assert.assertNotNull;
\r
8 import static org.junit.Assert.fail;
\r
10 import org.junit.Ignore;
\r
11 import org.junit.Test;
\r
12 import org.openecomp.mso.cloud.CloudIdentity;
\r
13 import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
\r
14 import org.openecomp.mso.cloud.IdentityServerTypeAbstract;
\r
15 import org.openecomp.mso.openstack.exceptions.MsoException;
\r
17 public class ServerTypeTest {
\r
20 @Ignore // IGNORED FOR 1710 MERGE TO ONAP
\r
21 public void testKeystoneServerType() {
\r
22 IdentityServerTypeAbstract keystoneServerType = IdentityServerType.valueOf("KEYSTONE");
\r
23 assertNotNull(keystoneServerType);
\r
27 public void testNewServerType() {
\r
28 IdentityServerTypeAbstract customServerType = null;
\r
30 customServerType = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
\r
32 } catch (IllegalArgumentException e) {
\r
33 fail("An exception should not be raised when we register a new server type for the first time");
\r
35 System.out.println(IdentityServerType.values().toString());
\r
36 assertEquals(customServerType, IdentityServerType.valueOf("NewServerType"));
\r
39 // Create it a second time
\r
40 IdentityServerTypeAbstract customServerType2 = null;
\r
42 customServerType2 = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
\r
43 fail("An exception should be raised as server type does not exist");
\r
44 } catch (IllegalArgumentException e) {
\r
45 // Fail silently -- it simply indicates we already registered it
\r
46 customServerType2 = IdentityServerType.valueOf("NewServerType");
\r
48 System.out.println(IdentityServerType.values().toString());
\r
49 assertEquals(customServerType2, IdentityServerType.valueOf("NewServerType"));
\r
52 // Check the KeystoneURL for this custom TenantUtils
\r
53 CloudIdentity cloudIdentity = new CloudIdentity();
\r
54 cloudIdentity.setIdentityUrl("LocalIdentity");
\r
55 cloudIdentity.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
\r
56 cloudIdentity.setIdentityServerType((CloudIdentity.IdentityServerType) CloudIdentity.IdentityServerType.valueOf("NewServerType"));
\r
57 String regionId = "RegionA";
\r
58 String msoPropID = "12345";
\r
60 assertEquals(cloudIdentity.getKeystoneUrl(regionId, msoPropID), msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl());
\r
61 } catch (MsoException e) {
\r
62 fail("No MSO Exception should have occured here");
\r