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.Test;
\r
11 import org.openecomp.mso.cloud.CloudIdentity;
\r
12 import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
\r
13 import org.openecomp.mso.cloud.IdentityServerTypeAbstract;
\r
14 import org.openecomp.mso.openstack.exceptions.MsoException;
\r
16 public class ServerTypeTest {
\r
19 public void testKeystoneServerType() {
\r
20 IdentityServerTypeAbstract keystoneServerType = IdentityServerType.valueOf("KEYSTONE");
\r
21 assertNotNull(keystoneServerType);
\r
25 public void testNewServerType() {
\r
26 IdentityServerTypeAbstract customServerType = null;
\r
28 customServerType = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
\r
30 } catch (IllegalArgumentException e) {
\r
31 fail("An exception should not be raised when we register a new server type for the first time");
\r
33 System.out.println(IdentityServerType.values().toString());
\r
34 assertEquals(customServerType, IdentityServerType.valueOf("NewServerType"));
\r
37 // Create it a second time
\r
38 IdentityServerTypeAbstract customServerType2 = null;
\r
40 customServerType2 = new IdentityServerType("NewServerType", NewServerTypeUtils.class);
\r
41 fail("An exception should be raised as server type does not exist");
\r
42 } catch (IllegalArgumentException e) {
\r
43 // Fail silently -- it simply indicates we already registered it
\r
44 customServerType2 = IdentityServerType.valueOf("NewServerType");
\r
46 System.out.println(IdentityServerType.values().toString());
\r
47 assertEquals(customServerType2, IdentityServerType.valueOf("NewServerType"));
\r
50 // Check the KeystoneURL for this custom TenantUtils
\r
51 CloudIdentity cloudIdentity = new CloudIdentity();
\r
52 cloudIdentity.setIdentityUrl("LocalIdentity");
\r
53 cloudIdentity.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
\r
54 cloudIdentity.setIdentityServerType((CloudIdentity.IdentityServerType) CloudIdentity.IdentityServerType.valueOf("NewServerType"));
\r
55 String regionId = "RegionA";
\r
56 String msoPropID = "12345";
\r
58 assertEquals(cloudIdentity.getKeystoneUrl(regionId, msoPropID), msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl());
\r
59 } catch (MsoException e) {
\r
60 fail("No MSO Exception should have occured here");
\r