diff options
author | ChrisC <cc697w@intl.att.com> | 2017-01-31 11:40:03 +0100 |
---|---|---|
committer | ChrisC <cc697w@intl.att.com> | 2017-01-31 12:59:33 +0100 |
commit | 025301d08b061482c1f046d562bf017c8cbcfe8d (patch) | |
tree | 68a2a549736c9bf0f7cd4e71c76e40ef7e2606f2 /adapters/mso-tenant-adapter/src/test | |
parent | 2754ad52f833278a5c925bd788a16d1dce16a598 (diff) |
Initial OpenECOMP MSO commit
Change-Id: Ia6a7574859480717402cc2f22534d9973a78fa6d
Signed-off-by: ChrisC <cc697w@intl.att.com>
Diffstat (limited to 'adapters/mso-tenant-adapter/src/test')
-rw-r--r-- | adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java | 132 | ||||
-rw-r--r-- | adapters/mso-tenant-adapter/src/test/resources/logback-test.xml | 47 |
2 files changed, 179 insertions, 0 deletions
diff --git a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java new file mode 100644 index 0000000000..dac0e6ebab --- /dev/null +++ b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.adapters.tenant.test; + + + +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.openecomp.mso.adapters.tenant.MsoTenantAdapter; +import org.openecomp.mso.adapters.tenant.MsoTenantAdapterImpl; +import org.openecomp.mso.adapters.tenant.exceptions.TenantException; +import org.openecomp.mso.adapters.tenantrest.TenantRollback; + +public class TenantTest { + public static final void main (String args[]) + { + String cloudId = "MT"; + cloudId = "AIC_GAMMALAB"; + + MsoTenantAdapter tenantAdapter = new MsoTenantAdapterImpl(); + + Holder<String> tenantId = new Holder<String>(); + Holder<String> tenantName = new Holder<String>(); + Holder<Map<String,String>> tenantMetadata = new Holder<Map<String,String>>(); + Holder<Boolean> tenantDeleted = new Holder<Boolean>(); + Holder<TenantRollback> rollback = new Holder<TenantRollback>(); + + try { + tenantAdapter.queryTenant (cloudId, "934a4ac9c4bd4b8d9d8ab3ef900281b0", null, tenantId, tenantName, tenantMetadata); + System.out.println ("Got Tenant ID=" + tenantId.value + ", name=" + tenantName.value + ", metadata = " + tenantMetadata.value); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception: " + e); + System.exit(1); + } +/* + Map<String,String> metadata = new HashMap<String,String>(); + metadata.put("sdn-global-id", "abc"); + metadata.put("service-type", "gamma"); + + // Create a new tenant + try { + tenantAdapter.createTenant(cloudId, "TEST_META6", metadata, true, tenantId, rollback); + System.out.println ("Created Tenant ID " + tenantId.value); + } + catch (TenantAlreadyExists e) { + System.out.println ("Create: Tenant already exists: " + "TEST_META6"); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Create: " + e); + System.exit(1); + } + + // Query the new tenant + try { + tenantAdapter.queryTenant (cloudId, "TEST_META6", tenantId, tenantName, tenantMetadata); + System.out.println ("Queried Tenant ID=" + tenantId.value + ", name=" + tenantName.value + ", metadata = " + tenantMetadata.value); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Query: " + e); + System.exit(1); + } + + try { + Thread.sleep(10000); + } catch (InterruptedException e1) {} + + // Delete the new tenant + try { + tenantAdapter.deleteTenant (cloudId, tenantId.value, tenantDeleted); + if (tenantDeleted.value) + System.out.println ("Deleted Tenant " + tenantId.value); + else + System.out.println ("Delete: Tenant " + tenantId.value + " does not exist"); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Delete: " + e); + } +/* + // Create another new tenant + try { + tenantAdapter.createTenant(cloudId, "TEST_MSO2", null, false, tenantId, rollback); + System.out.println ("Created Tenant ID " + tenantId.value); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Create: " + e); + } + + // Query the new tenant + try { + tenantAdapter.queryTenant (cloudId, "TEST_MSO2", tenantId, tenantName); + System.out.println ("Queried Tenant ID=" + tenantId.value + ", name=" + tenantName.value); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Query: " + e); + } + + try { + Thread.sleep(10000); + } catch (InterruptedException e1) {} + + // Rollback the new tenant + try { + tenantAdapter.rollbackTenant(rollback.value); + System.out.println ("Rolled Back Tenant ID " + tenantId.value); + } + catch (TenantException e) { + System.out.println ("Got Tenant Exception on Rollback: " + e); + } +*/ + } +} diff --git a/adapters/mso-tenant-adapter/src/test/resources/logback-test.xml b/adapters/mso-tenant-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..a23395fe1b --- /dev/null +++ b/adapters/mso-tenant-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,47 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<configuration > + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration> |