Update the integration test with tenant operations

Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/bf81f776
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/bf81f776
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/bf81f776

Branch: refs/heads/tenant-isolation
Commit: bf81f776ca83617c425a2764f5a2ac32f6306d5a
Parents: 7c8a22c
Author: gayangunarathne <[email protected]>
Authored: Tue Aug 18 21:59:21 2015 +0530
Committer: gayangunarathne <[email protected]>
Committed: Tue Aug 18 21:59:21 2015 +0530

----------------------------------------------------------------------
 .../tests/policies/ApplicationPolicyTest.java   | 57 ++++++++++++++++++--
 1 file changed, 54 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/bf81f776/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
index 5c05725..6800200 100644
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
@@ -28,9 +28,7 @@ import org.apache.stratos.integration.tests.RestConstants;
 import org.apache.stratos.integration.tests.StratosTestServerManager;
 import org.testng.annotations.Test;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.*;
 
 /**
  * Test to handle Network partition CRUD operations
@@ -97,6 +95,27 @@ public class ApplicationPolicyTest extends 
StratosTestServerManager {
                             ApplicationPolicyBean.class, 
RestConstants.APPLICATION_POLICIES_NAME);
             assertNull("Application policy bean found in tenant 2",bean);
 
+            addedN1 = restClientTenant2.addEntity(RESOURCES_PATH + 
RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-application-policy-test-1" + 
".json",
+                    RestConstants.NETWORK_PARTITIONS, 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(addedN1, true);
+
+            addedN2 = restClientTenant2.addEntity(RESOURCES_PATH + 
RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-application-policy-test-2" + 
".json",
+                    RestConstants.NETWORK_PARTITIONS, 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(addedN2, true);
+
+            boolean addedTenant2Dep = 
restClientTenant2.addEntity(RESOURCES_PATH + 
RestConstants.APPLICATION_POLICIES_PATH + "/" +
+                            applicationPolicyId + ".json",
+                    RestConstants.APPLICATION_POLICIES, 
RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(addedTenant2Dep, true);
+
+            ApplicationPolicyBean tenant2bean = (ApplicationPolicyBean) 
restClientTenant2.
+                    getEntity(RestConstants.APPLICATION_POLICIES, 
applicationPolicyId,
+                            ApplicationPolicyBean.class, 
RestConstants.APPLICATION_POLICIES_NAME);
+            assertNotNull("Application is not exist in tenant 2", tenant2bean);
+
+
             boolean removedNet = 
restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-application-policy-test-1", 
RestConstants.NETWORK_PARTITIONS_NAME);
             //Trying to remove the used network partition
@@ -129,6 +148,38 @@ public class ApplicationPolicyTest extends 
StratosTestServerManager {
                             NetworkPartitionBean.class, 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(beanRemovedN2, null);
 
+            tenant2bean = (ApplicationPolicyBean) restClientTenant2.
+                    getEntity(RestConstants.APPLICATION_POLICIES, 
applicationPolicyId,
+                            ApplicationPolicyBean.class, 
RestConstants.APPLICATION_POLICIES_NAME);
+            assertNotNull("Application is not exist in tenant 2", tenant2bean);
+
+            removedDep = 
restClientTenant2.removeEntity(RestConstants.APPLICATION_POLICIES,
+                    applicationPolicyId, 
RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(removedDep, true);
+
+            beanRemovedDep = (ApplicationPolicyBean) restClientTenant2.
+                    getEntity(RestConstants.APPLICATION_POLICIES, 
applicationPolicyId,
+                            ApplicationPolicyBean.class, 
RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(beanRemovedDep, null);
+
+            removedN1 = 
restClientTenant2.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-application-policy-test-1", 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedN1, true);
+
+            beanRemovedN1 = (NetworkPartitionBean) restClientTenant2.
+                    getEntity(RestConstants.NETWORK_PARTITIONS, 
"network-partition-application-policy-test-1",
+                            NetworkPartitionBean.class, 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(beanRemovedN1, null);
+
+            removedN2 = 
restClientTenant2.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-application-policy-test-2", 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedN2, true);
+
+            beanRemovedN2 = (NetworkPartitionBean) restClientTenant2.
+                    getEntity(RestConstants.NETWORK_PARTITIONS, 
"network-partition-application-policy-test-2",
+                            NetworkPartitionBean.class, 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(beanRemovedN2, null);
+
             log.info("-------------------------Ended deployment policy test 
case-------------------------");
 
         } catch (Exception e) {

Reply via email to