You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2015/08/14 12:59:19 UTC

[1/4] stratos git commit: reducing the log level as it gets printed frequently and can be omitted

Repository: stratos
Updated Branches:
  refs/heads/master 0f2b953bf -> 4dc0f9af2


reducing the log level as it gets printed frequently and can be omitted


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

Branch: refs/heads/master
Commit: 4dc0f9af20bbf72ff0d669560da940ae401926a3
Parents: 121f118
Author: reka <rt...@gmail.com>
Authored: Fri Aug 14 15:35:04 2015 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Aug 14 15:38:08 2015 +0530

----------------------------------------------------------------------
 .../stratos/modules/distribution/src/main/conf/drools/scaling.drl  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4dc0f9af/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl b/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl
index 4b55123..61ed1a3 100644
--- a/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl
+++ b/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl
@@ -288,7 +288,7 @@ dialect "mvel"
 
                 }
             } else {
-                log.info("[scale-down] Min is reached, hence not scaling down [cluster] " + clusterId + " [instance id]"
+                log.debug("[scale-down] Min is reached, hence not scaling down [cluster] " + clusterId + " [instance id]"
                     + clusterInstanceContext.getId());
                 //if(clusterInstanceContext.isInGroupScalingEnabledSubtree()){
 


[4/4] stratos git commit: adding termination behavior test and list test case for all the artifacts

Posted by re...@apache.org.
adding termination behavior test and list test case for all the artifacts


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

Branch: refs/heads/master
Commit: 512280afcf554ae8dd855b0772f065753238f088
Parents: 0f2b953
Author: reka <rt...@gmail.com>
Authored: Fri Aug 14 13:53:06 2015 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Aug 14 15:38:08 2015 +0530

----------------------------------------------------------------------
 .../tests/StratosTestServerManager.java         |   2 +-
 .../integration/tests/TopologyHandler.java      | 157 +++++++--
 .../application/ApplicationBurstingTest.java    |  75 ++--
 .../application/ApplicationUpdateTest.java      |  16 +-
 .../application/GroupStartupOrderTest.java      |  12 +-
 .../GroupTerminationBehaviorTest.java           | 350 +++++++++++++++++++
 .../PartitionOneAfterAnotherClusterTest.java    |  10 +-
 .../PartitionRoundRobinClusterTest.java         |  16 +-
 .../application/SingleClusterScalingTest.java   |  10 +-
 .../tests/group/CartridgeGroupTest.java         | 183 ++++++++--
 .../integration/tests/group/CartridgeTest.java  |  73 +++-
 .../tests/policies/NetworkPartitionTest.java    |  85 ++++-
 .../integration/tests/rest/RestClient.java      |  30 ++
 .../group-1-cartridge-group-test.json           |  50 +++
 .../group-2-cartridge-group-test.json           |  50 +++
 .../cartridges/mock/c1-cartridge-test.json      | 124 +++++++
 .../cartridges/mock/c2-cartridge-test.json      | 124 +++++++
 ...cation-policy-application-bursting-test.json |  17 -
 ...-policy-group-termination-behavior-test.json |  17 +
 .../group-termination-behavior-test.json        |   4 +-
 ...caling-policy-application-bursting-test.json |  14 -
 ...-policy-group-termination-behavior-test.json |  14 +
 ...-groups-group-termination-behavior-test.json |   4 +-
 ...-policy-group-termination-behavior-test.json |  18 +
 ...oyment-policy-termination-behavior-test.json |  22 --
 ...k-partition-application-bursting-test-1.json |  15 -
 ...ition-group-termination-behavior-test-1.json |  15 +
 .../src/test/resources/mock-iaas.xml            |  20 ++
 ...work-partition-network-partition-test-1.json |  15 +
 ...work-partition-network-partition-test-2.json |  15 +
 .../src/test/resources/stratos-testing.xml      |  15 +-
 31 files changed, 1359 insertions(+), 213 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
index 342df28..6a69b75 100755
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
@@ -58,7 +58,7 @@ public class StratosTestServerManager extends TestServerManager {
     private static final String JNDI_PROPERTIES_FILE = "jndi.properties";
     private static final String JMS_OUTPUT_ADAPTER_FILE = "JMSOutputAdaptor.xml";
     protected RestClient restClient;
-    private String endpoint = "https://localhost:9443";
+    private String endpoint = "http://localhost:9763";
 
     private BrokerService broker = new BrokerService();
     private TestLogAppender testLogAppender = new TestLogAppender();

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
index 85e370b..85987f5 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
@@ -33,10 +33,8 @@ import org.apache.stratos.messaging.domain.topology.Member;
 import org.apache.stratos.messaging.domain.topology.MemberStatus;
 import org.apache.stratos.messaging.domain.topology.Service;
 import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.application.GroupInstanceCreatedEvent;
-import org.apache.stratos.messaging.event.topology.ClusterInstanceCreatedEvent;
-import org.apache.stratos.messaging.event.topology.MemberCreatedEvent;
-import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent;
+import org.apache.stratos.messaging.event.application.*;
+import org.apache.stratos.messaging.event.topology.*;
 import org.apache.stratos.messaging.listener.application.*;
 import org.apache.stratos.messaging.listener.topology.*;
 import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
@@ -68,10 +66,11 @@ public class TopologyHandler {
     private ApplicationsEventReceiver applicationsEventReceiver;
     private TopologyEventReceiver topologyEventReceiver;
     public static TopologyHandler topologyHandler;
-    private Map<String, Map<String, Long>> terminatedNodes = new ConcurrentHashMap<String, Map<String, Long>>();
     private Map<String, Long> terminatedMembers = new ConcurrentHashMap<String, Long>();
-    private Map<String, Map<String, Long>> createdNodes = new ConcurrentHashMap<String, Map<String, Long>>();
-    private Map<String, Map<String, Long>> activeNodes = new ConcurrentHashMap<String, Map<String, Long>>();
+    private Map<String, Long> terminatingMembers = new ConcurrentHashMap<String, Long>();
+    private Map<String, Long> createdMembers = new ConcurrentHashMap<String, Long>();
+    private Map<String, Long> inActiveMembers = new ConcurrentHashMap<String, Long>();
+    private Map<String, Long> activateddMembers = new ConcurrentHashMap<String, Long>();
 
     private TopologyHandler() {
         // Set jndi.properties.dir system property for initializing event receivers
@@ -82,6 +81,7 @@ public class TopologyHandler {
         assertApplicationTopologyInitialized();
         assertTopologyInitialized();
         addTopologyEventListeners();
+        addApplicationEventListeners();
     }
 
     public static TopologyHandler getInstance() {
@@ -457,30 +457,27 @@ public class TopologyHandler {
             @Override
             protected void onEvent(Event event) {
                 MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event;
-                terminatedMembers.put(memberTerminatedEvent.getMemberId(), System.currentTimeMillis());
+                getTerminatedMembers().put(memberTerminatedEvent.getMemberId(), System.currentTimeMillis());
 
             }
         });
 
-        topologyEventReceiver.addEventListener(new MemberCreatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-
-            }
-        });
 
         topologyEventReceiver.addEventListener(new ClusterInstanceCreatedEventListener() {
             @Override
             protected void onEvent(Event event) {
                 ClusterInstanceCreatedEvent event1 = (ClusterInstanceCreatedEvent) event;
-
+                String clusterId = event1.getClusterId();
+                getCreatedMembers().put(clusterId, System.currentTimeMillis());
             }
         });
 
         topologyEventReceiver.addEventListener(new ClusterInstanceActivatedEventListener() {
             @Override
             protected void onEvent(Event event) {
+                ClusterInstanceActivatedEvent event1 = (ClusterInstanceActivatedEvent) event;
+                String clusterId = event1.getClusterId();
+                getActivateddMembers().put(clusterId, System.currentTimeMillis());
 
             }
         });
@@ -488,14 +485,27 @@ public class TopologyHandler {
         topologyEventReceiver.addEventListener(new ClusterInstanceInactivateEventListener() {
             @Override
             protected void onEvent(Event event) {
-
+                ClusterInstanceInactivateEvent event1 = (ClusterInstanceInactivateEvent) event;
+                String clusterId = event1.getClusterId();
+                getInActiveMembers().put(clusterId, System.currentTimeMillis());
             }
         });
 
         topologyEventReceiver.addEventListener(new ClusterInstanceTerminatedEventListener() {
             @Override
             protected void onEvent(Event event) {
+                ClusterInstanceTerminatedEvent event1 = (ClusterInstanceTerminatedEvent) event;
+                String clusterId = event1.getClusterId();
+                getTerminatedMembers().put(clusterId, System.currentTimeMillis());
+            }
+        });
 
+        topologyEventReceiver.addEventListener(new ClusterInstanceTerminatingEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                ClusterInstanceTerminatingEvent event1 = (ClusterInstanceTerminatingEvent) event;
+                String clusterId = event1.getClusterId();
+                getTerminatingMembers().put(clusterId, System.currentTimeMillis());
             }
         });
 
@@ -503,46 +513,135 @@ public class TopologyHandler {
     }
 
     private void addApplicationEventListeners() {
-        applicationsEventReceiver.addEventListener(new ApplicationInstanceCreatedEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-
-
-            }
-        });
 
         applicationsEventReceiver.addEventListener(new GroupInstanceCreatedEventListener() {
             @Override
             protected void onEvent(Event event) {
                 GroupInstanceCreatedEvent event1 = (GroupInstanceCreatedEvent) event;
                 String appId = event1.getAppId();
-                String id = event1.getGroupId();
+                String groupId = event1.getGroupId();
                 String instanceId = event1.getGroupInstance().getInstanceId();
+                String id = generateId(appId, groupId, instanceId);
+                getCreatedMembers().put(id, System.currentTimeMillis());
 
             }
         });
 
-
-
         applicationsEventReceiver.addEventListener(new GroupInstanceActivatedEventListener() {
             @Override
             protected void onEvent(Event event) {
-
+                GroupInstanceActivatedEvent event1 = (GroupInstanceActivatedEvent) event;
+                String appId = event1.getAppId();
+                String groupId = event1.getGroupId();
+                String instanceId = event1.getInstanceId();
+                String id = generateId(appId, groupId, instanceId);
+                getActivateddMembers().put(id, System.currentTimeMillis());
             }
         });
 
         applicationsEventReceiver.addEventListener(new GroupInstanceInactivateEventListener() {
             @Override
             protected void onEvent(Event event) {
-
+                GroupInstanceInactivatedEvent event1 = (GroupInstanceInactivatedEvent) event;
+                String appId = event1.getAppId();
+                String groupId = event1.getGroupId();
+                String instanceId = event1.getInstanceId();
+                String id = generateId(appId, groupId, instanceId);
+                getInActiveMembers().put(id, System.currentTimeMillis());
             }
         });
 
         applicationsEventReceiver.addEventListener(new GroupInstanceTerminatedEventListener() {
             @Override
             protected void onEvent(Event event) {
+                GroupInstanceTerminatedEvent event1 = (GroupInstanceTerminatedEvent) event;
+                String appId = event1.getAppId();
+                String groupId = event1.getGroupId();
+                String instanceId = event1.getInstanceId();
+                String id = generateId(appId, groupId, instanceId);
+                getTerminatedMembers().put(id, System.currentTimeMillis());
+            }
+        });
 
+        applicationsEventReceiver.addEventListener(new GroupInstanceTerminatingEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                GroupInstanceTerminatingEvent event1 = (GroupInstanceTerminatingEvent) event;
+                String appId = event1.getAppId();
+                String groupId = event1.getGroupId();
+                String instanceId = event1.getInstanceId();
+                String id = generateId(appId, groupId, instanceId);
+                getTerminatingMembers().put(id, System.currentTimeMillis());
             }
         });
     }
+
+    public String generateId(String appId, String groupId, String instanceId) {
+        return appId + "-" + groupId + "-" + instanceId;
+    }
+
+    public String getClusterIdFromAlias(String applicationId, String alias) {
+        Application application = ApplicationManager.getApplications().getApplication(applicationId);
+        assertNotNull(application);
+
+        ClusterDataHolder dataHolder = application.getClusterDataHolderRecursivelyByAlias(alias);
+        assertNotNull(dataHolder);
+
+        return dataHolder.getClusterId();
+    }
+
+
+    public void removeMembersFromMaps(String applicationId) {
+        for(Map.Entry<String, Long> entry: getActivateddMembers().entrySet()) {
+            if(entry.getKey().contains(applicationId)) {
+                getActivateddMembers().remove(entry.getKey());
+            }
+        }
+
+        for(Map.Entry<String, Long> entry: getTerminatedMembers().entrySet()) {
+            if(entry.getKey().contains(applicationId)) {
+                getTerminatedMembers().remove(entry.getKey());
+            }
+        }
+    }
+
+    public Map<String, Long> getTerminatedMembers() {
+        return terminatedMembers;
+    }
+
+    public void setTerminatedMembers(Map<String, Long> terminatedMembers) {
+        this.terminatedMembers = terminatedMembers;
+    }
+
+    public Map<String, Long> getTerminatingMembers() {
+        return terminatingMembers;
+    }
+
+    public void setTerminatingMembers(Map<String, Long> terminatingMembers) {
+        this.terminatingMembers = terminatingMembers;
+    }
+
+    public Map<String, Long> getCreatedMembers() {
+        return createdMembers;
+    }
+
+    public void setCreatedMembers(Map<String, Long> createdMembers) {
+        this.createdMembers = createdMembers;
+    }
+
+    public Map<String, Long> getInActiveMembers() {
+        return inActiveMembers;
+    }
+
+    public void setInActiveMembers(Map<String, Long> inActiveMembers) {
+        this.inActiveMembers = inActiveMembers;
+    }
+
+    public Map<String, Long> getActivateddMembers() {
+        return activateddMembers;
+    }
+
+    public void setActivateddMembers(Map<String, Long> activateddMembers) {
+        this.activateddMembers = activateddMembers;
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
index 6c62056..70f79f2 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
@@ -29,8 +29,7 @@ import org.apache.stratos.integration.tests.TopologyHandler;
 import org.apache.stratos.messaging.domain.application.ApplicationStatus;
 import org.testng.annotations.Test;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.*;
 
 /**
  * This will handle the application bursting test cases
@@ -44,30 +43,30 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
     public void testApplicationBusting() {
         try {
             log.info("-------------------------------Started application Bursting test case-------------------------------");
-
+            TopologyHandler topologyHandler = TopologyHandler.getInstance();
             String autoscalingPolicyId = "autoscaling-policy-application-bursting-test";
 
             boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
                             + "/" + autoscalingPolicyId + ".json",
                     RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
-            assertEquals(addedScalingPolicy, true);
+            assertTrue(addedScalingPolicy);
 
             boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb-application-bursting-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(addedC1, true);
+            assertTrue(addedC1);
 
             boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php-application-bursting-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(addedC2, true);
+            assertTrue(addedC2);
 
             boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat-application-bursting-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(addedC3, true);
+            assertTrue(addedC3);
 
             boolean addedG1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
                             "/" + "esb-php-group-application-bursting-test.json", RestConstants.CARTRIDGE_GROUPS,
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(addedG1, true);
+            assertTrue(addedG1);
 
             CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
                     getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test",
@@ -77,22 +76,22 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
             boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
                             "network-partition-application-bursting-test-1.json",
                     RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(addedN1, true);
+            assertTrue(addedN1);
 
             boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
                             "network-partition-application-bursting-test-2.json",
                     RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(addedN2, true);
+            assertTrue(addedN2);
 
             boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
                             "deployment-policy-application-bursting-test.json",
                     RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(addedDep, true);
+            assertTrue(addedDep);
 
             boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
                             "app-bursting-single-cartriddge-group.json", RestConstants.APPLICATIONS,
                     RestConstants.APPLICATIONS_NAME);
-            assertEquals(added, true);
+            assertTrue(added);
 
             ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
                     "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
@@ -101,7 +100,7 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
             boolean addAppPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
                             "application-policy-application-bursting-test.json", RestConstants.APPLICATION_POLICIES,
                     RestConstants.APPLICATION_POLICIES_NAME);
-            assertEquals(addAppPolicy, true);
+            assertTrue(addAppPolicy);
 
             ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity(
                     RestConstants.APPLICATION_POLICIES,
@@ -113,35 +112,35 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
                     RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-application-bursting-test";
             boolean deployed = restClient.deployEntity(resourcePath,
                     RestConstants.APPLICATIONS_NAME);
-            assertEquals(deployed, true);
+            assertTrue(deployed);
 
             //Application active handling
-            TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+            topologyHandler.assertApplicationStatus(bean.getApplicationId(),
                     ApplicationStatus.Active);
 
             //Group active handling
-            TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
+            topologyHandler.assertGroupActivation(bean.getApplicationId());
 
             //Cluster active handling
-            TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+            topologyHandler.assertClusterActivation(bean.getApplicationId());
 
             boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(removedGroup, false);
+            assertFalse(removedGroup);
 
             boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
-            assertEquals(removedAuto, false);
+            assertFalse(removedAuto);
 
             boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-application-bursting-test-1",
                     RestConstants.NETWORK_PARTITIONS_NAME);
             //Trying to remove the used network partition
-            assertEquals(removedNet, false);
+            assertFalse(removedNet);
 
             boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
                     "deployment-policy-application-bursting-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(removedDep, false);
+            assertFalse(removedDep);
 
             //Un-deploying the application
             String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "application-bursting-test" +
@@ -149,9 +148,9 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
 
             boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
                     RestConstants.APPLICATIONS_NAME);
-            assertEquals(unDeployed, true);
+            assertTrue(unDeployed);
 
-            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test");
+            boolean undeploy = topologyHandler.assertApplicationUndeploy("application-bursting-test");
             if (!undeploy) {
                 //Need to forcefully undeploy the application
                 log.info("Force undeployment is going to start for the [application] " + "application-bursting-test");
@@ -159,63 +158,63 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
                 restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "application-bursting-test" +
                         RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
 
-                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test");
+                boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("application-bursting-test");
                 assertEquals(String.format("Forceful undeployment failed for the application %s",
-                        "application-bursting-test"), forceUndeployed, true);
+                        "application-bursting-test"), forceUndeployed);
 
             }
 
             boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "application-bursting-test",
                     RestConstants.APPLICATIONS_NAME);
-            assertEquals(removed, true);
+            assertTrue(removed);
 
             ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
                     "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
-            assertEquals(beanRemoved, null);
+            assertNull(beanRemoved);
 
             removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(removedGroup, true);
+            assertTrue(removedGroup);
 
             boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "esb-application-bursting-test",
                     RestConstants.CARTRIDGES_NAME);
-            assertEquals(removedC1, true);
+            assertTrue(removedC1);
 
             boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "php-application-bursting-test",
                     RestConstants.CARTRIDGES_NAME);
-            assertEquals(removedC2, true);
+            assertTrue(removedC2);
 
             boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat-application-bursting-test",
                     RestConstants.CARTRIDGES_NAME);
-            assertEquals(removedC3, true);
+            assertTrue(removedC3);
 
             removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
-            assertEquals(removedAuto, true);
+            assertTrue(removedAuto);
 
             removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
                     "deployment-policy-application-bursting-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(removedDep, true);
+            assertTrue(removedDep);
 
             removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-application-bursting-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedNet, false);
+            assertFalse(removedNet);
 
             boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedN2, false);
+            assertFalse(removedN2);
 
             boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
                     "application-policy-application-bursting-test", RestConstants.APPLICATION_POLICIES_NAME);
-            assertEquals(removeAppPolicy, true);
+            assertTrue(removeAppPolicy);
 
             removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-application-bursting-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedNet, true);
+            assertTrue(removedNet);
 
             removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedN2, true);
+            assertTrue(removedN2);
 
             log.info("-------------------------------Ended application bursting test case-------------------------------");
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
index c9e64b2..f3f1b91 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
@@ -44,7 +44,7 @@ public class ApplicationUpdateTest extends StratosTestServerManager {
     public void testDeployApplication() {
         try {
             log.info("-------------------------Started application runtime update test case-------------------------");
-
+            TopologyHandler topologyHandler = TopologyHandler.getInstance();
             String autoscalingPolicyId = "autoscaling-policy-application-update-test";
 
             boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
@@ -116,14 +116,14 @@ public class ApplicationUpdateTest extends StratosTestServerManager {
             assertEquals(deployed, true);
 
             //Application active handling
-            TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+            topologyHandler.assertApplicationStatus(bean.getApplicationId(),
                     ApplicationStatus.Active);
 
             //Group active handling
-            TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
+            topologyHandler.assertGroupActivation(bean.getApplicationId());
 
             //Cluster active handling
-            TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+            topologyHandler.assertClusterActivation(bean.getApplicationId());
 
             //Updating application
             boolean updated = restClient.updateEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
@@ -131,9 +131,9 @@ public class ApplicationUpdateTest extends StratosTestServerManager {
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(updated, true);
 
-            TopologyHandler.getInstance().assertGroupInstanceCount(bean.getApplicationId(), "group3-application-update-test", 2);
+            topologyHandler.assertGroupInstanceCount(bean.getApplicationId(), "group3-application-update-test", 2);
 
-            TopologyHandler.getInstance().assertClusterMinMemberCount(bean.getApplicationId(), 2);
+            topologyHandler.assertClusterMinMemberCount(bean.getApplicationId(), 2);
 
             ApplicationBean updatedBean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
                     "g-sc-G123-1-application-update-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
@@ -165,7 +165,7 @@ public class ApplicationUpdateTest extends StratosTestServerManager {
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(unDeployed, true);
 
-            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1-application-update-test");
+            boolean undeploy = topologyHandler.assertApplicationUndeploy("g-sc-G123-1-application-update-test");
             if (!undeploy) {
                 //Need to forcefully undeploy the application
                 log.info("Force undeployment is going to start for the [application] " + "g-sc-G123-1-application-update-test");
@@ -173,7 +173,7 @@ public class ApplicationUpdateTest extends StratosTestServerManager {
                 restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "g-sc-G123-1-application-update-test" +
                         RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
 
-                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1-application-update-test");
+                boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("g-sc-G123-1-application-update-test");
                 assertEquals(String.format("Forceful undeployment failed for the application %s",
                         "g-sc-G123-1-application-update-test"), forceUndeployed, true);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java
index 1f3aa56..7cd8e9f 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java
@@ -43,7 +43,7 @@ public class GroupStartupOrderTest extends StratosTestServerManager {
     public void testApplicationBusting() {
         try {
             log.info("-------------------------------Started application Bursting test case-------------------------------");
-
+            TopologyHandler topologyHandler = TopologyHandler.getInstance();
             String autoscalingPolicyId = "autoscaling-policy-application-bursting-test";
 
             boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
@@ -115,14 +115,14 @@ public class GroupStartupOrderTest extends StratosTestServerManager {
             assertEquals(deployed, true);
 
             //Application active handling
-            TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+            topologyHandler.assertApplicationStatus(bean.getApplicationId(),
                     ApplicationStatus.Active);
 
             //Group active handling
-            TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
+            topologyHandler.assertGroupActivation(bean.getApplicationId());
 
             //Cluster active handling
-            TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+            topologyHandler.assertClusterActivation(bean.getApplicationId());
 
             boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
@@ -150,7 +150,7 @@ public class GroupStartupOrderTest extends StratosTestServerManager {
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(unDeployed, true);
 
-            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test");
+            boolean undeploy = topologyHandler.assertApplicationUndeploy("application-bursting-test");
             if (!undeploy) {
                 //Need to forcefully undeploy the application
                 log.info("Force undeployment is going to start for the [application] " + "application-bursting-test");
@@ -158,7 +158,7 @@ public class GroupStartupOrderTest extends StratosTestServerManager {
                 restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "application-bursting-test" +
                         RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
 
-                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test");
+                boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("application-bursting-test");
                 assertEquals(String.format("Forceful undeployment failed for the application %s",
                         "application-bursting-test"), forceUndeployed, true);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java
index b86d674..415f67a 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java
@@ -18,10 +18,360 @@
  */
 package org.apache.stratos.integration.tests.application;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
 import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.apache.stratos.integration.tests.TopologyHandler;
+import org.apache.stratos.messaging.domain.application.Application;
+import org.apache.stratos.messaging.domain.application.ApplicationStatus;
+import org.apache.stratos.messaging.domain.application.Group;
+import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import static junit.framework.Assert.*;
 
 /**
  * Handling the termination behavior of the group
  */
 public class GroupTerminationBehaviorTest extends StratosTestServerManager {
+    private static final Log log = LogFactory.getLog(GroupTerminationBehaviorTest.class);
+    private static final String RESOURCES_PATH = "/group-termination-behavior-test";
+    private static final int GROUP_INACTIVE_TIMEOUT = 300000;
+
+    @Test
+    public void testTerminationBehavior() {
+        try {
+            log.info("-------------------------------Started application termination behavior test case-------------------------------");
+
+            String autoscalingPolicyId = "autoscaling-policy-group-termination-behavior-test";
+            TopologyHandler topologyHandler = TopologyHandler.getInstance();
+
+            boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
+                            + "/" + autoscalingPolicyId + ".json",
+                    RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertTrue(addedScalingPolicy);
+
+            boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1-group-termination-behavior-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertTrue(addedC1);
+
+            boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2-group-termination-behavior-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertTrue(addedC2);
+
+            boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3-group-termination-behavior-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertTrue(addedC3);
+
+            boolean addedC4 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c4-group-termination-behavior-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertTrue(addedC4);
+
+            boolean addedG1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+                            "/" + "cartridge-groups-group-termination-behavior-test.json", RestConstants.CARTRIDGE_GROUPS,
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertTrue(addedG1);
+
+            CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, "g-sc-G4-group-termination-behavior-test",
+                            CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(beanG1.getName(), "g-sc-G4-group-termination-behavior-test");
+
+            boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-group-termination-behavior-test-1.json",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(addedN1);
+            
+            boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                            "deployment-policy-group-termination-behavior-test.json",
+                    RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertTrue(addedDep);
+
+            boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+                            "group-termination-behavior-test.json", RestConstants.APPLICATIONS,
+                    RestConstants.APPLICATIONS_NAME);
+            assertTrue(added);
+
+            ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+                    "group-termination-behavior-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertEquals(bean.getApplicationId(), "group-termination-behavior-test");
+
+            boolean addAppPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+                            "application-policy-group-termination-behavior-test.json", RestConstants.APPLICATION_POLICIES,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+            assertTrue(addAppPolicy);
+
+            ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity(
+                    RestConstants.APPLICATION_POLICIES,
+                    "application-policy-group-termination-behavior-test", ApplicationPolicyBean.class,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+
+            //deploy the application
+            String resourcePath = RestConstants.APPLICATIONS + "/" + "group-termination-behavior-test" +
+                    RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-group-termination-behavior-test";
+            boolean deployed = restClient.deployEntity(resourcePath,
+                    RestConstants.APPLICATIONS_NAME);
+            assertTrue(deployed);
+
+            //Application active handling
+            topologyHandler.assertApplicationStatus(bean.getApplicationId(),
+                    ApplicationStatus.Active);
+            String groupId = topologyHandler.generateId(bean.getApplicationId(),
+                    "g-G1-1x0-group-termination-behavior-test", bean.getApplicationId() + "-1");
+
+            String clusterIdC3 = topologyHandler.
+                    getClusterIdFromAlias(bean.getApplicationId(),
+                            "c3-1x0-group-termination-behavior-test");
+
+            String clusterIdC4 = topologyHandler.
+                    getClusterIdFromAlias(bean.getApplicationId(),
+                            "c4-1x0-group-termination-behavior-test");
+
+            String clusterIdC2 = topologyHandler.
+                    getClusterIdFromAlias(bean.getApplicationId(),
+                            "c2-1x0-group-termination-behavior-test");
+
+            assertCreationOfNodes(groupId, clusterIdC2);
+            assertCreationOfNodes(clusterIdC3, clusterIdC4);
+
+            //Group active handling
+            topologyHandler.assertGroupActivation(bean.getApplicationId());
+
+            //Cluster active handling
+            topologyHandler.assertClusterActivation(bean.getApplicationId());
+
+            List<String> clusterIds = new ArrayList<String>();
+            clusterIds.add(clusterIdC3);
+            clusterIds.add(clusterIdC4);
+            clusterIds.add(clusterIdC2);
+
+            assertGroupInactive(groupId, clusterIdC3);
+
+            assertTerminatingOfNodes(groupId, clusterIds);
+
+            assertTerminationOfNodes(groupId, clusterIds);
+
+            //Application active handling
+            topologyHandler.assertApplicationStatus(bean.getApplicationId(),
+                    ApplicationStatus.Active);
+
+            assertCreationOfNodes(groupId, clusterIdC2);
+            assertCreationOfNodes(clusterIdC3, clusterIdC4);
+
+            //Group active handling
+            topologyHandler.assertGroupActivation(bean.getApplicationId());
+
+            //Cluster active handling
+            topologyHandler.assertClusterActivation(bean.getApplicationId());
+
+            boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,
+                    "g-sc-G4-group-termination-behavior-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertFalse(removedGroup);
+
+            boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertFalse(removedAuto);
+
+            boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-group-termination-behavior-test-1",
+                    RestConstants.NETWORK_PARTITIONS_NAME);
+            //Trying to remove the used network partition
+            assertFalse(removedNet);
+
+            boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-group-termination-behavior-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertFalse(removedDep);
+
+            //Un-deploying the application
+            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "group-termination-behavior-test" +
+                    RestConstants.APPLICATIONS_UNDEPLOY;
+
+            boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
+                    RestConstants.APPLICATIONS_NAME);
+            assertTrue(unDeployed);
+
+            boolean undeploy = topologyHandler.assertApplicationUndeploy("group-termination-behavior-test");
+            if (!undeploy) {
+                //Need to forcefully undeploy the application
+                log.info("Force undeployment is going to start for the [application] " + "group-termination-behavior-test");
+
+                restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "group-termination-behavior-test" +
+                        RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
+
+                boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("group-termination-behavior-test");
+                assertTrue(String.format("Forceful undeployment failed for the application %s",
+                        "group-termination-behavior-test"), forceUndeployed);
+
+            }
+
+            boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "group-termination-behavior-test",
+                    RestConstants.APPLICATIONS_NAME);
+            assertTrue(removed);
+
+            ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+                    "group-termination-behavior-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertNull(beanRemoved);
+
+            removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,
+                    "g-sc-G4-group-termination-behavior-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertTrue(removedGroup);
+
+            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1-group-termination-behavior-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertTrue(removedC1);
+
+            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2-group-termination-behavior-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertTrue(removedC2);
+
+            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3-group-termination-behavior-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertTrue(removedC3);
+
+            boolean removedC4 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-group-termination-behavior-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertTrue(removedC4);
+
+            removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertTrue(removedAuto);
+
+            removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-group-termination-behavior-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertTrue(removedDep);
+
+            removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-group-termination-behavior-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertFalse(removedNet);
+
+            boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+                    "application-policy-group-termination-behavior-test", RestConstants.APPLICATION_POLICIES_NAME);
+            assertTrue(removeAppPolicy);
+
+            removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-group-termination-behavior-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(removedNet);
+
+            log.info("-------------------------------Ended application termination behavior test case-------------------------------");
+
+        } catch (Exception e) {
+            log.error("An error occurred while handling  application termination behavior", e);
+            assertTrue("An error occurred while handling  application termination behavior", false);
+        }
+    }
+
+    private void assertGroupInactive(String groupId, String clusterId) {
+        long startTime = System.currentTimeMillis();
+        Map<String, Long> inActiveMap = TopologyHandler.getInstance().getInActiveMembers();
+
+        while(!inActiveMap.containsKey(clusterId)) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+            inActiveMap = TopologyHandler.getInstance().getInActiveMembers();
+            if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
+                break;
+            }
+        }
+        assertTrue(inActiveMap.containsKey(clusterId));
+
+        while(!inActiveMap.containsKey(groupId)) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+            inActiveMap = TopologyHandler.getInstance().getInActiveMembers();
+            if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
+                break;
+            }
+        }
+        assertTrue(inActiveMap.containsKey(groupId));
+
+    }
+
+    private void assertTerminatingOfNodes(String groupId, List<String> clusterIds) {
+        Map<String, Long> terminatingMembers = TopologyHandler.getInstance().getTerminatingMembers();
+        for(String clusterId : clusterIds) {
+            long startTime = System.currentTimeMillis();
+            while(!terminatingMembers.containsKey(clusterId)) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException ignore) {
+                }
+                terminatingMembers = TopologyHandler.getInstance().getTerminatingMembers();
+                if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
+                    break;
+                }
+            }
+            assertTrue(terminatingMembers.containsKey(groupId));
+        }
+        long startTime = System.currentTimeMillis();
+        while(!terminatingMembers.containsKey(groupId)) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+            terminatingMembers = TopologyHandler.getInstance().getTerminatingMembers();
+            if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
+                break;
+            }
+        }
+        assertTrue(terminatingMembers.containsKey(groupId));
+
+    }
+
+    private void assertTerminationOfNodes(String groupId, List<String> clusterIds) {
+        long startTime = System.currentTimeMillis();
+        Map<String, Long> terminatedMembers = TopologyHandler.getInstance().getTerminatedMembers();
+
+        for(String clusterId : clusterIds) {
+            while(!terminatedMembers.containsKey(clusterId)) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException ignore) {
+                }
+                terminatedMembers = TopologyHandler.getInstance().getTerminatedMembers();
+                if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
+                    break;
+                }
+            }
+            assertTrue(terminatedMembers.containsKey(clusterId));
+        }
+
+        while(!terminatedMembers.containsKey(groupId)) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+            terminatedMembers = TopologyHandler.getInstance().getTerminatedMembers();
+            if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
+                break;
+            }
+        }
+
+        assertTrue(terminatedMembers.containsKey(groupId));
+    }
+
+    private void assertCreationOfNodes(String firstNodeId, String secondNodeId) {
+        //group1 started first, then cluster started later
+
+        Map<String, Long> activeMembers = TopologyHandler.getInstance().getActivateddMembers();
+        Map<String, Long> createdMembers = TopologyHandler.getInstance().getCreatedMembers();
+        //Active member should be available at the time cluster is started to create.
+        assertTrue(activeMembers.containsKey(firstNodeId));
+        assertTrue(createdMembers.containsKey(secondNodeId));
+
+        assertTrue(createdMembers.get(secondNodeId) > activeMembers.get(firstNodeId));
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTest.java
index d8f6965..1e8324e 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTest.java
@@ -52,7 +52,7 @@ public class PartitionOneAfterAnotherClusterTest extends StratosTestServerManage
     public void testDeployApplication() {
         try {
             log.info("-------------------------------Started Partition One after another test case-------------------------------");
-
+            TopologyHandler topologyHandler = TopologyHandler.getInstance();
             String autoscalingPolicyId = "autoscaling-policy-3";
 
             boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
@@ -101,11 +101,11 @@ public class PartitionOneAfterAnotherClusterTest extends StratosTestServerManage
             assertEquals(deployed, true);
 
             //Application active handling
-            TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+            topologyHandler.assertApplicationStatus(bean.getApplicationId(),
                     ApplicationStatus.Active);
 
             //Cluster active handling
-            TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+            topologyHandler.assertClusterActivation(bean.getApplicationId());
 
             //Verifying whether members got created using round robin algorithm
             assertClusterWithRoundRobinAlgorithm(bean.getApplicationId());
@@ -135,7 +135,7 @@ public class PartitionOneAfterAnotherClusterTest extends StratosTestServerManage
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(unDeployed, true);
 
-            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("single-cluster-scaling-test");
+            boolean undeploy = topologyHandler.assertApplicationUndeploy("single-cluster-scaling-test");
             if (!undeploy) {
                 //Need to forcefully undeploy the application
                 log.info("Force undeployment is going to start for the [application] " + "single-cluster-scaling-test");
@@ -143,7 +143,7 @@ public class PartitionOneAfterAnotherClusterTest extends StratosTestServerManage
                 restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "single-cluster-scaling-test" +
                         RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
 
-                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("single-cluster-scaling-test");
+                boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("single-cluster-scaling-test");
                 assertEquals(String.format("Forceful undeployment failed for the application %s",
                         "single-cluster-scaling-test"), forceUndeployed, true);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTest.java
index ab7d592..3c0cee1 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTest.java
@@ -52,7 +52,7 @@ public class PartitionRoundRobinClusterTest extends StratosTestServerManager {
     public void testDeployApplication() {
         try {
             log.info("-------------------------------Started application Bursting test case-------------------------------");
-
+            TopologyHandler topologyHandler = TopologyHandler.getInstance();
             String autoscalingPolicyId = "autoscaling-policy-partition-round-robin-test";
 
             boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
@@ -97,11 +97,11 @@ public class PartitionRoundRobinClusterTest extends StratosTestServerManager {
 
 
             //Application active handling
-            TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+            topologyHandler.assertApplicationStatus(bean.getApplicationId(),
                     ApplicationStatus.Active);
 
             //Cluster active handling
-            TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+            topologyHandler.assertClusterActivation(bean.getApplicationId());
 
             //Verifying whether members got created using round robin algorithm
             assertClusterWithRoundRobinAlgorithm(bean.getApplicationId());
@@ -109,15 +109,15 @@ public class PartitionRoundRobinClusterTest extends StratosTestServerManager {
             //Application in-active handling
             log.info("Waiting for the faulty member detection from " +
                     "CEP as the statistics are stopped...");
-            TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+            topologyHandler.assertApplicationStatus(bean.getApplicationId(),
                     ApplicationStatus.Inactive);
 
             //Application active handling after application becomes active again
-            TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+            topologyHandler.assertApplicationStatus(bean.getApplicationId(),
                     ApplicationStatus.Active);
 
             //Cluster active handling
-            TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+            topologyHandler.assertClusterActivation(bean.getApplicationId());
 
             boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
@@ -141,7 +141,7 @@ public class PartitionRoundRobinClusterTest extends StratosTestServerManager {
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(unDeployed, true);
 
-            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("partition-round-robin-test");
+            boolean undeploy = topologyHandler.assertApplicationUndeploy("partition-round-robin-test");
             if (!undeploy) {
                 //Need to forcefully undeploy the application
                 log.info("Force undeployment is going to start for the [application] " + "partition-round-robin-test");
@@ -149,7 +149,7 @@ public class PartitionRoundRobinClusterTest extends StratosTestServerManager {
                 restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "partition-round-robin-test" +
                         RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
 
-                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("partition-round-robin-test");
+                boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("partition-round-robin-test");
                 assertEquals(String.format("Forceful undeployment failed for the application %s",
                         "partition-round-robin-test"), forceUndeployed, true);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
index f5fba7c..5a89d67 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
@@ -54,7 +54,7 @@ public class SingleClusterScalingTest extends StratosTestServerManager {
     public void testDeployApplication() {
         try {
             log.info("-------------------------------Started application Bursting test case-------------------------------");
-
+            TopologyHandler topologyHandler = TopologyHandler.getInstance();
             String autoscalingPolicyId = "autoscaling-policy-single-cluster-scaling-test";
 
             boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
@@ -103,11 +103,11 @@ public class SingleClusterScalingTest extends StratosTestServerManager {
             assertEquals(deployed, true);
 
             //Application active handling
-            TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId()
+            topologyHandler.assertApplicationStatus(bean.getApplicationId()
                     , ApplicationStatus.Active);
 
             //Cluster active handling
-            TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+            topologyHandler.assertClusterActivation(bean.getApplicationId());
 
             //Verifying whether members got created using round robin algorithm
             assertClusterWithScalingup(bean.getApplicationId());
@@ -134,7 +134,7 @@ public class SingleClusterScalingTest extends StratosTestServerManager {
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(unDeployed, true);
 
-            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("single-cluster-scaling-test");
+            boolean undeploy = topologyHandler.assertApplicationUndeploy("single-cluster-scaling-test");
             if (!undeploy) {
                 //Need to forcefully undeploy the application
                 log.info("Force undeployment is going to start for the [application] " + "single-cluster-scaling-test");
@@ -142,7 +142,7 @@ public class SingleClusterScalingTest extends StratosTestServerManager {
                 restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "single-cluster-scaling-test" +
                         RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
 
-                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("single-cluster-scaling-test");
+                boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("single-cluster-scaling-test");
                 assertEquals(String.format("Forceful undeployment failed for the application %s",
                         "single-cluster-scaling-test"), forceUndeployed, true);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
index ccaeaf6..60db78f 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.stratos.integration.tests.group;
 
+import com.google.gson.reflect.TypeToken;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
@@ -26,8 +27,11 @@ 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.assertTrue;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.*;
 
 /**
  * Test to handle Cartridge group CRUD operations
@@ -44,26 +48,26 @@ public class CartridgeGroupTest extends StratosTestServerManager {
             boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
                             "/" + "c4-cartridge-group-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(String.format("Cartridge did not added: [cartridge-name] %s",
-                    "c4-cartridge-group-test"), addedC1, true);
+            assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+                    "c4-cartridge-group-test"), addedC1);
 
             boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
                             "/" + "c5-cartridge-group-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(String.format("Cartridge did not added: [cartridge-name] %s",
-                    "c5-cartridge-group-test"), addedC2, true);
+            assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+                    "c5-cartridge-group-test"), addedC2);
 
             boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
                             "/" + "c6-cartridge-group-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(String.format("Cartridge did not added: [cartridge-name] %s",
-                    "c6-cartridge-group-test"), addedC3, true);
+            assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+                    "c6-cartridge-group-test"), addedC3);
 
             boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
                             "/" + "g4-g5-g6-cartridge-group-test.json", RestConstants.CARTRIDGE_GROUPS,
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
-                    "g4-g5-g6-cartridge-group-test"), added, true);
+            assertTrue(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
+                    "g4-g5-g6-cartridge-group-test"), added);
 
             CartridgeGroupBean bean = (CartridgeGroupBean) restClient.
                     getEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
@@ -74,8 +78,8 @@ public class CartridgeGroupTest extends StratosTestServerManager {
             boolean updated = restClient.updateEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
                             "/" + "g4-g5-g6-cartridge-group-test-v1.json",
                     RestConstants.CARTRIDGE_GROUPS, RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(String.format("Cartridge Group did not updated: [cartridge-group-name] %s",
-                    "g4-g5-g6-cartridge-group-test"), updated, true);
+            assertTrue(String.format("Cartridge Group did not updated: [cartridge-group-name] %s",
+                    "g4-g5-g6-cartridge-group-test"), updated);
 
             CartridgeGroupBean updatedBean = (CartridgeGroupBean) restClient.
                     getEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
@@ -85,25 +89,25 @@ public class CartridgeGroupTest extends StratosTestServerManager {
 
             boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(String.format("Cartridge can be removed while it is used in " +
-                    "cartridge group: [cartridge-name] %s", "c4-cartridge-group-test"), removedC1, false);
+            assertFalse(String.format("Cartridge can be removed while it is used in " +
+                    "cartridge group: [cartridge-name] %s", "c4-cartridge-group-test"), removedC1);
 
             boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(String.format("Cartridge can be removed while it is used in " +
+            assertFalse(String.format("Cartridge can be removed while it is used in " +
                             "cartridge group: [cartridge-name] %s",
-                    "c5-cartridge-group-test"), removedC2, false);
+                    "c5-cartridge-group-test"), removedC2);
 
             boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(String.format("Cartridge can be removed while it is used in " +
+            assertFalse(String.format("Cartridge can be removed while it is used in " +
                             "cartridge group: [cartridge-name] %s",
-                    "c6-cartridge-group-test"), removedC3, false);
+                    "c6-cartridge-group-test"), removedC3);
 
             boolean removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
-                    "g4-g5-g6-cartridge-group-test"), removed, true);
+            assertTrue(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
+                    "g4-g5-g6-cartridge-group-test"), removed);
 
             CartridgeGroupBean beanRemoved = (CartridgeGroupBean) restClient.
                     getEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
@@ -114,24 +118,149 @@ public class CartridgeGroupTest extends StratosTestServerManager {
 
             removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
-                    "c4-cartridge-group-test"), removedC1, true);
+            assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+                    "c4-cartridge-group-test"), removedC1);
 
             removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
-                    "c5-cartridge-group-test"), removedC2, true);
+            assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+                    "c5-cartridge-group-test"), removedC2);
 
             removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
-                    "c6-cartridge-group-test"), removedC3, true);
+            assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+                    "c6-cartridge-group-test"), removedC3);
 
             log.info("-------------------------Ended Cartridge group test case-------------------------");
 
         } catch (Exception e) {
             log.error("An error occurred while handling Cartridge group test case", e);
-            assertTrue("An error occurred while handling Cartridge group test case", false);
+            assertFalse("An error occurred while handling Cartridge group test case", false);
+        }
+    }
+
+    @Test
+    public void testCartridgeGroupList() {
+        try {
+            log.info("-------------------------Started Cartridge group list test case-------------------------");
+
+            boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
+                            "/" + "c4-cartridge-group-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+                    "c4-cartridge-group-test"), addedC1);
+
+            boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
+                            "/" + "c5-cartridge-group-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+                    "c5-cartridge-group-test"), addedC2);
+
+            boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
+                            "/" + "c6-cartridge-group-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+                    "c6-cartridge-group-test"), addedC3);
+
+            String group1 = "group-1-cartridge-group-test";
+            String group2 = "group-2-cartridge-group-test";
+
+            boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+                            "/" + group1 + ".json", RestConstants.CARTRIDGE_GROUPS,
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertTrue(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
+                    group1), added);
+
+            added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+                            "/" + group2 + ".json", RestConstants.CARTRIDGE_GROUPS,
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertTrue(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
+                    group1), added);
+
+            Type listType = new TypeToken<ArrayList<CartridgeGroupBean>>() {
+            }.getType();
+
+            List<CartridgeGroupBean> cartridgeGroupList = (List<CartridgeGroupBean>) restClient.
+                    listEntity(RestConstants.CARTRIDGE_GROUPS,
+                            listType, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(cartridgeGroupList.size(), 2);
+
+            CartridgeGroupBean bean1 = null;
+            for (CartridgeGroupBean cartridgeGroupBean : cartridgeGroupList) {
+                if (cartridgeGroupBean.getName().equals(group1)) {
+                    bean1 = cartridgeGroupBean;
+                }
+            }
+            assertNotNull(bean1);
+
+            CartridgeGroupBean bean2 = null;
+            for (CartridgeGroupBean cartridgeGroupBean : cartridgeGroupList) {
+                if (cartridgeGroupBean.getName().equals(group2)) {
+                    bean2 = cartridgeGroupBean;
+                }
+            }
+            assertNotNull(bean2);
+
+            boolean removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, group1,
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertTrue(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
+                    group1), removed);
+
+            CartridgeGroupBean beanRemoved = (CartridgeGroupBean) restClient.
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, group1,
+                            CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertNull(String.format("Cartridge Group did not removed completely: " +
+                            "[cartridge-group-name] %s",
+                    group1), beanRemoved);
+
+            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertFalse(String.format("Cartridge can be removed while it is used in " +
+                    "cartridge group: [cartridge-name] %s", "c4-cartridge-group-test"), removedC1);
+
+            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertFalse(String.format("Cartridge can be removed while it is used in " +
+                            "cartridge group: [cartridge-name] %s",
+                    "c5-cartridge-group-test"), removedC2);
+
+            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertFalse(String.format("Cartridge can be removed while it is used in " +
+                            "cartridge group: [cartridge-name] %s",
+                    "c6-cartridge-group-test"), removedC3);
+
+            removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, group2,
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertTrue(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
+                    group2), removed);
+
+            beanRemoved = (CartridgeGroupBean) restClient.
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, group2,
+                            CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertNull(String.format("Cartridge Group did not removed completely: " +
+                            "[cartridge-group-name] %s",
+                    group2), beanRemoved);
+
+            removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+                    "c4-cartridge-group-test"), removedC1);
+
+            removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+                    "c5-cartridge-group-test"), removedC2);
+
+            removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+                    "c6-cartridge-group-test"), removedC3);
+
+            log.info("-------------------------Ended Cartridge group list test case-------------------------");
+        } catch (Exception e) {
+            log.error("An error occurred while handling Cartridge list group test case", e);
+            assertFalse("An error occurred while handling Cartridge list group test case", false);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
index ac39161..7b413c1 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.stratos.integration.tests.group;
 
+import com.google.gson.reflect.TypeToken;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.common.beans.PropertyBean;
@@ -27,8 +28,11 @@ 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.assertTrue;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.*;
 
 /**
  * Test to handle Cartridge CRUD operations
@@ -127,4 +131,69 @@ public class CartridgeTest extends StratosTestServerManager {
             assertTrue("An error occurred while handling RESTConstants.CARTRIDGES_PATH", false);
         }
     }
+
+    @Test
+    public void testCartridgeList() {
+        log.info("--------------------Started Cartridge list test case-----------------------------");
+
+        try {
+            String cartridgeType1 = "c1-cartridge-test";
+            String cartridgeType2 = "c2-cartridge-test";
+            boolean added1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
+                            cartridgeType1 + ".json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(added1, true);
+
+            boolean added2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
+                            cartridgeType2 + ".json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(added2, true);
+
+            Type listType = new TypeToken<ArrayList<CartridgeBean>>() {
+            }.getType();
+
+            List<CartridgeBean> cartridgeList = (List<CartridgeBean>) restClient.listEntity(RestConstants.CARTRIDGES,
+                    listType, RestConstants.CARTRIDGES_NAME);
+            assertEquals(cartridgeList.size(), 2);
+
+            CartridgeBean bean1 = null;
+            for (CartridgeBean cartridgeBean : cartridgeList) {
+                if (cartridgeBean.getType().equals(cartridgeType1)) {
+                    bean1 = cartridgeBean;
+                }
+            }
+            assertNotNull(bean1);
+
+            CartridgeBean bean2 = null;
+            for (CartridgeBean cartridgeBean : cartridgeList) {
+                if (cartridgeBean.getType().equals(cartridgeType1)) {
+                    bean2 = cartridgeBean;
+                }
+            }
+            assertNotNull(bean2);
+
+            boolean removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType1,
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removed, true);
+
+            CartridgeBean beanRemoved = (CartridgeBean) restClient.
+                    getEntity(RestConstants.CARTRIDGES, cartridgeType1,
+                            CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
+            assertEquals(beanRemoved, null);
+
+            removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType2,
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removed, true);
+
+            beanRemoved = (CartridgeBean) restClient.
+                    getEntity(RestConstants.CARTRIDGES, cartridgeType2,
+                            CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
+            assertEquals(beanRemoved, null);
+
+            log.info("---------------------------Ended Cartridge list test case-------------------------");
+        } catch (Exception e) {
+            log.error("An error occurred while handling Cartridges list", e);
+            assertTrue("An error occurred while handling Cartridges list", false);
+        }
+    }
 }


[2/4] stratos git commit: adding list operation to application, cartridge, and all other policies

Posted by re...@apache.org.
adding list operation to application, cartridge, and all other policies


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

Branch: refs/heads/master
Commit: 121f118f4dfd9b5da4d3b770c882355488a18763
Parents: 512280a
Author: reka <rt...@gmail.com>
Authored: Fri Aug 14 15:34:21 2015 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Aug 14 15:38:08 2015 +0530

----------------------------------------------------------------------
 .../application/SampleApplicationsTest.java     | 174 ++++++++++++++++++-
 .../integration/tests/group/CartridgeTest.java  |  18 +-
 .../tests/policies/ApplicationPolicyTest.java   | 132 ++++++++++++--
 .../tests/policies/AutoscalingPolicyTest.java   |  95 +++++++++-
 .../tests/policies/DeploymentPolicyTest.java    | 145 ++++++++++++++--
 ...cation-policy-application-policy-test-1.json |  18 ++
 ...cation-policy-application-policy-test-2.json |  18 ++
 ...caling-policy-autoscaling-policy-test-1.json |  14 ++
 ...caling-policy-autoscaling-policy-test-2.json |  14 ++
 ...loyment-policy-deployment-policy-test-1.json |  32 ++++
 ...loyment-policy-deployment-policy-test-2.json |  32 ++++
 .../sample-applications-test-1.json             |  86 +++++++++
 .../sample-applications-test-2.json             |  86 +++++++++
 .../src/test/resources/stratos-testing.xml      |  12 +-
 14 files changed, 814 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
index 4ca3632..0de17e1 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.stratos.integration.tests.application;
 
+import com.google.gson.reflect.TypeToken;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.common.beans.application.ApplicationBean;
@@ -27,12 +28,13 @@ import org.apache.stratos.common.beans.cartridge.CartridgeGroupReferenceBean;
 import org.apache.stratos.common.beans.cartridge.CartridgeReferenceBean;
 import org.apache.stratos.integration.tests.RestConstants;
 import org.apache.stratos.integration.tests.StratosTestServerManager;
-import org.apache.stratos.messaging.domain.application.Group;
 import org.testng.annotations.Test;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.*;
 
 /**
  * Sample application tests with application add, .
@@ -201,7 +203,167 @@ public class SampleApplicationsTest extends StratosTestServerManager {
 
             ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
                     "g-sc-G123-1-sample-applications-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
-            assertEquals(beanRemoved, null);
+            assertNull(beanRemoved);
+
+            removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1-sample-applications-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(removedGroup, true);
+
+            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1-sample-applications-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC1, true);
+
+            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2-sample-applications-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC2, true);
+
+            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3-sample-applications-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC3, true);
+
+            removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, true);
+
+            removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-sample-applications-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, true);
+
+            removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-sample-applications-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, true);
+
+            boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-sample-applications-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(String.format("[Network partition] network-partition-sample-applications-test-2 " +
+                    "could not be removed for [application] g-sc-G123-1-sample-applications-test"), removedN2, true);
+
+            log.info("-------------------------------Ended application test case-------------------------------");
+
+        } catch (Exception e) {
+            log.error("An error occurred while handling application test case", e);
+            assertTrue("An error occurred while handling application test case", false);
+        }
+    }
+
+    @Test
+    public void testApplicationList() {
+        log.info("-------------------------------Started application listtest case-------------------------------");
+        try {
+            String autoscalingPolicyId = "autoscaling-policy-sample-applications-test";
+
+            boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
+                            + "/" + autoscalingPolicyId + ".json",
+                    RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(addedScalingPolicy, true);
+
+            boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1-sample-applications-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC1, true);
+
+            boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2-sample-applications-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC2, true);
+
+            boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3-sample-applications-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC3, true);
+
+            boolean addedG1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+                            "/" + "cartrdige-nested-sample-applications-test.json", RestConstants.CARTRIDGE_GROUPS,
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(addedG1, true);
+
+            CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, "G1-sample-applications-test",
+                            CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(beanG1.getName(), "G1-sample-applications-test");
+
+            boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-sample-applications-test-1.json",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(addedN1, true);
+
+            boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-sample-applications-test-2.json",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(addedN2, true);
+
+            boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                            "deployment-policy-sample-applications-test.json",
+                    RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(addedDep, true);
+
+            String app1 = "sample-applications-test-1";
+            String app2 = "sample-applications-test-2";
+            boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+                            app1 + ".json", RestConstants.APPLICATIONS,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(added, true);
+
+            added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+                            app2 + ".json", RestConstants.APPLICATIONS,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(added, true);
+
+            Type listType = new TypeToken<ArrayList<ApplicationBean>>() {
+            }.getType();
+
+            List<ApplicationBean> applicationList = (List<ApplicationBean>) restClient.
+                    listEntity(RestConstants.APPLICATIONS,
+                            listType, RestConstants.APPLICATIONS_NAME);
+            assertEquals(applicationList.size(), 2);
+
+            ApplicationBean bean1 = null;
+            for (ApplicationBean applicationBean : applicationList) {
+                if (applicationBean.getApplicationId().equals(app1)) {
+                    bean1 = applicationBean;
+                }
+            }
+            assertNotNull(bean1);
+
+            ApplicationBean bean2 = null;
+            for (ApplicationBean applicationBean : applicationList) {
+                if (applicationBean.getApplicationId().equals(app2)) {
+                    bean2 = applicationBean;
+                }
+            }
+            assertNotNull(bean2);
+
+
+            boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, app1,
+                    RestConstants.APPLICATIONS_NAME);
+            assertTrue(removed);
+
+            ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+                    app1, ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertNull(beanRemoved);
+
+            boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1-sample-applications-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertFalse(removedGroup);
+
+            boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertFalse(removedAuto);
+
+            boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-sample-applications-test-1",
+                    RestConstants.NETWORK_PARTITIONS_NAME);
+            //Trying to remove the used network partition
+            assertFalse(removedNet);
+
+            boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-sample-applications-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertFalse(removedDep);
+
+            removed = restClient.removeEntity(RestConstants.APPLICATIONS, app2,
+                    RestConstants.APPLICATIONS_NAME);
+            assertTrue(removed);
+
+            beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+                    app2, ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertNull(beanRemoved);
 
             removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1-sample-applications-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
@@ -234,7 +396,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-sample-applications-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(String.format("[Network partition] network-partition-sample-applications-test-2 " +
-                    "could not be removed for [application] g-sc-G123-1-sample-applications-test"),removedN2, true);
+                    "could not be removed for [application] g-sc-G123-1-sample-applications-test"), removedN2, true);
 
             log.info("-------------------------------Ended application test case-------------------------------");
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
index 7b413c1..891b3f2 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
@@ -51,7 +51,7 @@ public class CartridgeTest extends StratosTestServerManager {
             boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
                             cartridgeType + ".json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(added, true);
+            assertTrue(added);
             CartridgeBean bean = (CartridgeBean) restClient.
                     getEntity(RestConstants.CARTRIDGES, cartridgeType,
                             CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
@@ -85,7 +85,7 @@ public class CartridgeTest extends StratosTestServerManager {
             boolean updated = restClient.updateEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
                             cartridgeType + "-v1.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(updated, true);
+            assertTrue(updated);
             CartridgeBean updatedBean = (CartridgeBean) restClient.
                     getEntity(RestConstants.CARTRIDGES, cartridgeType,
                             CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
@@ -118,12 +118,12 @@ public class CartridgeTest extends StratosTestServerManager {
 
             boolean removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType,
                     RestConstants.CARTRIDGES_NAME);
-            assertEquals(removed, true);
+            assertTrue(removed);
 
             CartridgeBean beanRemoved = (CartridgeBean) restClient.
                     getEntity(RestConstants.CARTRIDGES, cartridgeType,
                             CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
-            assertEquals(beanRemoved, null);
+            assertNull(beanRemoved);
 
             log.info("---------------------------Ended Cartridge test case-------------------------");
         } catch (Exception e) {
@@ -142,12 +142,12 @@ public class CartridgeTest extends StratosTestServerManager {
             boolean added1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
                             cartridgeType1 + ".json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(added1, true);
+            assertTrue(added1);
 
             boolean added2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
                             cartridgeType2 + ".json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(added2, true);
+            assertTrue(added2);
 
             Type listType = new TypeToken<ArrayList<CartridgeBean>>() {
             }.getType();
@@ -174,7 +174,7 @@ public class CartridgeTest extends StratosTestServerManager {
 
             boolean removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType1,
                     RestConstants.CARTRIDGES_NAME);
-            assertEquals(removed, true);
+            assertTrue(removed);
 
             CartridgeBean beanRemoved = (CartridgeBean) restClient.
                     getEntity(RestConstants.CARTRIDGES, cartridgeType1,
@@ -183,12 +183,12 @@ public class CartridgeTest extends StratosTestServerManager {
 
             removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType2,
                     RestConstants.CARTRIDGES_NAME);
-            assertEquals(removed, true);
+            assertTrue(removed);
 
             beanRemoved = (CartridgeBean) restClient.
                     getEntity(RestConstants.CARTRIDGES, cartridgeType2,
                             CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
-            assertEquals(beanRemoved, null);
+            assertNull(beanRemoved);
 
             log.info("---------------------------Ended Cartridge list test case-------------------------");
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/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 bced0ff..98ffae1 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
@@ -19,6 +19,7 @@
 
 package org.apache.stratos.integration.tests.policies;
 
+import com.google.gson.reflect.TypeToken;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.common.beans.PropertyBean;
@@ -28,8 +29,11 @@ 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.assertTrue;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.*;
 
 /**
  * Test to handle Network partition CRUD operations
@@ -48,17 +52,17 @@ public class ApplicationPolicyTest extends StratosTestServerManager {
             boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
                             "network-partition-application-policy-test-1" + ".json",
                     RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(addedN1, true);
+            assertTrue(addedN1);
 
             boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
                             "network-partition-application-policy-test-2" + ".json",
                     RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(addedN2, true);
+            assertTrue(addedN2);
 
             boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
                             applicationPolicyId + ".json",
                     RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME);
-            assertEquals(addedDep, true);
+            assertTrue(addedDep);
 
             ApplicationPolicyBean bean = (ApplicationPolicyBean) restClient.
                     getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
@@ -87,41 +91,141 @@ public class ApplicationPolicyTest extends StratosTestServerManager {
                 }
             }
             if (!algoFound) {
-                assertTrue(String.format("The networkPartitionGroups property is not found in %s",
-                        applicationPolicyId), false);
+                assertNull(String.format("The networkPartitionGroups property is not found in %s",
+                        applicationPolicyId));
             }
 
             boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
             //Trying to remove the used network partition
-            assertEquals(removedNet, false);
+            assertFalse(removedNet);
 
             boolean removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
                     applicationPolicyId, RestConstants.APPLICATION_POLICIES_NAME);
-            assertEquals(removedDep, true);
+            assertTrue(removedDep);
 
             ApplicationPolicyBean beanRemovedDep = (ApplicationPolicyBean) restClient.
                     getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
                             ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
-            assertEquals(beanRemovedDep, null);
+            assertNull(beanRemovedDep);
+
+            boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(removedN1);
+
+            NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
+                    getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-1",
+                            NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertNull(beanRemovedN1);
+
+            boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-application-policy-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(removedN2);
+
+            NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
+                    getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-2",
+                            NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertNull(beanRemovedN2);
+
+            log.info("-------------------------Ended deployment policy test case-------------------------");
+
+        } catch (Exception e) {
+            log.error("An error occurred while handling deployment policy", e);
+            assertTrue("An error occurred while handling deployment policy", false);
+        }
+    }
+
+    @Test
+    public void testApplicationPolicyList() {
+        try {
+            String applicationPolicyId1 = "application-policy-application-policy-test-1";
+            String applicationPolicyId2 = "application-policy-application-policy-test-2";
+            log.info("-------------------------Started Application policy list test case-------------------------");
+
+            boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-application-policy-test-1" + ".json",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(addedN1);
+
+            boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-application-policy-test-2" + ".json",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(addedN2);
+
+            boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+                            applicationPolicyId1 + ".json",
+                    RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME);
+            assertTrue(addedDep);
+
+            addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+                            applicationPolicyId2 + ".json",
+                    RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME);
+            assertTrue(addedDep);
+
+            Type listType = new TypeToken<ArrayList<ApplicationPolicyBean>>() {
+            }.getType();
+
+            List<ApplicationPolicyBean> applicationPolicyList = (List<ApplicationPolicyBean>) restClient.
+                    listEntity(RestConstants.APPLICATION_POLICIES,
+                            listType, RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(applicationPolicyList.size(), 2);
+
+            ApplicationPolicyBean bean1 = null;
+            for (ApplicationPolicyBean applicationPolicyBean : applicationPolicyList) {
+                if (applicationPolicyBean.getId().equals(applicationPolicyId1)) {
+                    bean1 = applicationPolicyBean;
+                }
+            }
+            assertNotNull(bean1);
+
+            ApplicationPolicyBean bean2 = null;
+            for (ApplicationPolicyBean applicationPolicyBean : applicationPolicyList) {
+                if (applicationPolicyBean.getId().equals(applicationPolicyId2)) {
+                    bean2 = applicationPolicyBean;
+                }
+            }
+            assertNotNull(bean2);
+
+            boolean removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+                    applicationPolicyId1, RestConstants.APPLICATION_POLICIES_NAME);
+            assertTrue(removedDep);
+
+            ApplicationPolicyBean beanRemovedDep = (ApplicationPolicyBean) restClient.
+                    getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId1,
+                            ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
+            assertNull(beanRemovedDep);
+
+            boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+            //Trying to remove the used network partition
+            assertFalse(removedNet);
+
+            removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+                    applicationPolicyId2, RestConstants.APPLICATION_POLICIES_NAME);
+            assertTrue(removedDep);
+
+            beanRemovedDep = (ApplicationPolicyBean) restClient.
+                    getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId2,
+                            ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
+            assertNull(beanRemovedDep);
 
             boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedN1, true);
+            assertTrue(removedN1);
 
             NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
                     getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-1",
                             NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(beanRemovedN1, null);
+            assertNull(beanRemovedN1);
 
             boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-application-policy-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedN2, true);
+            assertTrue(removedN2);
 
             NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
                     getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-2",
                             NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(beanRemovedN2, null);
+            assertNull(beanRemovedN2);
 
             log.info("-------------------------Ended deployment policy test case-------------------------");
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java
index 9a164c5..ddded1c 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.stratos.integration.tests.policies;
 
+import com.google.gson.reflect.TypeToken;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
@@ -25,8 +26,11 @@ 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.assertTrue;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.*;
 
 /**
  * Test to handle autoscaling policy CRUD operations
@@ -44,7 +48,7 @@ public class AutoscalingPolicyTest extends StratosTestServerManager {
             boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + policyId + ".json",
                     RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
 
-            assertEquals(String.format("Autoscaling policy did not added: [autoscaling-policy-id] %s", policyId), added, true);
+            assertTrue(String.format("Autoscaling policy did not added: [autoscaling-policy-id] %s", policyId), added);
             AutoscalePolicyBean bean = (AutoscalePolicyBean) restClient.
                     getEntity(RestConstants.AUTOSCALING_POLICIES, policyId,
                             AutoscalePolicyBean.class, RestConstants.AUTOSCALING_POLICIES_NAME);
@@ -61,7 +65,7 @@ public class AutoscalingPolicyTest extends StratosTestServerManager {
             boolean updated = restClient.updateEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + policyId + "-v1.json",
                     RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
 
-            assertEquals(String.format("[autoscaling-policy-id] %s update failed", policyId), updated, true);
+            assertTrue(String.format("[autoscaling-policy-id] %s update failed", policyId), updated);
             AutoscalePolicyBean updatedBean = (AutoscalePolicyBean) restClient.getEntity(
                     RestConstants.AUTOSCALING_POLICIES, policyId,
                     AutoscalePolicyBean.class, RestConstants.AUTOSCALING_POLICIES_NAME);
@@ -74,18 +78,93 @@ public class AutoscalingPolicyTest extends StratosTestServerManager {
 
             boolean removed = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     policyId, RestConstants.AUTOSCALING_POLICIES_NAME);
-            assertEquals(String.format("[autoscaling-policy-id] %s couldn't be removed", policyId),
-                    removed, true);
+            assertTrue(String.format("[autoscaling-policy-id] %s couldn't be removed", policyId),
+                    removed);
 
             AutoscalePolicyBean beanRemoved = (AutoscalePolicyBean) restClient.getEntity(
                     RestConstants.AUTOSCALING_POLICIES, policyId,
                     AutoscalePolicyBean.class, RestConstants.AUTOSCALING_POLICIES_NAME);
-            assertEquals(String.format("[autoscaling-policy-id] %s didn't get removed successfully",
-                    policyId), beanRemoved, null);
+            assertNull(String.format("[autoscaling-policy-id] %s didn't get removed successfully",
+                    policyId), beanRemoved);
             log.info("-------------------------Ended autoscaling policy test case---------------------------");
         } catch (Exception e) {
             log.error("An error occurred while handling [autoscaling policy] " + policyId, e);
             assertTrue("An error occurred while handling [autoscaling policy] " + policyId, false);
         }
     }
+
+    @Test
+    public void testAutoscalingPolicyList() {
+        log.info("-------------------------Started autoscaling policy list test case-------------------------");
+        String policyId1 = "autoscaling-policy-autoscaling-policy-test-1";
+        String policyId2 = "autoscaling-policy-autoscaling-policy-test-2";
+        try {
+            boolean added = restClient.addEntity(RESOURCES_PATH +
+                            RestConstants.AUTOSCALING_POLICIES_PATH + "/" + policyId1 + ".json",
+                    RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
+
+            assertTrue(String.format("Autoscaling policy did not added: [autoscaling-policy-id] %s",
+                    policyId1), added);
+
+            added = restClient.addEntity(RESOURCES_PATH +
+                            RestConstants.AUTOSCALING_POLICIES_PATH + "/" + policyId2 + ".json",
+                    RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
+
+            assertTrue(String.format("Autoscaling policy did not added: [autoscaling-policy-id] %s",
+                    policyId2), added);
+
+
+            Type listType = new TypeToken<ArrayList<AutoscalePolicyBean>>() {
+            }.getType();
+
+            List<AutoscalePolicyBean> autoscalingPolicyList = (List<AutoscalePolicyBean>) restClient.
+                    listEntity(RestConstants.AUTOSCALING_POLICIES,
+                            listType, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(autoscalingPolicyList.size(), 2);
+
+            AutoscalePolicyBean bean1 = null;
+            for (AutoscalePolicyBean autoscalePolicyBean : autoscalingPolicyList) {
+                if (autoscalePolicyBean.getId().equals(policyId1)) {
+                    bean1 = autoscalePolicyBean;
+                }
+            }
+            assertNotNull(bean1);
+
+            AutoscalePolicyBean bean2 = null;
+            for (AutoscalePolicyBean autoscalePolicyBean : autoscalingPolicyList) {
+                if (autoscalePolicyBean.getId().equals(policyId2)) {
+                    bean2 = autoscalePolicyBean;
+                }
+            }
+            assertNotNull(bean2);
+
+
+            boolean removed = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    policyId1, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertTrue(String.format("[autoscaling-policy-id] %s couldn't be removed", policyId1),
+                    removed);
+
+            AutoscalePolicyBean beanRemoved = (AutoscalePolicyBean) restClient.getEntity(
+                    RestConstants.AUTOSCALING_POLICIES, policyId1,
+                    AutoscalePolicyBean.class, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertNull(String.format("[autoscaling-policy-id] %s didn't get removed successfully",
+                    policyId1), beanRemoved);
+
+            removed = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    policyId2, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertTrue(String.format("[autoscaling-policy-id] %s couldn't be removed", policyId2),
+                    removed);
+
+            beanRemoved = (AutoscalePolicyBean) restClient.getEntity(
+                    RestConstants.AUTOSCALING_POLICIES, policyId2,
+                    AutoscalePolicyBean.class, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertNull(String.format("[autoscaling-policy-id] %s didn't get removed successfully",
+                    policyId2), beanRemoved);
+
+            log.info("-------------------------Ended autoscaling policy list test case---------------------------");
+        } catch (Exception e) {
+            log.error("An error occurred while handling [autoscaling policy] list", e);
+            assertTrue("An error occurred while handling [autoscaling policy] list", false);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
index 4401443..6cc0101 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
@@ -19,9 +19,9 @@
 
 package org.apache.stratos.integration.tests.policies;
 
+import com.google.gson.reflect.TypeToken;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
 import org.apache.stratos.common.beans.partition.NetworkPartitionReferenceBean;
 import org.apache.stratos.common.beans.partition.PartitionReferenceBean;
 import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
@@ -29,8 +29,11 @@ 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.assertTrue;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.*;
 
 /**
  * Test to handle Deployment policy CRUD operations
@@ -49,17 +52,17 @@ public class DeploymentPolicyTest extends StratosTestServerManager {
             boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
                             "network-partition-deployment-policy-test-1" + ".json",
                     RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(addedN1, true);
+            assertTrue(addedN1);
 
             boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
                             "network-partition-deployment-policy-test-2" + ".json",
                     RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(addedN2, true);
+            assertTrue(addedN2);
 
             boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
                             deploymentPolicyId + ".json",
                     RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(addedDep, true);
+            assertTrue(addedDep);
 
             DeploymentPolicyBean bean = (DeploymentPolicyBean) restClient.
                     getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
@@ -93,13 +96,13 @@ public class DeploymentPolicyTest extends StratosTestServerManager {
             boolean updated = restClient.updateEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
                             "network-partition-deployment-policy-test-1-v1.json",
                     RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(updated, true);
+            assertTrue(updated);
 
             //update deployment policy with new partition and max values
             boolean updatedDep = restClient.updateEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH +
                             "/" + deploymentPolicyId + "-v1.json", RestConstants.DEPLOYMENT_POLICIES,
                     RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(updatedDep, true);
+            assertTrue(updatedDep);
 
             DeploymentPolicyBean updatedBean = (DeploymentPolicyBean) restClient.
                     getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
@@ -135,34 +138,34 @@ public class DeploymentPolicyTest extends StratosTestServerManager {
             boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-deployment-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
             //Trying to remove the used network partition
-            assertEquals(removedNet, false);
+            assertFalse(removedNet);
 
             boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
                     deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(removedDep, true);
+            assertTrue(removedDep);
 
             DeploymentPolicyBean beanRemovedDep = (DeploymentPolicyBean) restClient.
                     getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
                             DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(beanRemovedDep, null);
+            assertNull(beanRemovedDep);
 
             boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-deployment-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedN1, true);
+            assertTrue(removedN1);
 
-            NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
+            DeploymentPolicyBean beanRemovedN1 = (DeploymentPolicyBean) restClient.
                     getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-deployment-policy-test-1",
-                            NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(beanRemovedN1, null);
+                            DeploymentPolicyBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertNull(beanRemovedN1);
 
             boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-deployment-policy-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedN2, true);
+            assertTrue(removedN2);
 
-            NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
+            DeploymentPolicyBean beanRemovedN2 = (DeploymentPolicyBean) restClient.
                     getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-deployment-policy-test-2",
-                            NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(beanRemovedN2, null);
+                            DeploymentPolicyBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertNull(beanRemovedN2);
 
             log.info("-------------------------Ended deployment policy test case-------------------------");
 
@@ -171,4 +174,108 @@ public class DeploymentPolicyTest extends StratosTestServerManager {
             assertTrue("An error occurred while handling deployment policy", false);
         }
     }
+
+
+    @Test
+    public void testDeploymentPolicyList() {
+        try {
+            String deploymentPolicyId1 = "deployment-policy-deployment-policy-test-1";
+            String deploymentPolicyId2 = "deployment-policy-deployment-policy-test-2";
+
+            log.info("-------------------------Started deployment policy list test case-------------------------");
+
+            boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-deployment-policy-test-1" + ".json",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(addedN1);
+
+            boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-deployment-policy-test-2" + ".json",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(addedN2);
+
+            boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                            deploymentPolicyId1 + ".json",
+                    RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertTrue(addedDep);
+
+
+            addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                            deploymentPolicyId2 + ".json",
+                    RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertTrue(addedDep);
+
+
+            Type listType = new TypeToken<ArrayList<DeploymentPolicyBean>>() {
+            }.getType();
+
+            List<DeploymentPolicyBean> cartridgeList = (List<DeploymentPolicyBean>) restClient.
+                    listEntity(RestConstants.DEPLOYMENT_POLICIES,
+                            listType, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(cartridgeList.size(), 2);
+
+            DeploymentPolicyBean bean1 = null;
+            for (DeploymentPolicyBean deploymentPolicyBean : cartridgeList) {
+                if (deploymentPolicyBean.getId().equals(deploymentPolicyId1)) {
+                    bean1 = deploymentPolicyBean;
+                }
+            }
+            assertNotNull(bean1);
+
+            DeploymentPolicyBean bean2 = null;
+            for (DeploymentPolicyBean deploymentPolicyBean : cartridgeList) {
+                if (deploymentPolicyBean.getId().equals(deploymentPolicyId2)) {
+                    bean2 = deploymentPolicyBean;
+                }
+            }
+            assertNotNull(bean2);
+
+            boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    deploymentPolicyId1, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertTrue(removedDep);
+
+            DeploymentPolicyBean beanRemovedDep = (DeploymentPolicyBean) restClient.
+                    getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId1,
+                            DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertNull(beanRemovedDep);
+
+            boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-deployment-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+            //Trying to remove the used network partition
+            assertFalse(removedNet);
+
+            removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    deploymentPolicyId2, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertTrue(removedDep);
+
+            beanRemovedDep = (DeploymentPolicyBean) restClient.
+                    getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId2,
+                            DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertNull(beanRemovedDep);
+
+            boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-deployment-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(removedN1);
+
+            DeploymentPolicyBean beanRemovedN1 = (DeploymentPolicyBean) restClient.
+                    getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-deployment-policy-test-1",
+                            DeploymentPolicyBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertNull(beanRemovedN1);
+
+            boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-deployment-policy-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(removedN2);
+
+            DeploymentPolicyBean beanRemovedN2 = (DeploymentPolicyBean) restClient.
+                    getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-deployment-policy-test-2",
+                            DeploymentPolicyBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertNull(beanRemovedN2);
+
+            log.info("-------------------------Ended deployment policy list test case-------------------------");
+
+        } catch (Exception e) {
+            log.error("An error occurred while handling deployment policy", e);
+            assertTrue("An error occurred while handling deployment policy", false);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-application-policy-test-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-application-policy-test-1.json b/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-application-policy-test-1.json
new file mode 100644
index 0000000..da3e8ef
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-application-policy-test-1.json
@@ -0,0 +1,18 @@
+{
+    "id": "application-policy-application-policy-test-1",
+    "algorithm": "one-after-another",
+    "networkPartitions": [
+        "network-partition-application-policy-test-1",
+        "network-partition-application-policy-test-2"
+    ],
+    "properties": [
+        {
+            "name": "networkPartitionGroups",
+            "value": "network-partition-application-policy-test-1,network-partition-application-policy-test-2"
+        },
+        {
+            "name": "key-2",
+            "value": "value-2"
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-application-policy-test-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-application-policy-test-2.json b/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-application-policy-test-2.json
new file mode 100644
index 0000000..ec3715c
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-application-policy-test-2.json
@@ -0,0 +1,18 @@
+{
+    "id": "application-policy-application-policy-test-2",
+    "algorithm": "one-after-another",
+    "networkPartitions": [
+        "network-partition-application-policy-test-1",
+        "network-partition-application-policy-test-2"
+    ],
+    "properties": [
+        {
+            "name": "networkPartitionGroups",
+            "value": "network-partition-application-policy-test-1,network-partition-application-policy-test-2"
+        },
+        {
+            "name": "key-2",
+            "value": "value-2"
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-autoscaling-policy-test-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-autoscaling-policy-test-1.json b/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-autoscaling-policy-test-1.json
new file mode 100644
index 0000000..d7765b9
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-autoscaling-policy-test-1.json
@@ -0,0 +1,14 @@
+{
+    "id": "autoscaling-policy-autoscaling-policy-test-1",
+    "loadThresholds": {
+        "requestsInFlight": {
+            "threshold": 35
+        },
+        "memoryConsumption": {
+            "threshold": 45
+        },
+        "loadAverage": {
+            "threshold": 25
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-autoscaling-policy-test-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-autoscaling-policy-test-2.json b/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-autoscaling-policy-test-2.json
new file mode 100644
index 0000000..03f3a01
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-autoscaling-policy-test-2.json
@@ -0,0 +1,14 @@
+{
+    "id": "autoscaling-policy-autoscaling-policy-test-2",
+    "loadThresholds": {
+        "requestsInFlight": {
+            "threshold": 35
+        },
+        "memoryConsumption": {
+            "threshold": 45
+        },
+        "loadAverage": {
+            "threshold": 25
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-deployment-policy-test-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-deployment-policy-test-1.json b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-deployment-policy-test-1.json
new file mode 100644
index 0000000..edab5bd
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-deployment-policy-test-1.json
@@ -0,0 +1,32 @@
+{
+    "id": "deployment-policy-deployment-policy-test-1",
+    "networkPartitions": [
+        {
+            "id": "network-partition-deployment-policy-test-1",
+            "partitionAlgo": "one-after-another",
+            "partitions": [
+                {
+                    "id": "partition-1",
+                    "partitionMax": 20
+                }
+            ]
+        },
+        {
+            "id": "network-partition-deployment-policy-test-2",
+            "partitionAlgo": "round-robin",
+            "partitions": [
+                {
+                    "id": "network-partition-6-partition-1",
+                    "partitionMax": 10
+                },
+                {
+                    "id": "network-partition-6-partition-2",
+                    "partitionMax": 9
+                }
+            ]
+        }
+    ]
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-deployment-policy-test-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-deployment-policy-test-2.json b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-deployment-policy-test-2.json
new file mode 100644
index 0000000..18cb31c
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-deployment-policy-test-2.json
@@ -0,0 +1,32 @@
+{
+    "id": "deployment-policy-deployment-policy-test-2",
+    "networkPartitions": [
+        {
+            "id": "network-partition-deployment-policy-test-1",
+            "partitionAlgo": "one-after-another",
+            "partitions": [
+                {
+                    "id": "partition-1",
+                    "partitionMax": 20
+                }
+            ]
+        },
+        {
+            "id": "network-partition-deployment-policy-test-2",
+            "partitionAlgo": "round-robin",
+            "partitions": [
+                {
+                    "id": "network-partition-6-partition-1",
+                    "partitionMax": 10
+                },
+                {
+                    "id": "network-partition-6-partition-2",
+                    "partitionMax": 9
+                }
+            ]
+        }
+    ]
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/sample-applications-test-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/sample-applications-test-1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/sample-applications-test-1.json
new file mode 100644
index 0000000..532bee6
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/sample-applications-test-1.json
@@ -0,0 +1,86 @@
+{
+    "alias": "sample-applications-test-1",
+    "applicationId": "sample-applications-test-1",
+    "components": {
+        "cartridges": [],
+        "groups": [
+            {
+                "name": "G1-sample-applications-test",
+                "groupMaxInstances": 1,
+                "groupMinInstances": 1,
+                "alias": "group1-sample-applications-test",
+                "cartridges": [
+                    {
+                        "cartridgeMin": 1,
+                        "cartridgeMax": 2,
+                        "type": "c1-sample-applications-test",
+                        "subscribableInfo": {
+                            "alias": "c1-1x0-sample-applications-test",
+                            "deploymentPolicy": "deployment-policy-sample-applications-test",
+                            "artifactRepository": {
+                                "repoUsername": "user",
+                                "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+                                "privateRepo": true,
+                                "repoPassword": "c-policy"
+                            },
+                            "autoscalingPolicy": "autoscaling-policy-sample-applications-test"
+                        }
+                    }
+                ],
+                "groups": [
+                    {
+                        "name": "G2-sample-applications-test",
+                        "groupMaxInstances": 1,
+                        "groupMinInstances": 1,
+                        "alias": "group2-sample-applications-test",
+                        "cartridges": [
+                            {
+                                "cartridgeMin": 1,
+                                "cartridgeMax": 2,
+                                "type": "c2-sample-applications-test",
+                                "subscribableInfo": {
+                                    "alias": "c2-1x0-sample-applications-test",
+                                    "deploymentPolicy": "deployment-policy-sample-applications-test",
+                                    "artifactRepository": {
+                                        "repoUsername": "user",
+                                        "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+                                        "privateRepo": true,
+                                        "repoPassword": "c-policy"
+                                    },
+                                    "autoscalingPolicy": "autoscaling-policy-sample-applications-test"
+                                }
+                            }
+                        ],
+                        "groups": [
+                            {
+                                "name": "G3-sample-applications-test",
+                                "groupMaxInstances": 2,
+                                "groupMinInstances": 1,
+                                "deploymentPolicy": "deployment-policy-sample-applications-test",
+                                "alias": "group3-sample-applications-test",
+                                "cartridges": [
+                                    {
+                                        "cartridgeMin": 1,
+                                        "cartridgeMax": 2,
+                                        "type": "c3-sample-applications-test",
+                                        "subscribableInfo": {
+                                            "alias": "c3-1x0-sample-applications-test",
+                                            "artifactRepository": {
+                                                "repoUsername": "user",
+                                                "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+                                                "privateRepo": true,
+                                                "repoPassword": "c-policy"
+                                            },
+                                            "autoscalingPolicy": "autoscaling-policy-sample-applications-test"
+                                        }
+                                    }
+                                ],
+                                "groups": []
+                            }
+                        ]
+                    }
+                ]
+            }
+        ]
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/sample-applications-test-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/sample-applications-test-2.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/sample-applications-test-2.json
new file mode 100644
index 0000000..6427d7e
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/sample-applications-test-2.json
@@ -0,0 +1,86 @@
+{
+    "alias": "sample-applications-test-2",
+    "applicationId": "sample-applications-test-2",
+    "components": {
+        "cartridges": [],
+        "groups": [
+            {
+                "name": "G1-sample-applications-test",
+                "groupMaxInstances": 1,
+                "groupMinInstances": 1,
+                "alias": "group1-sample-applications-test",
+                "cartridges": [
+                    {
+                        "cartridgeMin": 1,
+                        "cartridgeMax": 2,
+                        "type": "c1-sample-applications-test",
+                        "subscribableInfo": {
+                            "alias": "c1-1x0-sample-applications-test",
+                            "deploymentPolicy": "deployment-policy-sample-applications-test",
+                            "artifactRepository": {
+                                "repoUsername": "user",
+                                "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+                                "privateRepo": true,
+                                "repoPassword": "c-policy"
+                            },
+                            "autoscalingPolicy": "autoscaling-policy-sample-applications-test"
+                        }
+                    }
+                ],
+                "groups": [
+                    {
+                        "name": "G2-sample-applications-test",
+                        "groupMaxInstances": 1,
+                        "groupMinInstances": 1,
+                        "alias": "group2-sample-applications-test",
+                        "cartridges": [
+                            {
+                                "cartridgeMin": 1,
+                                "cartridgeMax": 2,
+                                "type": "c2-sample-applications-test",
+                                "subscribableInfo": {
+                                    "alias": "c2-1x0-sample-applications-test",
+                                    "deploymentPolicy": "deployment-policy-sample-applications-test",
+                                    "artifactRepository": {
+                                        "repoUsername": "user",
+                                        "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+                                        "privateRepo": true,
+                                        "repoPassword": "c-policy"
+                                    },
+                                    "autoscalingPolicy": "autoscaling-policy-sample-applications-test"
+                                }
+                            }
+                        ],
+                        "groups": [
+                            {
+                                "name": "G3-sample-applications-test",
+                                "groupMaxInstances": 2,
+                                "groupMinInstances": 1,
+                                "deploymentPolicy": "deployment-policy-sample-applications-test",
+                                "alias": "group3-sample-applications-test",
+                                "cartridges": [
+                                    {
+                                        "cartridgeMin": 1,
+                                        "cartridgeMax": 2,
+                                        "type": "c3-sample-applications-test",
+                                        "subscribableInfo": {
+                                            "alias": "c3-1x0-sample-applications-test",
+                                            "artifactRepository": {
+                                                "repoUsername": "user",
+                                                "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+                                                "privateRepo": true,
+                                                "repoPassword": "c-policy"
+                                            },
+                                            "autoscalingPolicy": "autoscaling-policy-sample-applications-test"
+                                        }
+                                    }
+                                ],
+                                "groups": []
+                            }
+                        ]
+                    }
+                ]
+            }
+        ]
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/121f118f/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/stratos-testing.xml b/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
index da48aa8..3f66b6b 100644
--- a/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
+++ b/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
@@ -21,22 +21,22 @@
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
 
 <suite name="StratosIntegrationSuite">
-   <!-- <test name="CartridgeTest">
+    <test name="CartridgeTest">
         <classes>
             <class name="org.apache.stratos.integration.tests.group.CartridgeTest" />
         </classes>
-    </test>-->
-    <!--<test name="CartridgeGroupTest" >
+    </test>
+    <test name="CartridgeGroupTest" >
         <classes>
             <class name="org.apache.stratos.integration.tests.group.CartridgeGroupTest" />
         </classes>
-    </test>-->
+    </test>
     <test name="NetworkPartitionTest">
         <classes>
             <class name="org.apache.stratos.integration.tests.policies.NetworkPartitionTest" />
         </classes>
     </test>
-    <!--<test name="ApplicationPolicyTest">
+    <test name="ApplicationPolicyTest">
         <classes>
             <class name="org.apache.stratos.integration.tests.policies.ApplicationPolicyTest" />
         </classes>
@@ -80,5 +80,5 @@
         <classes>
             <class name="org.apache.stratos.integration.tests.application.GroupTerminationBehaviorTest" />
         </classes>
-    </test>-->
+    </test>
 </suite>


[3/4] stratos git commit: adding termination behavior test and list test case for all the artifacts

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
index 684dc03..61f2205 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
@@ -19,17 +19,20 @@
 
 package org.apache.stratos.integration.tests.policies;
 
+import com.google.gson.reflect.TypeToken;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
-import org.apache.stratos.common.beans.partition.NetworkPartitionReferenceBean;
 import org.apache.stratos.common.beans.partition.PartitionBean;
 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.assertTrue;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.*;
 
 /**
  * Test to handle Network partition CRUD operations
@@ -49,7 +52,7 @@ public class NetworkPartitionTest extends StratosTestServerManager {
                             networkPartitionId + ".json",
                     RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
 
-            assertEquals(added, true);
+            assertTrue(added);
             NetworkPartitionBean bean = (NetworkPartitionBean) restClient.
                     getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
                             NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
@@ -65,7 +68,7 @@ public class NetworkPartitionTest extends StratosTestServerManager {
                             networkPartitionId + "-v1.json",
                     RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
 
-            assertEquals(updated, true);
+            assertTrue(updated);
             NetworkPartitionBean updatedBean = (NetworkPartitionBean) restClient.
                     getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
                             NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
@@ -81,12 +84,80 @@ public class NetworkPartitionTest extends StratosTestServerManager {
 
             boolean removed = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     networkPartitionId, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removed, true);
+            assertTrue(removed);
 
             NetworkPartitionBean beanRemoved = (NetworkPartitionBean) restClient.
                     getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
                             NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(beanRemoved, null);
+            assertNull(beanRemoved);
+
+            log.info("-------------------------Ended network partition test case-------------------------");
+        } catch (Exception e) {
+            log.error("An error occurred while handling network partitions", e);
+            assertTrue("An error occurred while handling network partitions", false);
+        }
+    }
+
+    @Test
+    public void testNetworkPartitionList() {
+        try {
+            String networkPartitionId1 = "network-partition-network-partition-test-1";
+            String networkPartitionId2 = "network-partition-network-partition-test-2";
+
+            log.info("-------------------------Started network partition list test case-------------------------");
+
+            boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            networkPartitionId1 + ".json",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(added);
+
+            added = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            networkPartitionId2 + ".json",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(added);
+
+            Type listType = new TypeToken<ArrayList<NetworkPartitionBean>>() {
+            }.getType();
+
+            List<NetworkPartitionBean> cartridgeList = (List<NetworkPartitionBean>) restClient.
+                    listEntity(RestConstants.NETWORK_PARTITIONS,
+                            listType, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(cartridgeList.size(), 2);
+
+            NetworkPartitionBean bean1 = null;
+            for (NetworkPartitionBean networkPartitionBean : cartridgeList) {
+                if (networkPartitionBean.getId().equals(networkPartitionId1)) {
+                    bean1 = networkPartitionBean;
+                }
+            }
+            assertNotNull(bean1);
+
+            NetworkPartitionBean bean2 = null;
+            for (NetworkPartitionBean networkPartitionBean : cartridgeList) {
+                if (networkPartitionBean.getId().equals(networkPartitionId2)) {
+                    bean2 = networkPartitionBean;
+                }
+            }
+            assertNotNull(bean2);
+
+
+            boolean removed = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    networkPartitionId1, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(removed);
+
+            NetworkPartitionBean beanRemoved = (NetworkPartitionBean) restClient.
+                    getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId1,
+                            NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertNull(beanRemoved);
+
+            removed = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    networkPartitionId2, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertTrue(removed);
+
+            beanRemoved = (NetworkPartitionBean) restClient.
+                    getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId2,
+                            NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertNull(beanRemoved);
 
             log.info("-------------------------Ended network partition test case-------------------------");
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
index 34a9d75..9702a31 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
@@ -34,6 +34,7 @@ import org.apache.http.impl.conn.PoolingClientConnectionManager;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
+import java.lang.reflect.Type;
 import java.net.URI;
 
 /**
@@ -263,6 +264,35 @@ public class RestClient {
         }
     }
 
+    public Object listEntity(String resourcePath, Type type, String entityName) {
+        try {
+            URI uri = new URIBuilder(this.endPoint + resourcePath).build();
+            HttpResponse response = doGet(uri);
+            GsonBuilder gsonBuilder = new GsonBuilder();
+            Gson gson = gsonBuilder.create();
+            if (response != null) {
+                if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+                    return gson.fromJson(response.getContent(), type);
+                } else if (response.getStatusCode() == 404) {
+                    return null;
+                } else {
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(),
+                            ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            String msg = "An unknown error occurred while getting the " + entityName;
+            log.error(msg);
+            throw new RuntimeException(msg);
+        } catch (Exception e) {
+            String message = "Could not get " + entityName;
+            log.error(message, e);
+            throw new RuntimeException(message, e);
+        }
+    }
+
     public boolean removeEntity(String resourcePath, String identifier, String entityName) {
         try {
             URI uri = new URIBuilder(this.endPoint + "/" + resourcePath + "/" + identifier).build();

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/group-1-cartridge-group-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/group-1-cartridge-group-test.json b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/group-1-cartridge-group-test.json
new file mode 100644
index 0000000..a3050f4
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/group-1-cartridge-group-test.json
@@ -0,0 +1,50 @@
+{
+    "name": "group-1-cartridge-group-test",
+    "dependencies": {
+        "terminationBehaviour": "terminate-none",
+        "startupOrders": [
+            {
+                "aliases": [
+                    "group.group5-cartridge-group-test",
+                    "cartridge.c4-1x0-cartridge-group-test"
+                ]
+            }
+        ]
+    },
+    "cartridges": [
+        "c4-cartridge-group-test"
+    ],
+    "groups": [
+        {
+            "name": "G5-cartridge-group-test",
+            "dependencies": {
+                "terminationBehaviour": "terminate-dependents",
+                "startupOrders": [
+                    {
+                        "aliases": [
+                            "group.group6-cartridge-group-test",
+                            "cartridge.c5-1x0-cartridge-group-test"
+                        ]
+                    }
+                ]
+            },
+            "cartridges": [
+                "c5-cartridge-group-test"
+            ],
+            "groups": [
+                {
+                    "name": "G6-cartridge-group-test",
+                    "dependencies": {
+                        "terminationBehaviour": "terminate-all",
+                        "startupOrders": []
+                    },
+                    "cartridges": [
+                        "c6-cartridge-group-test"
+                    ],
+                    "groups": []
+                }
+            ]
+        }
+    ]
+}
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/group-2-cartridge-group-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/group-2-cartridge-group-test.json b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/group-2-cartridge-group-test.json
new file mode 100644
index 0000000..bbe7ae7
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/group-2-cartridge-group-test.json
@@ -0,0 +1,50 @@
+{
+    "name": "group-2-cartridge-group-test",
+    "dependencies": {
+        "terminationBehaviour": "terminate-none",
+        "startupOrders": [
+            {
+                "aliases": [
+                    "group.group5-cartridge-group-test",
+                    "cartridge.c4-1x0-cartridge-group-test"
+                ]
+            }
+        ]
+    },
+    "cartridges": [
+        "c4-cartridge-group-test"
+    ],
+    "groups": [
+        {
+            "name": "G5-cartridge-group-test",
+            "dependencies": {
+                "terminationBehaviour": "terminate-dependents",
+                "startupOrders": [
+                    {
+                        "aliases": [
+                            "group.group6-cartridge-group-test",
+                            "cartridge.c5-1x0-cartridge-group-test"
+                        ]
+                    }
+                ]
+            },
+            "cartridges": [
+                "c5-cartridge-group-test"
+            ],
+            "groups": [
+                {
+                    "name": "G6-cartridge-group-test",
+                    "dependencies": {
+                        "terminationBehaviour": "terminate-all",
+                        "startupOrders": []
+                    },
+                    "cartridges": [
+                        "c6-cartridge-group-test"
+                    ],
+                    "groups": []
+                }
+            ]
+        }
+    ]
+}
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c1-cartridge-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c1-cartridge-test.json b/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c1-cartridge-test.json
new file mode 100755
index 0000000..2251af1
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c1-cartridge-test.json
@@ -0,0 +1,124 @@
+{
+    "category": "Application",
+    "description": "c1-cartridge-test Cartridge",
+    "displayName": "c1-cartridge-test",
+    "host": "qmog.cisco.com",
+    "iaasProvider": [
+        {
+            "imageId": "RegionOne/16e7e35b-0c88-4605-90ce-cbef9e9dde0f",
+            "maxInstanceLimit": "4",
+            "networkInterfaces": [
+                {
+                    "floatingNetworks": [
+                        {
+                            "name": "public",
+                            "networkUuid": "26b4aa2b-06bc-4e4f-a6eb-c19fbc211af6"
+                        }
+                    ],
+                    "name": "core",
+                    "networkUuid": "5e107fbd-4820-47ad-84ea-6f135496f889"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/2cdbd576-8c9b-4c2d-8b1a-0f79dc4fb809"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "phoenix"
+                },
+                {
+                    "name": "autoAssignIp",
+                    "value": "false"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ],
+            "type": "mock"
+        }
+    ],
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "port": "22",
+            "protocol": "http",
+            "proxyPort": "8280"
+        }
+    ],
+    "property": [
+        {
+            "name": "payload_parameter.MB_IP",
+            "value": "octl.qmog.cisco.com"
+        },
+        {
+            "name": "payload_parameter.MB_PORT",
+            "value": "61616"
+        },
+        {
+            "name": "payload_parameter.CEP_IP",
+            "value": "octl.qmog.cisco.com"
+        },
+        {
+            "name": "payload_parameter.CEP_PORT",
+            "value": "7611"
+        },
+        {
+            "name": "payload_parameter.CEP_ADMIN_USERNAME",
+            "value": "admin"
+        },
+        {
+            "name": "payload_parameter.CEP_ADMIN_PASSWORD",
+            "value": "admin"
+        },
+        {
+            "name": "payload_parameter.CERT_TRUSTSTORE",
+            "value": "/opt/apache-stratos-cartridge-agent/security/client-truststore.jks"
+        },
+        {
+            "name": "payload_parameter.TRUSTSTORE_PASSWORD",
+            "value": "wso2carbon"
+        },
+        {
+            "name": "payload_parameter.ENABLE_DATA_PUBLISHER",
+            "value": "false"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_IP",
+            "value": "octl.qmog.cisco.com"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_PORT",
+            "value": "7611"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_SECURE_PORT",
+            "value": "7711"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_ADMIN_USERNAME",
+            "value": "admin"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD",
+            "value": "admin"
+        },
+        {
+            "name": "payload_parameter.QTCM_DNS_SEGMENT",
+            "value": "test"
+        },
+        {
+            "name": "payload_parameter.QTCM_NETWORK_COUNT",
+            "value": "1"
+        },
+        {
+            "name": "payload_parameter.SIMPLE_PROPERTY",
+            "value": "value"
+        }
+    ],
+    "provider": "cisco",
+    "type": "c1-cartridge-test",
+    "version": "1.0"
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c2-cartridge-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c2-cartridge-test.json b/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c2-cartridge-test.json
new file mode 100755
index 0000000..ce821f1
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c2-cartridge-test.json
@@ -0,0 +1,124 @@
+{
+    "category": "Application",
+    "description": "c2-cartridge-test Cartridge",
+    "displayName": "c2-cartridge-test",
+    "host": "qmog.cisco.com",
+    "iaasProvider": [
+        {
+            "imageId": "RegionOne/16e7e35b-0c88-4605-90ce-cbef9e9dde0f",
+            "maxInstanceLimit": "4",
+            "networkInterfaces": [
+                {
+                    "floatingNetworks": [
+                        {
+                            "name": "public",
+                            "networkUuid": "26b4aa2b-06bc-4e4f-a6eb-c19fbc211af6"
+                        }
+                    ],
+                    "name": "core",
+                    "networkUuid": "5e107fbd-4820-47ad-84ea-6f135496f889"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/2cdbd576-8c9b-4c2d-8b1a-0f79dc4fb809"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "phoenix"
+                },
+                {
+                    "name": "autoAssignIp",
+                    "value": "false"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ],
+            "type": "mock"
+        }
+    ],
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "port": "22",
+            "protocol": "http",
+            "proxyPort": "8280"
+        }
+    ],
+    "property": [
+        {
+            "name": "payload_parameter.MB_IP",
+            "value": "octl.qmog.cisco.com"
+        },
+        {
+            "name": "payload_parameter.MB_PORT",
+            "value": "61616"
+        },
+        {
+            "name": "payload_parameter.CEP_IP",
+            "value": "octl.qmog.cisco.com"
+        },
+        {
+            "name": "payload_parameter.CEP_PORT",
+            "value": "7611"
+        },
+        {
+            "name": "payload_parameter.CEP_ADMIN_USERNAME",
+            "value": "admin"
+        },
+        {
+            "name": "payload_parameter.CEP_ADMIN_PASSWORD",
+            "value": "admin"
+        },
+        {
+            "name": "payload_parameter.CERT_TRUSTSTORE",
+            "value": "/opt/apache-stratos-cartridge-agent/security/client-truststore.jks"
+        },
+        {
+            "name": "payload_parameter.TRUSTSTORE_PASSWORD",
+            "value": "wso2carbon"
+        },
+        {
+            "name": "payload_parameter.ENABLE_DATA_PUBLISHER",
+            "value": "false"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_IP",
+            "value": "octl.qmog.cisco.com"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_PORT",
+            "value": "7611"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_SECURE_PORT",
+            "value": "7711"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_ADMIN_USERNAME",
+            "value": "admin"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD",
+            "value": "admin"
+        },
+        {
+            "name": "payload_parameter.QTCM_DNS_SEGMENT",
+            "value": "test"
+        },
+        {
+            "name": "payload_parameter.QTCM_NETWORK_COUNT",
+            "value": "1"
+        },
+        {
+            "name": "payload_parameter.SIMPLE_PROPERTY",
+            "value": "value"
+        }
+    ],
+    "provider": "cisco",
+    "type": "c2-cartridge-test",
+    "version": "1.0"
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/application-policies/application-policy-application-bursting-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/application-policies/application-policy-application-bursting-test.json b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/application-policies/application-policy-application-bursting-test.json
deleted file mode 100644
index 15e757b..0000000
--- a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/application-policies/application-policy-application-bursting-test.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
-    "id": "application-policy-group-termination-behavior-test",
-    "algorithm": "one-after-another",
-    "networkPartitions": [
-        "network-partition-group-termination-behavior-test-1"
-    ],
-    "properties": [
-        {
-            "name": "networkPartitionGroups",
-            "value": "network-partition-group-termination-behavior-test-1"
-        },
-        {
-            "name": "key-2",
-            "value": "value-2"
-        }
-    ]
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/application-policies/application-policy-group-termination-behavior-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/application-policies/application-policy-group-termination-behavior-test.json b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/application-policies/application-policy-group-termination-behavior-test.json
new file mode 100644
index 0000000..15e757b
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/application-policies/application-policy-group-termination-behavior-test.json
@@ -0,0 +1,17 @@
+{
+    "id": "application-policy-group-termination-behavior-test",
+    "algorithm": "one-after-another",
+    "networkPartitions": [
+        "network-partition-group-termination-behavior-test-1"
+    ],
+    "properties": [
+        {
+            "name": "networkPartitionGroups",
+            "value": "network-partition-group-termination-behavior-test-1"
+        },
+        {
+            "name": "key-2",
+            "value": "value-2"
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/applications/group-termination-behavior-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/applications/group-termination-behavior-test.json b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/applications/group-termination-behavior-test.json
index 0ce09a8..70432ae 100644
--- a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/applications/group-termination-behavior-test.json
+++ b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/applications/group-termination-behavior-test.json
@@ -61,9 +61,9 @@
                                     {
                                         "cartridgeMin": 1,
                                         "cartridgeMax": 1,
-                                        "type": "c4",
+                                        "type": "c4-group-termination-behavior-test",
                                         "subscribableInfo": {
-                                            "alias": "c4-1x0",
+                                            "alias": "c4-1x0-group-termination-behavior-test",
                                             "deploymentPolicy": "deployment-policy-group-termination-behavior-test",
                                             "artifactRepository": {
                                                 "repoUsername": "user",

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/autoscaling-policies/autoscaling-policy-application-bursting-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/autoscaling-policies/autoscaling-policy-application-bursting-test.json b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/autoscaling-policies/autoscaling-policy-application-bursting-test.json
deleted file mode 100644
index fd81d17..0000000
--- a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/autoscaling-policies/autoscaling-policy-application-bursting-test.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-    "id": "autoscaling-policy-group-termination-behavior-test",
-    "loadThresholds": {
-        "requestsInFlight": {
-            "threshold": 35
-        },
-        "memoryConsumption": {
-            "threshold": 45
-        },
-        "loadAverage": {
-            "threshold": 25
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/autoscaling-policies/autoscaling-policy-group-termination-behavior-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/autoscaling-policies/autoscaling-policy-group-termination-behavior-test.json b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/autoscaling-policies/autoscaling-policy-group-termination-behavior-test.json
new file mode 100644
index 0000000..fd81d17
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/autoscaling-policies/autoscaling-policy-group-termination-behavior-test.json
@@ -0,0 +1,14 @@
+{
+    "id": "autoscaling-policy-group-termination-behavior-test",
+    "loadThresholds": {
+        "requestsInFlight": {
+            "threshold": 35
+        },
+        "memoryConsumption": {
+            "threshold": 45
+        },
+        "loadAverage": {
+            "threshold": 25
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/cartridges-groups/cartridge-groups-group-termination-behavior-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/cartridges-groups/cartridge-groups-group-termination-behavior-test.json b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/cartridges-groups/cartridge-groups-group-termination-behavior-test.json
index 52ce80f..2d69021 100644
--- a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/cartridges-groups/cartridge-groups-group-termination-behavior-test.json
+++ b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/cartridges-groups/cartridge-groups-group-termination-behavior-test.json
@@ -46,8 +46,8 @@
                   ]
               },
               "cartridges": [
-                  "c4",
-                  "c5"
+                  "c3-group-termination-behavior-test",
+                  "c4-group-termination-behavior-test"
               ],
               "groups": [
               ]

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/deployment-policies/deployment-policy-group-termination-behavior-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/deployment-policies/deployment-policy-group-termination-behavior-test.json b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/deployment-policies/deployment-policy-group-termination-behavior-test.json
new file mode 100644
index 0000000..035ad73
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/deployment-policies/deployment-policy-group-termination-behavior-test.json
@@ -0,0 +1,18 @@
+{
+    "id": "deployment-policy-group-termination-behavior-test",
+    "networkPartitions": [
+        {
+            "id": "network-partition-group-termination-behavior-test-1",
+            "partitionAlgo": "one-after-another",
+            "partitions": [
+                {
+                    "id": "partition-1",
+                    "partitionMax": 4
+                }
+            ]
+        }
+    ]
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/deployment-policies/deployment-policy-termination-behavior-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/deployment-policies/deployment-policy-termination-behavior-test.json b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/deployment-policies/deployment-policy-termination-behavior-test.json
deleted file mode 100644
index 9209573..0000000
--- a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/deployment-policies/deployment-policy-termination-behavior-test.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
-    "id": "deployment-policy-group-termination-behavior-test",
-    "networkPartitions": [
-        {
-            "id": "network-partition-group-termination-behavior-test-1",
-            "partitionAlgo": "one-after-another",
-            "partitions": [
-                {
-                    "id": "network-partition-10-partition-1",
-                    "partitionMax": 4
-                },
-                {
-                    "id": "network-partition-10-partition-2",
-                    "partitionMax": 4
-                }
-            ]
-        }
-    ]
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/network-partitions/mock/network-partition-application-bursting-test-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/network-partitions/mock/network-partition-application-bursting-test-1.json b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/network-partitions/mock/network-partition-application-bursting-test-1.json
deleted file mode 100644
index 13abc47..0000000
--- a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/network-partitions/mock/network-partition-application-bursting-test-1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-    "id": "network-partition-group-termination-behavior-test-1",
-    "provider": "mock",
-    "partitions": [
-        {
-            "id": "partition-1",
-            "property": [
-                {
-                    "name": "region",
-                    "value": "default"
-                }
-            ]
-        }
-    ]
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/network-partitions/mock/network-partition-group-termination-behavior-test-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/network-partitions/mock/network-partition-group-termination-behavior-test-1.json b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/network-partitions/mock/network-partition-group-termination-behavior-test-1.json
new file mode 100644
index 0000000..13abc47
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/group-termination-behavior-test/network-partitions/mock/network-partition-group-termination-behavior-test-1.json
@@ -0,0 +1,15 @@
+{
+    "id": "network-partition-group-termination-behavior-test-1",
+    "provider": "mock",
+    "partitions": [
+        {
+            "id": "partition-1",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/mock-iaas.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/mock-iaas.xml b/products/stratos/modules/integration/src/test/resources/mock-iaas.xml
index a0f1066..37051b6 100644
--- a/products/stratos/modules/integration/src/test/resources/mock-iaas.xml
+++ b/products/stratos/modules/integration/src/test/resources/mock-iaas.xml
@@ -79,6 +79,26 @@
                 <sampleDuration>30</sampleDuration>
             </pattern>
         </cartridge>
+        <cartridge type="c3-group-termination-behavior-test">
+            <!-- factor:memory-consumption|load-average|requests-in-flight-->
+            <!-- mode:loop|continue|stop -->
+            <!-- Mode defines the action needs to be taken after the last sample value:
+                 loop: start from beginning
+                 continue: continue the last sample value
+                 stop: stop publishing statistics -->
+            <pattern factor="memory-consumption" mode="stop">
+                <!-- Sample values -->
+                <sampleValues>20,20,20</sampleValues>
+                <!-- Duration of each sample value in seconds -->
+                <sampleDuration>60</sampleDuration>
+            </pattern>
+            <pattern factor="load-average" mode="stop">
+                <!-- Sample values -->
+                <sampleValues>20,20,20</sampleValues>
+                <!-- Duration of each sample value in seconds -->
+                <sampleDuration>60</sampleDuration>
+            </pattern>
+        </cartridge>
         <cartridge type="php">
             <!-- factor:memory-consumption|load-average|requests-in-flight-->
             <!-- mode:loop|continue|stop -->

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-network-partition-test-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-network-partition-test-1.json b/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-network-partition-test-1.json
new file mode 100644
index 0000000..d673796
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-network-partition-test-1.json
@@ -0,0 +1,15 @@
+{
+    "id": "network-partition-network-partition-test-1",
+    "provider": "mock",
+    "partitions": [
+        {
+            "id": "partition-1",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-network-partition-test-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-network-partition-test-2.json b/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-network-partition-test-2.json
new file mode 100644
index 0000000..3e1ba76
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-network-partition-test-2.json
@@ -0,0 +1,15 @@
+{
+    "id": "network-partition-network-partition-test-2",
+    "provider": "mock",
+    "partitions": [
+        {
+            "id": "partition-1",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/512280af/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/stratos-testing.xml b/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
index b64603e..da48aa8 100644
--- a/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
+++ b/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
@@ -21,22 +21,22 @@
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
 
 <suite name="StratosIntegrationSuite">
-    <test name="CartridgeTest">
+   <!-- <test name="CartridgeTest">
         <classes>
             <class name="org.apache.stratos.integration.tests.group.CartridgeTest" />
         </classes>
-    </test>
-    <test name="CartridgeGroupTest" >
+    </test>-->
+    <!--<test name="CartridgeGroupTest" >
         <classes>
             <class name="org.apache.stratos.integration.tests.group.CartridgeGroupTest" />
         </classes>
-    </test>
+    </test>-->
     <test name="NetworkPartitionTest">
         <classes>
             <class name="org.apache.stratos.integration.tests.policies.NetworkPartitionTest" />
         </classes>
     </test>
-    <test name="ApplicationPolicyTest">
+    <!--<test name="ApplicationPolicyTest">
         <classes>
             <class name="org.apache.stratos.integration.tests.policies.ApplicationPolicyTest" />
         </classes>
@@ -76,4 +76,9 @@
             <class name="org.apache.stratos.integration.tests.application.PartitionRoundRobinClusterTest" />
         </classes>
     </test>
+    <test name="GroupTerminationBehaviorTest">
+        <classes>
+            <class name="org.apache.stratos.integration.tests.application.GroupTerminationBehaviorTest" />
+        </classes>
+    </test>-->
 </suite>