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

[03/11] stratos git commit: Merge the latest changes of integration test from master branch

Merge the latest changes of integration test from master branch


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

Branch: refs/heads/tenant-isolation
Commit: 6c6f4cc3fa9771f8883eaf4e5c27e81d1f85be6b
Parents: 96899f7
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Wed Aug 12 17:45:08 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Wed Aug 12 17:45:08 2015 +0530

----------------------------------------------------------------------
 products/stratos/modules/integration/pom.xml    |  11 +-
 .../integration/tests/RestConstants.java        |   6 -
 .../tests/StratosTestServerManager.java         |  18 +-
 .../integration/tests/TopologyHandler.java      | 175 +++++++-
 .../application/ApplicationBurstingTest.java    |  98 ++---
 .../application/SampleApplicationsTest.java     | 409 ++++++-------------
 .../application/SingleClusterScalingTest.java   | 193 ++++-----
 .../tests/config/ApplicationBean.java           |  25 --
 .../tests/config/ApplicationConfigParser.java   |  25 --
 .../tests/group/CartridgeGroupTest.java         |  78 ++--
 .../integration/tests/group/CartridgeTest.java  |  14 +-
 .../tests/policies/ApplicationPolicyTest.java   |  40 +-
 .../tests/policies/AutoscalingPolicyTest.java   |  12 +-
 .../tests/policies/DeploymentPolicyTest.java    | 111 ++---
 .../tests/policies/NetworkPartitionTest.java    |  37 +-
 .../integration/tests/rest/RestClient.java      |  22 +-
 .../application-policy-3.json                   |  18 -
 .../app-bursting-single-cartriddge-group.json   |  28 +-
 .../autoscaling-policy-2.json                   |  14 -
 .../cartridges-groups/esb-php-group.json        |  19 -
 .../cartridges/mock/esb.json                    |  50 ---
 .../cartridges/mock/php.json                    |  51 ---
 .../cartridges/mock/tomcat.json                 |  53 ---
 .../deployment-policy-4.json                    |  32 --
 .../mock/network-partition-10.json              |  24 --
 .../mock/network-partition-9.json               |  15 -
 .../application-policy-2.json                   |  18 -
 .../mock/network-partition-7.json               |  15 -
 .../mock/network-partition-8.json               |  24 --
 .../autoscaling-policy-c0-v1.json               |  14 -
 .../autoscaling-policy-c0.json                  |  14 -
 .../cartridges-groups/g4-g5-g6-v1.json          |  50 ---
 .../cartridges-groups/g4-g5-g6.json             |  50 ---
 .../cartridges/mock/c4.json                     |  45 --
 .../cartridges/mock/c5.json                     | 124 ------
 .../cartridges/mock/c6.json                     |  45 --
 .../cartridge-test/cartridges/mock/c0-v1.json   | 124 ------
 .../cartridge-test/cartridges/mock/c0.json      | 124 ------
 .../deployment-policy-2-v1.json                 |  36 --
 .../deployment-policy-2.json                    |  32 --
 .../mock/network-partition-5-v1.json            |  28 --
 .../mock/network-partition-5.json               |  15 -
 .../mock/network-partition-6.json               |  24 --
 .../src/test/resources/mock-iaas.xml            |  42 +-
 .../mock/network-partition-3-v1.json            |  28 --
 .../mock/network-partition-3.json               |  15 -
 .../application-policy-1.json                   |  18 -
 .../applications/g-sc-G123-1-v1.json            |  86 ----
 .../applications/g-sc-G123-1-v2.json            |  86 ----
 .../applications/g-sc-G123-1-v3.json            |  86 ----
 .../applications/g-sc-G123-1.json               |  86 ----
 .../autoscaling-policy-1.json                   |  14 -
 .../cartridges-groups/cartrdige-nested-v1.json  |  50 ---
 .../cartridges-groups/cartrdige-nested.json     |  50 ---
 .../cartridges/mock/c1.json                     |  45 --
 .../cartridges/mock/c2.json                     |  45 --
 .../cartridges/mock/c3.json                     |  45 --
 .../deployment-policy-1-v1.json                 |  36 --
 .../deployment-policy-1.json                    |  32 --
 .../mock/network-partition-1-v1.json            |  28 --
 .../mock/network-partition-1.json               |  15 -
 .../mock/network-partition-2.json               |  24 --
 .../src/test/resources/stratos-testing.xml      |  18 +-
 .../src/test/resources/tenant/tenant1.json      |   9 -
 .../src/test/resources/tenant/tenant2.json      |   9 -
 65 files changed, 680 insertions(+), 2547 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/6c6f4cc3/products/stratos/modules/integration/pom.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/pom.xml b/products/stratos/modules/integration/pom.xml
index edca877..ab6fa04 100755
--- a/products/stratos/modules/integration/pom.xml
+++ b/products/stratos/modules/integration/pom.xml
@@ -95,7 +95,13 @@
         <dependency>
             <groupId>org.apache.stratos</groupId>
             <artifactId>org.apache.stratos.messaging</artifactId>
-            <version>4.1.0-SNAPSHOT</version>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.mock.iaas.client</artifactId>
+            <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -117,6 +123,9 @@
                         <extracted.dir>stratos-parent-${project.version}</extracted.dir>
                         <emma.home>${basedir}/target/emma</emma.home>
                     </systemProperties>
+                    <suiteXmlFiles>
+                        <suiteXmlFile>src/test/resources/stratos-testing.xml</suiteXmlFile>
+                    </suiteXmlFiles>
                     <workingDirectory>${basedir}/target</workingDirectory>
                 </configuration>
             </plugin>

http://git-wip-us.apache.org/repos/asf/stratos/blob/6c6f4cc3/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
index 747a131..bf7de6c 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
@@ -49,10 +49,4 @@ public class RestConstants {
     public static final String APPLICATION_POLICIES_PATH = "/application-policies/";
     public static final String APPLICATION_POLICIES_NAME = "applicationPolicy";
 
-    public static final String TENANT1_RESOURCE ="/tenant/tenant1.json";
-    public static final String TENANT2_RESOURCE ="/tenant/tenant2.json";
-    public static final String TENANT_API = "/" + API + "/tenants";
-    public static final String TENANTS_NAME = "tenants";
-
-
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/6c6f4cc3/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 13fcb5d..f191743 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
@@ -27,9 +27,10 @@ import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.stratos.common.test.TestLogAppender;
 import org.apache.stratos.integration.tests.application.SampleApplicationsTest;
+import org.apache.stratos.integration.tests.rest.IntegrationMockClient;
 import org.apache.stratos.integration.tests.rest.RestClient;
+import org.apache.stratos.mock.iaas.client.MockIaasApiClient;
 import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeSuite;
 import org.wso2.carbon.integration.framework.TestServerManager;
 import org.wso2.carbon.integration.framework.utils.FrameworkSettings;
@@ -40,7 +41,6 @@ import java.io.File;
 import java.io.IOException;
 import java.net.URL;
 
-import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 
 /**
@@ -57,7 +57,6 @@ public class StratosTestServerManager extends TestServerManager {
     private static final String MOCK_IAAS_XML_FILE = "mock-iaas.xml";
     private static final String JNDI_PROPERTIES_FILE = "jndi.properties";
     private static final String JMS_OUTPUT_ADAPTER_FILE = "JMSOutputAdaptor.xml";
-    protected RestClient restClientAdmin;
     protected RestClient restClient;
     private String endpoint = "https://localhost:9443";
 
@@ -65,12 +64,13 @@ public class StratosTestServerManager extends TestServerManager {
     private TestLogAppender testLogAppender = new TestLogAppender();
     private ServerUtils serverUtils;
     private String carbonHome;
+    protected IntegrationMockClient mockIaasApiClient;
 
     public StratosTestServerManager() {
         super(CARBON_ZIP, PORT_OFFSET);
         serverUtils = new ServerUtils();
-        restClientAdmin=new RestClient(endpoint,"admin","admin");
         restClient = new RestClient(endpoint, "admin", "admin");
+        mockIaasApiClient = new IntegrationMockClient(endpoint + "/mock-iaas/api");
     }
 
     @Override
@@ -127,7 +127,6 @@ public class StratosTestServerManager extends TestServerManager {
 
                 long time4 = System.currentTimeMillis();
                 log.info(String.format("Stratos server started in %d sec", (time4 - time3) / 1000));
-                tenantCreation();
                 return carbonHome;
             }
         }
@@ -198,13 +197,4 @@ public class StratosTestServerManager extends TestServerManager {
         }
         return false;
     }
-
-
-    public void tenantCreation(){
-        log.info("Added tenants to the testing suit");
-        boolean addedTenant1=restClientAdmin.addEntity(RestConstants.TENANT1_RESOURCE,RestConstants.TENANT_API,RestConstants.TENANTS_NAME);
-        assertEquals(addedTenant1,true);
-        boolean addedTenant2=restClientAdmin.addEntity(RestConstants.TENANT2_RESOURCE,RestConstants.TENANT_API,RestConstants.TENANTS_NAME);
-        assertEquals(addedTenant2,true);
-    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/6c6f4cc3/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 2ff1cc5..fb0718d 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
@@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
 import org.apache.stratos.common.client.AutoscalerServiceClient;
 import org.apache.stratos.common.threading.StratosThreadPool;
+import org.apache.stratos.integration.tests.rest.IntegrationMockClient;
 import org.apache.stratos.messaging.domain.application.*;
 import org.apache.stratos.messaging.domain.instance.ClusterInstance;
 import org.apache.stratos.messaging.domain.instance.GroupInstance;
@@ -31,7 +32,13 @@ import org.apache.stratos.messaging.domain.topology.Cluster;
 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.listener.topology.MemberInitializedEventListener;
+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.listener.application.*;
+import org.apache.stratos.messaging.listener.topology.*;
 import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
 import org.apache.stratos.messaging.message.receiver.application.ApplicationsEventReceiver;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
@@ -40,12 +47,12 @@ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import java.io.File;
 import java.rmi.RemoteException;
 import java.util.Collection;
+import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.*;
 
 /**
  * To start the Topology receivers
@@ -53,13 +60,18 @@ import static junit.framework.Assert.assertNull;
 public class TopologyHandler {
     private static final Log log = LogFactory.getLog(TopologyHandler.class);
 
-    public static final int APPLICATION_ACTIVATION_TIMEOUT = 120000;
+    public static final int APPLICATION_ACTIVATION_TIMEOUT = 300000;
+    public static final int APPLICATION_UNDEPLOYMENT_TIMEOUT = 60000;
     public static final int APPLICATION_TOPOLOGY_TIMEOUT = 60000;
     public static final String APPLICATION_STATUS_CREATED = "Created";
     public static final String APPLICATION_STATUS_UNDEPLOYING = "Undeploying";
     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 TopologyHandler() {
         // Set jndi.properties.dir system property for initializing event receivers
@@ -69,6 +81,7 @@ public class TopologyHandler {
         initializeTopologyEventReceiver();
         assertApplicationTopologyInitialized();
         assertTopologyInitialized();
+        addTopologyEventListeners();
     }
 
     public static TopologyHandler getInstance() {
@@ -150,10 +163,10 @@ public class TopologyHandler {
      *
      * @param applicationName
      */
-    public void assertApplicationActivation(String applicationName) {
+    public void assertApplicationStatus(String applicationName, ApplicationStatus status) {
         long startTime = System.currentTimeMillis();
         Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
-        while (!((application != null) && (application.getStatus() == ApplicationStatus.Active))) {
+        while (!((application != null) && (application.getStatus() == status))) {
             try {
                 Thread.sleep(1000);
             } catch (InterruptedException ignore) {
@@ -164,8 +177,9 @@ public class TopologyHandler {
             }
         }
         assertNotNull(String.format("Application is not found: [application-id] %s", applicationName), application);
-        assertEquals(String.format("Application status did not change to active: [application-id] %s", applicationName),
-                ApplicationStatus.Active, application.getStatus());
+        assertEquals(String.format("Application status did not change to %s: [application-id] %s",
+                        status.toString(), applicationName),
+                status, application.getStatus());
     }
 
     /**
@@ -228,6 +242,53 @@ public class TopologyHandler {
 
     }
 
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    public void terminateMemberFromCluster(String cartridgeName, String applicationName, IntegrationMockClient mockIaasApiClient) {
+        Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+        assertNotNull(String.format("Application is not found: [application-id] %s",
+                applicationName), application);
+
+        Set<ClusterDataHolder> clusterDataHolderSet = application.getClusterDataRecursively();
+        for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
+            String serviceName = clusterDataHolder.getServiceType();
+            if(cartridgeName.equals(serviceName)) {
+                String clusterId = clusterDataHolder.getClusterId();
+                Service service = TopologyManager.getTopology().getService(serviceName);
+                assertNotNull(String.format("Service is not found: [application-id] %s [service] %s",
+                        applicationName, serviceName), service);
+
+                Cluster cluster = service.getCluster(clusterId);
+                assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
+                        applicationName, serviceName, clusterId), cluster);
+                boolean memberTerminated = false;
+
+                for (ClusterInstance instance : cluster.getInstanceIdToInstanceContextMap().values()) {
+                    for (Member member : cluster.getMembers()) {
+                        if (member.getClusterInstanceId().equals(instance.getInstanceId())) {
+                            if (member.getStatus().equals(MemberStatus.Active)) {
+                                mockIaasApiClient.terminateInstance(member.getMemberId());
+                                memberTerminated = true;
+                                break;
+                            }
+                        }
+                    }
+
+                    if(memberTerminated) {
+                        break;
+                    }
+
+                }
+                assertTrue("Any member couldn't be terminated from the mock IaaS client", memberTerminated);
+            }
+
+        }
+
+    }
+
     public void assertClusterMinMemberCount(String applicationName, int minMembers) {
         long startTime = System.currentTimeMillis();
 
@@ -319,7 +380,7 @@ public class TopologyHandler {
             } catch (RemoteException e) {
                 log.error("Error while getting the application context for [application] " + applicationName);
             }
-            if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+            if ((System.currentTimeMillis() - startTime) > APPLICATION_UNDEPLOYMENT_TIMEOUT) {
                 break;
             }
         }
@@ -390,4 +451,98 @@ public class TopologyHandler {
         String path = getClass().getResource("/").getPath();
         return StringUtils.removeEnd(path, File.separator);
     }
+
+    private void addTopologyEventListeners() {
+        topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event;
+                terminatedMembers.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;
+
+            }
+        });
+
+        topologyEventReceiver.addEventListener(new ClusterInstanceActivatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+            }
+        });
+
+        topologyEventReceiver.addEventListener(new ClusterInstanceInactivateEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+            }
+        });
+
+        topologyEventReceiver.addEventListener(new ClusterInstanceTerminatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+            }
+        });
+
+
+    }
+
+    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 instanceId = event1.getGroupInstance().getInstanceId();
+
+            }
+        });
+
+
+
+        applicationsEventReceiver.addEventListener(new GroupInstanceActivatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+            }
+        });
+
+        applicationsEventReceiver.addEventListener(new GroupInstanceInactivateEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+            }
+        });
+
+        applicationsEventReceiver.addEventListener(new GroupInstanceTerminatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+
+            }
+        });
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/6c6f4cc3/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 a1f2c6a..6c62056 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
@@ -26,6 +26,7 @@ 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.ApplicationStatus;
 import org.testng.annotations.Test;
 
 import static junit.framework.Assert.assertEquals;
@@ -36,86 +37,87 @@ import static junit.framework.Assert.assertTrue;
  */
 public class ApplicationBurstingTest extends StratosTestServerManager {
     private static final Log log = LogFactory.getLog(SampleApplicationsTest.class);
-    private static final String TEST_PATH = "/application-bursting-test";
+    private static final String RESOURCES_PATH = "/application-bursting-test";
 
 
     @Test
     public void testApplicationBusting() {
         try {
-            log.info("Started application Bursting test case**************************************");
+            log.info("-------------------------------Started application Bursting test case-------------------------------");
 
-            String autoscalingPolicyId = "autoscaling-policy-2";
+            String autoscalingPolicyId = "autoscaling-policy-application-bursting-test";
 
-            boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
+            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(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb.json",
+            boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb-application-bursting-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
             assertEquals(addedC1, true);
 
-            boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php.json",
+            boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php-application-bursting-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
             assertEquals(addedC2, true);
 
-            boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat.json",
+            boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat-application-bursting-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
             assertEquals(addedC3, true);
 
-            boolean addedG1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
-                            "/" + "esb-php-group.json", RestConstants.CARTRIDGE_GROUPS,
+            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);
 
             CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
-                    getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test",
                             CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(beanG1.getName(), "esb-php-group");
+            assertEquals(beanG1.getName(), "esb-php-group-application-bursting-test");
 
-            boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
-                            "network-partition-9.json",
+            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);
 
-            boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
-                            "network-partition-10.json",
+            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);
 
-            boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
-                            "deployment-policy-4.json",
+            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);
 
-            boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+            boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
                             "app-bursting-single-cartriddge-group.json", RestConstants.APPLICATIONS,
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(added, true);
 
             ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
-                    "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
-            assertEquals(bean.getApplicationId(), "cartridge-group-app");
+                    "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertEquals(bean.getApplicationId(), "application-bursting-test");
 
-            boolean addAppPolicy = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
-                            "application-policy-3.json", RestConstants.APPLICATION_POLICIES,
+            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);
 
             ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity(
                     RestConstants.APPLICATION_POLICIES,
-                    "application-policy-3", ApplicationPolicyBean.class,
+                    "application-policy-application-bursting-test", ApplicationPolicyBean.class,
                     RestConstants.APPLICATION_POLICIES_NAME);
 
             //deploy the application
-            String resourcePath = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
-                    RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-3";
+            String resourcePath = RestConstants.APPLICATIONS + "/" + "application-bursting-test" +
+                    RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-application-bursting-test";
             boolean deployed = restClient.deployEntity(resourcePath,
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(deployed, true);
 
             //Application active handling
-            TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId());
+            TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+                    ApplicationStatus.Active);
 
             //Group active handling
             TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
@@ -123,7 +125,7 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
             //Cluster active handling
             TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
 
-           boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+            boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
             assertEquals(removedGroup, false);
 
@@ -132,58 +134,58 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
             assertEquals(removedAuto, false);
 
             boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-9",
+                    "network-partition-application-bursting-test-1",
                     RestConstants.NETWORK_PARTITIONS_NAME);
             //Trying to remove the used network partition
             assertEquals(removedNet, false);
 
             boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
-                    "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME);
+                    "deployment-policy-application-bursting-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
             assertEquals(removedDep, false);
 
             //Un-deploying the application
-            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "application-bursting-test" +
                     RestConstants.APPLICATIONS_UNDEPLOY;
 
             boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(unDeployed, true);
 
-            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app");
+            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test");
             if (!undeploy) {
                 //Need to forcefully undeploy the application
-                log.info("Force undeployment is going to start for the [application] " + "cartridge-group-app");
+                log.info("Force undeployment is going to start for the [application] " + "application-bursting-test");
 
-                restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+                restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "application-bursting-test" +
                         RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
 
-                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app");
+                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test");
                 assertEquals(String.format("Forceful undeployment failed for the application %s",
-                        "cartridge-group-app"), forceUndeployed, true);
+                        "application-bursting-test"), forceUndeployed, true);
 
             }
 
-            boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "cartridge-group-app",
+            boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "application-bursting-test",
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(removed, true);
 
             ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
-                    "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+                    "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
             assertEquals(beanRemoved, null);
 
-            removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+            removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
             assertEquals(removedGroup, true);
 
-            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "esb",
+            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "esb-application-bursting-test",
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC1, true);
 
-            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "php",
+            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "php-application-bursting-test",
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC2, true);
 
-            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat",
+            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat-application-bursting-test",
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC3, true);
 
@@ -192,30 +194,30 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
             assertEquals(removedAuto, true);
 
             removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
-                    "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME);
+                    "deployment-policy-application-bursting-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
             assertEquals(removedDep, true);
 
             removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME);
+                    "network-partition-application-bursting-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedNet, false);
 
             boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME);
+                    "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedN2, false);
 
             boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
-                    "application-policy-3", RestConstants.APPLICATION_POLICIES_NAME);
+                    "application-policy-application-bursting-test", RestConstants.APPLICATION_POLICIES_NAME);
             assertEquals(removeAppPolicy, true);
 
             removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME);
+                    "network-partition-application-bursting-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedNet, true);
 
             removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME);
+                    "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedN2, true);
 
-            log.info("Ended application bursting test case**************************************");
+            log.info("-------------------------------Ended application bursting test case-------------------------------");
 
         } catch (Exception e) {
             log.error("An error occurred while handling  application bursting", e);

http://git-wip-us.apache.org/repos/asf/stratos/blob/6c6f4cc3/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 2dad064..4ca3632 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
@@ -23,13 +23,15 @@ 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.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.integration.tests.TopologyHandler;
+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;
 
 /**
@@ -37,167 +39,183 @@ import static junit.framework.Assert.assertTrue;
  */
 public class SampleApplicationsTest extends StratosTestServerManager {
     private static final Log log = LogFactory.getLog(SampleApplicationsTest.class);
-    private static final String TEST_PATH = "/sample-applications-test";
+    private static final String RESOURCES_PATH = "/sample-applications-test";
 
     @Test
     public void testApplication() {
-        log.info("Started application test case**************************************");
-        String autoscalingPolicyId = "autoscaling-policy-1";
-
+        log.info("-------------------------------Started application test case-------------------------------");
         try {
-            boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
+            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(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1.json",
+            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(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2.json",
+            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(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3.json",
+            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(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
-                            "/" + "cartrdige-nested.json", RestConstants.CARTRIDGE_GROUPS,
+            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",
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, "G1-sample-applications-test",
                             CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(beanG1.getName(), "G1");
+            assertEquals(beanG1.getName(), "G1-sample-applications-test");
 
-            boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
-                            "network-partition-1.json",
+            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(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
-                            "network-partition-2.json",
+            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(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
-                            "deployment-policy-1.json",
+            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);
 
-            boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" +
-                            "g-sc-G123-1.json", RestConstants.APPLICATIONS,
+            boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+                            "g-sc-G123-1-sample-applications-test.json", RestConstants.APPLICATIONS,
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(added, true);
 
             ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
-                    "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
-            assertEquals(bean.getApplicationId(), "g-sc-G123-1");
-
-            assertEquals(bean.getComponents().getGroups().get(0).getName(), "G1");
-            assertEquals(bean.getComponents().getGroups().get(0).getAlias(), "group1");
-            assertEquals(bean.getComponents().getGroups().get(0).getGroupMaxInstances(), 1);
-            assertEquals(bean.getComponents().getGroups().get(0).getGroupMinInstances(), 1);
-
-            assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getType(), "c1");
-            assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1);
-            assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2);
-
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getAlias(), "group2");
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getName(), "G2");
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 1);
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1);
-
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c2");
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1);
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2);
-
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getAlias(), "group3");
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getName(), "G3");
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 2);
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1);
-
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c3");
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1);
-            assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2);
-
-            boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/g-sc-G123-1-v1.json",
+                    "g-sc-G123-1-sample-applications-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertEquals(bean.getApplicationId(), "g-sc-G123-1-sample-applications-test");
+
+            CartridgeGroupReferenceBean group1 = bean.getComponents().getGroups().get(0);
+            CartridgeGroupReferenceBean group2 = group1.getGroups().get(0);
+            CartridgeGroupReferenceBean group3 = group2.getGroups().get(0);
+            CartridgeReferenceBean c1 = group1.getCartridges().get(0);
+            CartridgeReferenceBean c2 = group2.getCartridges().get(0);
+            CartridgeReferenceBean c3 = group3.getCartridges().get(0);
+
+            assertEquals(group1.getName(), "G1-sample-applications-test");
+            assertEquals(group1.getAlias(), "group1-sample-applications-test");
+            assertEquals(group1.getGroupMaxInstances(), 1);
+            assertEquals(group1.getGroupMinInstances(), 1);
+
+            assertEquals(c1.getType(), "c1-sample-applications-test");
+            assertEquals(c1.getCartridgeMin(), 1);
+            assertEquals(c1.getCartridgeMax(), 2);
+
+            assertEquals(group2.getAlias(), "group2-sample-applications-test");
+            assertEquals(group2.getName(), "G2-sample-applications-test");
+            assertEquals(group2.getGroupMaxInstances(), 1);
+            assertEquals(group2.getGroupMinInstances(), 1);
+
+            assertEquals(c2.getType(), "c2-sample-applications-test");
+            assertEquals(c2.getCartridgeMin(), 1);
+            assertEquals(c2.getCartridgeMax(), 2);
+
+            assertEquals(group3.getAlias(), "group3-sample-applications-test");
+            assertEquals(group3.getName(), "G3-sample-applications-test");
+            assertEquals(group3.getGroupMaxInstances(), 2);
+            assertEquals(group3.getGroupMinInstances(), 1);
+
+            assertEquals(c3.getType(), "c3-sample-applications-test");
+            assertEquals(c3.getCartridgeMin(), 1);
+            assertEquals(c3.getCartridgeMax(), 2);
+
+            boolean updated = restClient.updateEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH +
+                            "/g-sc-G123-1-sample-applications-test-v1.json",
                     RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME);
             assertEquals(updated, true);
 
             ApplicationBean updatedBean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
-                    "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+                    "g-sc-G123-1-sample-applications-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+
+            assertEquals(bean.getApplicationId(), "g-sc-G123-1-sample-applications-test");
 
-            assertEquals(bean.getApplicationId(), "g-sc-G123-1");
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getName(), "G1");
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getAlias(), "group1");
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroupMaxInstances(), 1);
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroupMinInstances(), 1);
+            group1 = updatedBean.getComponents().getGroups().get(0);
+            group2 = group1.getGroups().get(0);
+            group3 = group2.getGroups().get(0);
+            c1 = group1.getCartridges().get(0);
+            c2 = group2.getCartridges().get(0);
+            c3 = group3.getCartridges().get(0);
 
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getType(), "c1");
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2);
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 3);
+            assertEquals(group1.getName(), "G1-sample-applications-test");
+            assertEquals(group1.getAlias(), "group1-sample-applications-test");
+            assertEquals(group1.getGroupMaxInstances(), 1);
+            assertEquals(group1.getGroupMinInstances(), 1);
 
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getAlias(), "group2");
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getName(), "G2");
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 1);
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1);
+            assertEquals(c1.getType(), "c1-sample-applications-test");
+            assertEquals(c1.getCartridgeMin(), 2);
+            assertEquals(c1.getCartridgeMax(), 3);
 
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c2");
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2);
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 4);
+            assertEquals(group2.getAlias(), "group2-sample-applications-test");
+            assertEquals(group2.getName(), "G2-sample-applications-test");
+            assertEquals(group2.getGroupMaxInstances(), 1);
+            assertEquals(group2.getGroupMinInstances(), 1);
 
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getAlias(), "group3");
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getName(), "G3");
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 3);
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 2);
+            assertEquals(c2.getType(), "c2-sample-applications-test");
+            assertEquals(c2.getCartridgeMin(), 2);
+            assertEquals(c2.getCartridgeMax(), 4);
 
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c3");
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2);
-            assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 3);
+            assertEquals(group3.getAlias(), "group3-sample-applications-test");
+            assertEquals(group3.getName(), "G3-sample-applications-test");
+            assertEquals(group3.getGroupMaxInstances(), 3);
+            assertEquals(group3.getGroupMinInstances(), 2);
 
+            assertEquals(c3.getType(), "c3-sample-applications-test");
+            assertEquals(c3.getCartridgeMin(), 2);
+            assertEquals(c3.getCartridgeMax(), 3);
 
-            boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
+
+            boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1-sample-applications-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-1",
+                    "network-partition-sample-applications-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-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(removedDep, false);
+                    "deployment-policy-sample-applications-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertFalse(removedDep);
 
-            boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "g-sc-G123-1",
+            boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "g-sc-G123-1-sample-applications-test",
                     RestConstants.APPLICATIONS_NAME);
-            assertEquals(removed, true);
+            assertTrue(removed);
 
             ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
-                    "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+                    "g-sc-G123-1-sample-applications-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
             assertEquals(beanRemoved, null);
 
-            removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
+            removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1-sample-applications-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
             assertEquals(removedGroup, true);
 
-            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1",
+            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1-sample-applications-test",
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC1, true);
 
-            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2",
+            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2-sample-applications-test",
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC2, true);
 
-            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3",
+            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3-sample-applications-test",
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC3, true);
 
@@ -206,222 +224,23 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(removedAuto, true);
 
             removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
-                    "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
+                    "deployment-policy-sample-applications-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
             assertEquals(removedDep, true);
 
             removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-1", RestConstants.NETWORK_PARTITIONS_NAME);
+                    "network-partition-sample-applications-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedNet, true);
 
             boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-2", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedN2, true);
+                    "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**************************************");
+            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(dependsOnMethods = {"testApplication"})
-    public void testDeployApplication() {
-        try {
-            log.info("Started application deploy/undeploy test case**************************************");
-
-            String autoscalingPolicyId = "autoscaling-policy-1";
-
-            boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
-                            + "/" + autoscalingPolicyId + ".json",
-                    RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
-            assertEquals(addedScalingPolicy, true);
-
-            boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1.json",
-                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(addedC1, true);
-
-            boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2.json",
-                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(addedC2, true);
-
-            boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3.json",
-                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-            assertEquals(addedC3, true);
-
-            boolean addedG1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
-                            "/" + "cartrdige-nested.json", RestConstants.CARTRIDGE_GROUPS,
-                    RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(addedG1, true);
-
-            CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
-                    getEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
-                            CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(beanG1.getName(), "G1");
-
-            boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
-                            "network-partition-1.json",
-                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(addedN1, true);
-
-            boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
-                            "network-partition-2.json",
-                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(addedN2, true);
-
-            boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
-                            "deployment-policy-1.json",
-                    RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(addedDep, true);
-
-            boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" +
-                            "g-sc-G123-1.json", RestConstants.APPLICATIONS,
-                    RestConstants.APPLICATIONS_NAME);
-            assertEquals(added, true);
-
-            ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
-                    "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
-            assertEquals(bean.getApplicationId(), "g-sc-G123-1");
-
-            boolean addAppPolicy = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
-                            "application-policy-1.json", RestConstants.APPLICATION_POLICIES,
-                    RestConstants.APPLICATION_POLICIES_NAME);
-            assertEquals(addAppPolicy, true);
-
-            ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity(
-                    RestConstants.APPLICATION_POLICIES,
-                    "application-policy-1", ApplicationPolicyBean.class,
-                    RestConstants.APPLICATION_POLICIES_NAME);
-
-            //deploy the application
-            String resourcePath = RestConstants.APPLICATIONS + "/" + "g-sc-G123-1" +
-                    RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-1";
-            boolean deployed = restClient.deployEntity(resourcePath,
-                    RestConstants.APPLICATIONS_NAME);
-            assertEquals(deployed, true);
-
-            //Application active handling
-            TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId());
-
-            //Group active handling
-            TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
-
-            //Cluster active handling
-            TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
-
-            //Updating application
-            boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" +
-                            "g-sc-G123-1-v1.json", RestConstants.APPLICATIONS,
-                    RestConstants.APPLICATIONS_NAME);
-            assertEquals(updated, true);
-
-            TopologyHandler.getInstance().assertGroupInstanceCount(bean.getApplicationId(), "group3", 2);
-
-            TopologyHandler.getInstance().assertClusterMinMemberCount(bean.getApplicationId(), 2);
-
-            ApplicationBean updatedBean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
-                    "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
-            assertEquals(updatedBean.getApplicationId(), "g-sc-G123-1");
-
-            boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
-                    RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(removedGroup, false);
-
-            boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
-                    autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
-            assertEquals(removedAuto, false);
-
-            boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-1",
-                    RestConstants.NETWORK_PARTITIONS_NAME);
-            //Trying to remove the used network partition
-            assertEquals(removedNet, false);
-
-            boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
-                    "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(removedDep, false);
-
-            //Un-deploying the application
-            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "g-sc-G123-1" +
-                    RestConstants.APPLICATIONS_UNDEPLOY;
-
-            boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
-                    RestConstants.APPLICATIONS_NAME);
-            assertEquals(unDeployed, true);
-
-            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1");
-            if (!undeploy) {
-                //Need to forcefully undeploy the application
-                log.info("Force undeployment is going to start for the [application] " + "g-sc-G123-1");
-
-                restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "g-sc-G123-1" +
-                        RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
-
-                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1");
-                assertEquals(String.format("Forceful undeployment failed for the application %s",
-                        "g-sc-G123-1"), forceUndeployed, true);
-
-            }
-
-            boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "g-sc-G123-1",
-                    RestConstants.APPLICATIONS_NAME);
-            assertEquals(removed, true);
-
-            ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
-                    "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
-            assertEquals(beanRemoved, null);
-
-            removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
-                    RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(removedGroup, true);
-
-            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1",
-                    RestConstants.CARTRIDGES_NAME);
-            assertEquals(removedC1, true);
-
-            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2",
-                    RestConstants.CARTRIDGES_NAME);
-            assertEquals(removedC2, true);
-
-            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3",
-                    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-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(removedDep, true);
-
-            removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-1", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedNet, false);
-
-            boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-2", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedN2, false);
-
-            boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
-                    "application-policy-1", RestConstants.APPLICATION_POLICIES_NAME);
-            assertEquals(removeAppPolicy, true);
-
-            removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-1", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedNet, true);
-
-            removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-2", RestConstants.NETWORK_PARTITIONS_NAME);
-            assertEquals(removedN2, true);
-
-            log.info("Ended application deploy/undeploy test case**************************************");
-
-        } catch (Exception e) {
-            log.error("An error occurred while handling application deployment/undeployment", e);
-            assertTrue("An error occurred while handling application deployment/undeployment", false);
-        }
-    }
-
-
 }