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/04 10:40:38 UTC

[6/8] stratos git commit: adding application add, deploy, update, undeploy and remove in the integration test

adding application add, deploy, update, undeploy and remove in the integration test

Conflicts:
	products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java


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

Branch: refs/heads/tenant-isolation
Commit: 4f3a53c6fc6bdf9067bf14e4052e8b8c5c4e6b33
Parents: 5ba5692
Author: reka <rt...@gmail.com>
Authored: Mon Aug 3 14:44:43 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Mon Aug 3 14:59:43 2015 +0530

----------------------------------------------------------------------
 .../tests/ApplicationPolicyTest.java            |   2 +
 .../integration/tests/ApplicationTest.java      | 221 +++++++
 .../tests/AutoscalingPolicyTest.java            |   2 +
 .../integration/tests/CartridgeGroupTest.java   | 144 ++++
 .../integration/tests/CartridgeTest.java        |   2 +
 .../integration/tests/DeploymentPolicyTest.java |  16 +-
 .../integration/tests/RestConstants.java        |   4 +
 .../tests/SampleApplicationsTest.java           | 654 ++++++++++++++++++-
 .../application-policy-1.json                   |   7 +-
 .../single-cartridge-app-multi-cloud/README.md  |  30 -
 .../artifacts/application.json                  |  25 -
 .../artifacts/application-signup.json           |  18 -
 .../artifacts/application.json                  |  25 -
 .../artifacts/domain-mappings.json              |   9 -
 .../single-cartridge-app/g-sc-G123-1.json       |  86 +++
 .../update/g-sc-G123-1.json                     |  86 +++
 .../simple/single-group-app/README.md           |  28 -
 .../single-group-app/artifacts/application.json |  69 --
 .../autoscaling-policy-1.json                   |  14 +
 .../test/resources/cartridge-groups/group1.json |  38 --
 .../cartridges-groups/cartrdige-nested.json     |  18 +-
 .../update/cartrdige-nested.json                |  50 ++
 .../src/test/resources/cartridges/mock/c1.json  |  45 ++
 .../src/test/resources/cartridges/mock/c2.json  |  45 ++
 .../src/test/resources/cartridges/mock/c3.json  |  45 ++
 25 files changed, 1397 insertions(+), 286 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
index c4c0261..b1b37b2 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
@@ -124,6 +124,8 @@ public class ApplicationPolicyTest extends StratosArtifactsUtils {
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
+                } else if(response.getContent().contains("it is used")) {
+                    return false;
                 } else {
                     GsonBuilder gsonBuilder = new GsonBuilder();
                     Gson gson = gsonBuilder.create();

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
new file mode 100644
index 0000000..284401e
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.integration.tests;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
+import org.apache.stratos.integration.tests.rest.ErrorResponse;
+import org.apache.stratos.integration.tests.rest.HttpResponse;
+import org.apache.stratos.integration.tests.rest.RestClient;
+
+import java.net.URI;
+
+/**
+ * Test to handle autoscaling policy CRUD operations
+ */
+public class ApplicationTest extends StratosArtifactsUtils {
+    private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
+    String applications = "/applications/simple/single-cartridge-app/";
+    String applicationsUpdate = "/applications/simple/single-cartridge-app/update/";
+
+
+    public boolean addApplication(String applicationId, String endpoint, RestClient restClient) {
+        try {
+            String content = getJsonStringFromFile(applications + applicationId);
+            URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS).build();
+
+            HttpResponse response = restClient.doPost(uri, content);
+            if (response != null) {
+                if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+                    return true;
+                } else {
+                    GsonBuilder gsonBuilder = new GsonBuilder();
+                    Gson gson = gsonBuilder.create();
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public boolean deployApplication(String applicationId, String applicationPolicyId,
+                                     String endpoint, RestClient restClient) {
+        try {
+            URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" + applicationId +
+            RestConstants.APPLICATIONS_DEPLOY + "/" + applicationPolicyId).build();
+
+            HttpResponse response = restClient.doPost(uri, "");
+            if (response != null) {
+                if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+                    return true;
+                } else {
+                    GsonBuilder gsonBuilder = new GsonBuilder();
+                    Gson gson = gsonBuilder.create();
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public boolean undeployApplication(String applicationId,
+                                     String endpoint, RestClient restClient) {
+        try {
+            URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" + applicationId +
+                    RestConstants.APPLICATIONS_UNDEPLOY).build();
+
+            HttpResponse response = restClient.doPost(uri, "");
+            if (response != null) {
+                if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+                    return true;
+                } else {
+                    GsonBuilder gsonBuilder = new GsonBuilder();
+                    Gson gson = gsonBuilder.create();
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public boolean forceUndeployApplication(String applicationId,
+                                       String endpoint, RestClient restClient) {
+        try {
+            URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" + applicationId +
+                    RestConstants.APPLICATIONS_UNDEPLOY + "?force=true").build();
+
+            HttpResponse response = restClient.doPost(uri, "");
+            if (response != null) {
+                if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+                    return true;
+                } else {
+                    GsonBuilder gsonBuilder = new GsonBuilder();
+                    Gson gson = gsonBuilder.create();
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public ApplicationBean getApplication(String applicationId, String endpoint,
+                                                    RestClient restClient) {
+        try {
+            URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" +
+                    applicationId).build();
+            HttpResponse response = restClient.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(), ApplicationBean.class);
+                } else if (response.getStatusCode() == 404) {
+                    return null;
+                } else {
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public boolean updateApplication(String applicationId, String endpoint, RestClient restClient) {
+        try {
+            String content = getJsonStringFromFile(applicationsUpdate + applicationId);
+            URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS).build();
+            HttpResponse response = restClient.doPut(uri, content);
+            if (response != null) {
+                if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+                    return true;
+                } else {
+                    GsonBuilder gsonBuilder = new GsonBuilder();
+                    Gson gson = gsonBuilder.create();
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public boolean removeApplication(String applicationId, String endpoint, RestClient restClient) {
+        try {
+            URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" +
+                    applicationId).build();
+            HttpResponse response = restClient.doDelete(uri);
+            if (response != null) {
+                if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+                    return true;
+                } else {
+                    GsonBuilder gsonBuilder = new GsonBuilder();
+                    Gson gson = gsonBuilder.create();
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
index fe4fa55..f5f3786 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
@@ -123,6 +123,8 @@ public class AutoscalingPolicyTest extends StratosArtifactsUtils {
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
+                } else if(response.getContent().contains("is in use")) {
+                    return false;
                 } else {
                     GsonBuilder gsonBuilder = new GsonBuilder();
                     Gson gson = gsonBuilder.create();

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
new file mode 100644
index 0000000..dcbe5c9
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.integration.tests;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.integration.tests.rest.ErrorResponse;
+import org.apache.stratos.integration.tests.rest.HttpResponse;
+import org.apache.stratos.integration.tests.rest.RestClient;
+
+import java.net.URI;
+
+/**
+ * Test to handle Network partition CRUD operations
+ */
+public class CartridgeGroupTest extends StratosArtifactsUtils {
+    private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
+    String cartridgeGroups = "/cartridges-groups/";
+    String cartridgeGroupsUpdate = "/cartridges-groups/update/";
+
+
+    public boolean addCartridgeGroup(String groupName, String endpoint, RestClient restClient) {
+        try {
+            String content = getJsonStringFromFile(cartridgeGroups + groupName);
+            URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS).build();
+
+            HttpResponse response = restClient.doPost(uri, content);
+            if (response != null) {
+                if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+                    return true;
+                } else {
+                    GsonBuilder gsonBuilder = new GsonBuilder();
+                    Gson gson = gsonBuilder.create();
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public CartridgeGroupBean getCartridgeGroup(String groupName, String endpoint,
+                                                    RestClient restClient) {
+        try {
+            URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS + "/" +
+                    groupName).build();
+            HttpResponse response = restClient.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(), CartridgeGroupBean.class);
+                } else if (response.getStatusCode() == 404) {
+                    return null;
+                } else {
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public boolean updateCartridgeGroup(String groupName, String endpoint, RestClient restClient) {
+        try {
+            String content = getJsonStringFromFile(cartridgeGroupsUpdate + groupName);
+            URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS).build();
+            HttpResponse response = restClient.doPut(uri, content);
+            if (response != null) {
+                if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+                    return true;
+                } else {
+                    GsonBuilder gsonBuilder = new GsonBuilder();
+                    Gson gson = gsonBuilder.create();
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+
+    public boolean removeCartridgeGroup(String groupName, String endpoint, RestClient restClient) {
+        try {
+            URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS + "/" +
+                    groupName).build();
+            HttpResponse response = restClient.doDelete(uri);
+            if (response != null) {
+                if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+                    return true;
+                } else if(response.getContent().contains("it is used")) {
+                    return false;
+                } else {
+                    GsonBuilder gsonBuilder = new GsonBuilder();
+                    Gson gson = gsonBuilder.create();
+                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                    if (errorResponse != null) {
+                        throw new RuntimeException(errorResponse.getErrorMessage());
+                    }
+                }
+            }
+            throw new RuntimeException("An unknown error occurred");
+        } catch (Exception e) {
+            String message = "Could not start mock instance";
+            throw new RuntimeException(message, e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
index 9e9e07f..7cd5412 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
@@ -124,6 +124,8 @@ public class CartridgeTest extends StratosArtifactsUtils {
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
+                } else if (response.getContent().contains("it is used")) {
+                    return false;
                 } else {
                     GsonBuilder gsonBuilder = new GsonBuilder();
                     Gson gson = gsonBuilder.create();

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
index b437c5e..e7e80eb 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
@@ -100,15 +100,17 @@ public class DeploymentPolicyTest extends StratosArtifactsUtils {
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
+                } else if(response.getContent().contains("it is used")) {
+                    return false;
                 } else {
-                    GsonBuilder gsonBuilder = new GsonBuilder();
-                    Gson gson = gsonBuilder.create();
-                    ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
-                    if (errorResponse != null) {
-                        throw new RuntimeException(errorResponse.getErrorMessage());
+                        GsonBuilder gsonBuilder = new GsonBuilder();
+                        Gson gson = gsonBuilder.create();
+                        ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+                        if (errorResponse != null) {
+                            throw new RuntimeException(errorResponse.getErrorMessage());
+                        }
                     }
                 }
-            }
             throw new RuntimeException("An unknown error occurred");
         } catch (Exception e) {
             String message = "Could not start mock instance";
@@ -124,6 +126,8 @@ public class DeploymentPolicyTest extends StratosArtifactsUtils {
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
+                } else if(response.getContent().contains("is in use")) {
+                    return false;
                 } else {
                     GsonBuilder gsonBuilder = new GsonBuilder();
                     Gson gson = gsonBuilder.create();

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/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 577d211..9678c4e 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
@@ -27,7 +27,11 @@ public class RestConstants {
     public static final String DEPLOYMENT_POLICIES = "/" + API + "/deploymentPolicies";
     public static final String NETWORK_PARTITIONS = "/" + API + "/networkPartitions";
     public static final String CARTRIDGES = "/" + API + "/cartridges";
+    public static final String CARTRIDGE_GROUPS = "/" + API + "/cartridgeGroups";
     public static final String APPLICATION_POLICIES = "/" + API + "/applicationPolicies";
     public static final String APPLICATIONS = "/" + API + "/applications";
+    public static final String APPLICATIONS_RUNTIME = "/runtime";
+    public static final String APPLICATIONS_DEPLOY = "/deploy";
+    public static final String APPLICATIONS_UNDEPLOY = "/undeploy";
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
index e092d20..c98e8f9 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
@@ -25,17 +25,37 @@ import org.apache.commons.exec.PumpStreamHandler;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
+import org.apache.stratos.common.beans.PropertyBean;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
+import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
+import org.apache.stratos.common.client.AutoscalerServiceClient;
 import org.apache.stratos.common.threading.StratosThreadPool;
 import org.apache.stratos.integration.tests.rest.RestClient;
-import org.apache.stratos.messaging.domain.application.Application;
-import org.apache.stratos.messaging.domain.application.ApplicationStatus;
+import org.apache.stratos.messaging.domain.application.*;
+import org.apache.stratos.messaging.domain.instance.ClusterInstance;
+import org.apache.stratos.messaging.domain.instance.GroupInstance;
+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.message.receiver.application.ApplicationManager;
 import org.apache.stratos.messaging.message.receiver.application.ApplicationsEventReceiver;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.rmi.RemoteException;
+import java.util.Collection;
+import java.util.Set;
 import java.util.concurrent.ExecutorService;
 
 import static junit.framework.Assert.*;
@@ -47,30 +67,42 @@ public class SampleApplicationsTest extends StratosTestServerManager {
 
     private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
 
-    public static final int APPLICATION_ACTIVATION_TIMEOUT = 600000;
+    public static final int APPLICATION_ACTIVATION_TIMEOUT = 120000;
+    public static final String APPLICATION_STATUS_CREATED = "Created";
+    public static final String APPLICATION_STATUS_UNDEPLOYING = "Undeploying";
+    private String endpoint = "https://localhost:9443";
+
     private ApplicationsEventReceiver applicationsEventReceiver;
+    private TopologyEventReceiver topologyEventReceiver;
     private RestClient restClient = new RestClient();
-    private String endpoint = "https://localhost:9443";
     private AutoscalingPolicyTest autoscalingPolicyTest;
     private NetworkPartitionTest networkPartitionTest;
     private CartridgeTest cartridgeTest;
     private DeploymentPolicyTest deploymentPolicyTest;
+    private CartridgeGroupTest cartridgeGroupTest;
+    private ApplicationTest applicationTest;
+    private ApplicationPolicyTest applicationPolicyTest;
+
 
     @BeforeClass
     public void setUp() {
         // Set jndi.properties.dir system property for initializing event receivers
         System.setProperty("jndi.properties.dir", getResourcesFolderPath());
+        System.setProperty("autoscaler.service.url", "https://localhost:9443/services/AutoscalerService");
         autoscalingPolicyTest = new AutoscalingPolicyTest();
         networkPartitionTest = new NetworkPartitionTest();
         cartridgeTest = new CartridgeTest();
         deploymentPolicyTest = new DeploymentPolicyTest();
+        cartridgeGroupTest = new CartridgeGroupTest();
+        applicationTest = new ApplicationTest();
+        applicationPolicyTest = new ApplicationPolicyTest();
     }
 
     @Test
     public void testSingleCartridgeApplication() {
         try {
             initializeApplicationEventReceiver();
-            runApplicationTest("simple/single-cartridge-app", "single-cartridge-app");
+            //runApplicationTest("simple/single-cartridge-app", "single-cartridge-app");
         } catch (Exception e) {
             log.error(e);
             assertTrue("An error occurred", false);
@@ -80,12 +112,12 @@ public class SampleApplicationsTest extends StratosTestServerManager {
     @Test
     public void testAutoscalingPolicy() {
         try {
-            initializeApplicationEventReceiver();
             boolean added = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-c0.json",
                     endpoint, restClient);
             assertEquals(added, true);
             AutoscalePolicyBean bean = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
                     restClient);
+            assertEquals(bean.getId(), "autoscaling-policy-c0");
             assertEquals(bean.getLoadThresholds().getRequestsInFlight().getThreshold(), 35.0, 0.0);
             assertEquals(bean.getLoadThresholds().getMemoryConsumption().getThreshold(), 45.0, 0.0);
             assertEquals(bean.getLoadThresholds().getLoadAverage().getThreshold(), 25.0, 0.0);
@@ -114,9 +146,399 @@ public class SampleApplicationsTest extends StratosTestServerManager {
     }
 
     @Test
-    public void testNetworkPartition() {
+    public void testCartridgeGroup() {
+        try {
+            boolean addedC1 = cartridgeTest.addCartridge("c1.json", endpoint, restClient);
+            assertEquals(addedC1, true);
+
+            boolean addedC2 = cartridgeTest.addCartridge("c2.json", endpoint, restClient);
+            assertEquals(addedC2, true);
+
+            boolean addedC3 = cartridgeTest.addCartridge("c3.json", endpoint, restClient);
+            assertEquals(addedC3, true);
+
+            boolean added = cartridgeGroupTest.addCartridgeGroup("cartrdige-nested.json",
+                    endpoint, restClient);
+            assertEquals(added, true);
+            CartridgeGroupBean bean = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
+                    restClient);
+            assertEquals(bean.getName(), "G1");
+
+            boolean updated = cartridgeGroupTest.updateCartridgeGroup("cartrdige-nested.json",
+                    endpoint, restClient);
+            assertEquals(updated, true);
+            CartridgeGroupBean updatedBean = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
+                    restClient);
+            assertEquals(updatedBean.getName(), "G1");
+
+            boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
+                    restClient);
+            assertEquals(removedC1, false);
+
+            boolean removedC2 = cartridgeTest.removeCartridge("c2", endpoint,
+                    restClient);
+            assertEquals(removedC2, false);
+
+            boolean removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
+                    restClient);
+            assertEquals(removedC3, false);
+
+            boolean removed = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
+                    restClient);
+            assertEquals(removed, true);
+
+            CartridgeGroupBean beanRemoved = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
+                    restClient);
+            assertEquals(beanRemoved, null);
+
+            removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
+                    restClient);
+            assertEquals(removedC1, true);
+
+            removedC2 = cartridgeTest.removeCartridge("c2", endpoint,
+                    restClient);
+            assertEquals(removedC2, true);
+
+            removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
+                    restClient);
+            assertEquals(removedC3, true);
+
+        } catch (Exception e) {
+            log.error(e);
+            assertTrue("An error occurred while handling autoscaling policy", false);
+        }
+    }
+
+    @Test
+    public void testApplication() {
+        try {
+            boolean addedScalingPolicy = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-1.json",
+                    endpoint, restClient);
+            assertEquals(addedScalingPolicy, true);
+
+            boolean addedC1 = cartridgeTest.addCartridge("c1.json", endpoint, restClient);
+            assertEquals(addedC1, true);
+
+            boolean addedC2 = cartridgeTest.addCartridge("c2.json", endpoint, restClient);
+            assertEquals(addedC2, true);
+
+            boolean addedC3 = cartridgeTest.addCartridge("c3.json", endpoint, restClient);
+            assertEquals(addedC3, true);
+
+            boolean addedG1 = cartridgeGroupTest.addCartridgeGroup("cartrdige-nested.json",
+                    endpoint, restClient);
+            assertEquals(addedG1, true);
+            CartridgeGroupBean beanG1 = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
+                    restClient);
+            assertEquals(beanG1.getName(), "G1");
+
+            boolean addedN1 = networkPartitionTest.addNetworkPartition("network-partition-1.json",
+                    endpoint, restClient);
+            assertEquals(addedN1, true);
+
+            boolean addedN2 = networkPartitionTest.addNetworkPartition("network-partition-2.json",
+                    endpoint, restClient);
+            assertEquals(addedN2, true);
+
+            boolean addedDep = deploymentPolicyTest.addDeploymentPolicy("deployment-policy-1.json",
+                    endpoint, restClient);
+            assertEquals(addedDep, true);
+
+            boolean added = applicationTest.addApplication("g-sc-G123-1.json",
+                    endpoint, restClient);
+            assertEquals(added, true);
+            ApplicationBean bean = applicationTest.getApplication("g-sc-G123-1", endpoint,
+                    restClient);
+            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 = applicationTest.updateApplication("g-sc-G123-1.json",
+                    endpoint, restClient);
+            assertEquals(updated, true);
+
+            ApplicationBean updatedBean = applicationTest.getApplication("g-sc-G123-1", endpoint,
+                    restClient);
+
+            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);
+
+            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(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(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(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(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);
+
+
+            boolean removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
+                    restClient);
+            assertEquals(removedGroup, false);
+
+            boolean removedAuto = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-1", endpoint,
+                    restClient);
+            assertEquals(removedAuto, false);
+
+            boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            //Trying to remove the used network partition
+            assertEquals(removedNet, false);
+
+            boolean removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
+                    restClient);
+            assertEquals(removedDep, false);
+
+            boolean removed = applicationTest.removeApplication("g-sc-G123-1", endpoint,
+                    restClient);
+            assertEquals(removed, true);
+
+            ApplicationBean beanRemoved = applicationTest.getApplication("g-sc-G123-1", endpoint,
+                    restClient);
+            assertEquals(beanRemoved, null);
+
+            removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
+                    restClient);
+            assertEquals(removedGroup, true);
+
+            boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
+                    restClient);
+            assertEquals(removedC1, true);
+
+            boolean removedC2 = cartridgeTest.removeCartridge("c2", endpoint,
+                    restClient);
+            assertEquals(removedC2, true);
+
+            boolean removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
+                    restClient);
+            assertEquals(removedC3, true);
+
+            removedAuto = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-1", endpoint,
+                    restClient);
+            assertEquals(removedAuto, true);
+
+            removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
+                    restClient);
+            assertEquals(removedDep, true);
+
+            removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            assertEquals(removedNet, true);
+
+            boolean removedN2 = networkPartitionTest.removeNetworkPartition("network-partition-2", endpoint,
+                    restClient);
+            assertEquals(removedN2, true);
+
+        } catch (Exception e) {
+            log.error(e);
+            assertTrue("An error occurred while handling application", false);
+        }
+    }
+
+    @Test
+    public void testDeployApplication() {
         try {
+            //Initializing event Receivers
             initializeApplicationEventReceiver();
+            initializeTopologyEventReceiver();
+
+            boolean addedScalingPolicy = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-1.json",
+                    endpoint, restClient);
+            assertEquals(addedScalingPolicy, true);
+
+            boolean addedC1 = cartridgeTest.addCartridge("c1.json", endpoint, restClient);
+            assertEquals(addedC1, true);
+
+            boolean addedC2 = cartridgeTest.addCartridge("c2.json", endpoint, restClient);
+            assertEquals(addedC2, true);
+
+            boolean addedC3 = cartridgeTest.addCartridge("c3.json", endpoint, restClient);
+            assertEquals(addedC3, true);
+
+            boolean addedG1 = cartridgeGroupTest.addCartridgeGroup("cartrdige-nested.json",
+                    endpoint, restClient);
+            assertEquals(addedG1, true);
+            CartridgeGroupBean beanG1 = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
+                    restClient);
+            assertEquals(beanG1.getName(), "G1");
+
+            boolean addedN1 = networkPartitionTest.addNetworkPartition("network-partition-1.json",
+                    endpoint, restClient);
+            assertEquals(addedN1, true);
+
+            boolean addedN2 = networkPartitionTest.addNetworkPartition("network-partition-2.json",
+                    endpoint, restClient);
+            assertEquals(addedN2, true);
+
+            boolean addedDep = deploymentPolicyTest.addDeploymentPolicy("deployment-policy-1.json",
+                    endpoint, restClient);
+            assertEquals(addedDep, true);
+
+            boolean added = applicationTest.addApplication("g-sc-G123-1.json",
+                    endpoint, restClient);
+            assertEquals(added, true);
+            ApplicationBean bean = applicationTest.getApplication("g-sc-G123-1", endpoint,
+                    restClient);
+            assertEquals(bean.getApplicationId(), "g-sc-G123-1");
+
+            boolean addAppPolicy = applicationPolicyTest.addApplicationPolicy(
+                    "application-policy-1.json", endpoint, restClient);
+            assertEquals(addAppPolicy, true);
+
+            ApplicationPolicyBean policyBean = applicationPolicyTest.getApplicationPolicy(
+                    "application-policy-1", endpoint, restClient);
+
+            //deploy the application
+            boolean deployed = applicationTest.deployApplication(bean.getApplicationId(),
+                    policyBean.getId(), endpoint, restClient);
+            assertEquals(deployed, true);
+
+            //Application active handling
+            assertApplicationActivation(bean.getApplicationId());
+
+            //Group active handling
+            assertGroupActivation(bean.getApplicationId());
+
+            //Cluster active handling
+            assertClusterActivation(bean.getApplicationId());
+
+            //Updating application
+            boolean updated = applicationTest.updateApplication("g-sc-G123-1.json",
+                    endpoint, restClient);
+            assertEquals(updated, true);
+
+            assertGroupInstanceCount(bean.getApplicationId(), "group3", 2);
+            ApplicationBean updatedBean = applicationTest.getApplication("g-sc-G123-1", endpoint,
+                    restClient);
+            assertEquals(updatedBean.getApplicationId(), "g-sc-G123-1");
+
+            boolean removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
+                    restClient);
+            assertEquals(removedGroup, false);
+
+            boolean removedAuto = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-1", endpoint,
+                    restClient);
+            assertEquals(removedAuto, false);
+
+            boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            //Trying to remove the used network partition
+            assertEquals(removedNet, false);
+
+            boolean removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
+                    restClient);
+            assertEquals(removedDep, false);
+
+            boolean unDeployed = applicationTest.undeployApplication("g-sc-G123-1", endpoint,
+                    restClient);
+            assertEquals(unDeployed, true);
+
+            assertApplicationUndeploy("g-sc-G123-1");
+
+            boolean removed = applicationTest.removeApplication("g-sc-G123-1", endpoint,
+                    restClient);
+            assertEquals(removed, true);
+
+            ApplicationBean beanRemoved = applicationTest.getApplication("g-sc-G123-1", endpoint,
+                    restClient);
+            assertEquals(beanRemoved, null);
+
+            removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
+                    restClient);
+            assertEquals(removedGroup, true);
+
+            boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
+                    restClient);
+            assertEquals(removedC1, true);
+
+            boolean removedC2 = cartridgeTest.removeCartridge("c2", endpoint,
+                    restClient);
+            assertEquals(removedC2, true);
+
+            boolean removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
+                    restClient);
+            assertEquals(removedC3, true);
+
+            removedAuto = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-1", endpoint,
+                    restClient);
+            assertEquals(removedAuto, true);
+
+            removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
+                    restClient);
+            assertEquals(removedDep, true);
+
+            //Remove network partition used by application policy
+            removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            assertEquals(removedNet, false);
+
+            boolean removedN2 = networkPartitionTest.removeNetworkPartition("network-partition-2", endpoint,
+                    restClient);
+            assertEquals(removedN2, false);
+
+            boolean removeAppPolicy = applicationPolicyTest.removeApplicationPolicy("application-policy-1", endpoint,
+                    restClient);
+            assertEquals(removeAppPolicy, true);
+
+            removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            assertEquals(removedNet, true);
+
+            removedN2 = networkPartitionTest.removeNetworkPartition("network-partition-2", endpoint,
+                    restClient);
+            assertEquals(removedN2, true);
+
+        } catch (Exception e) {
+            log.error(e);
+            assertTrue("An error occurred while handling autoscaling policy", false);
+        }
+    }
+
+    @Test
+    public void testNetworkPartition() {
+        try {
             boolean added = networkPartitionTest.addNetworkPartition("network-partition-1.json",
                     endpoint, restClient);
             assertEquals(added, true);
@@ -158,7 +580,6 @@ public class SampleApplicationsTest extends StratosTestServerManager {
     @Test
     public void testDeploymentPolicy() {
         try {
-            initializeApplicationEventReceiver();
             boolean addedN1 = networkPartitionTest.addNetworkPartition("network-partition-1.json",
                     endpoint, restClient);
             assertEquals(addedN1, true);
@@ -232,7 +653,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
                     restClient);
             assertEquals(removedDep, true);
 
-            DeploymentPolicyBean beanRemovedDep = deploymentPolicyTest.getDeploymentPolicy("network-partition-1", endpoint,
+            DeploymentPolicyBean beanRemovedDep = deploymentPolicyTest.getDeploymentPolicy("deployment-policy-1", endpoint,
                     restClient);
             assertEquals(beanRemovedDep, null);
 
@@ -261,33 +682,32 @@ public class SampleApplicationsTest extends StratosTestServerManager {
     @Test
     public void testCartridge() {
         try {
-            initializeApplicationEventReceiver();
             boolean added = cartridgeTest.addCartridge("c0.json", endpoint, restClient);
             assertEquals(added, true);
             CartridgeBean bean = cartridgeTest.getCartridge("c0", endpoint, restClient);
             assertEquals(bean.getType(), "c0");
             assertEquals(bean.getCategory(), "Application");
             assertEquals(bean.getHost(), "qmog.cisco.com");
-            for(PropertyBean property : bean.getProperty()) {
-                if(property.getName().equals("payload_parameter.CEP_IP")) {
+            for (PropertyBean property : bean.getProperty()) {
+                if (property.getName().equals("payload_parameter.CEP_IP")) {
                     assertEquals(property.getValue(), "octl.qmog.cisco.com");
-                } else if(property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) {
+                } else if (property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) {
                     assertEquals(property.getValue(), "admin");
-                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) {
+                } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) {
                     assertEquals(property.getValue(), "octl.qmog.cisco.com");
-                } else if(property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) {
+                } else if (property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) {
                     assertEquals(property.getValue(), "1");
-                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) {
+                } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) {
                     assertEquals(property.getValue(), "admin");
-                } else if(property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) {
+                } else if (property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) {
                     assertEquals(property.getValue(), "test");
-                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) {
+                } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) {
                     assertEquals(property.getValue(), "7711");
-                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) {
+                } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) {
                     assertEquals(property.getValue(), "7611");
-                } else if(property.getName().equals("payload_parameter.CEP_PORT")) {
+                } else if (property.getName().equals("payload_parameter.CEP_PORT")) {
                     assertEquals(property.getValue(), "7611");
-                } else if(property.getName().equals("payload_parameter.MB_PORT")) {
+                } else if (property.getName().equals("payload_parameter.MB_PORT")) {
                     assertEquals(property.getValue(), "61616");
                 }
             }
@@ -301,26 +721,26 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(updatedBean.getType(), "c0");
             assertEquals(updatedBean.getCategory(), "Data");
             assertEquals(updatedBean.getHost(), "qmog.cisco.com12");
-            for(PropertyBean property : updatedBean.getProperty()) {
-                if(property.getName().equals("payload_parameter.CEP_IP")) {
+            for (PropertyBean property : updatedBean.getProperty()) {
+                if (property.getName().equals("payload_parameter.CEP_IP")) {
                     assertEquals(property.getValue(), "octl.qmog.cisco.com123");
-                } else if(property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) {
+                } else if (property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) {
                     assertEquals(property.getValue(), "admin123");
-                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) {
+                } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) {
                     assertEquals(property.getValue(), "octl.qmog.cisco.com123");
-                } else if(property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) {
+                } else if (property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) {
                     assertEquals(property.getValue(), "3");
-                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) {
+                } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) {
                     assertEquals(property.getValue(), "admin123");
-                } else if(property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) {
+                } else if (property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) {
                     assertEquals(property.getValue(), "test123");
-                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) {
+                } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) {
                     assertEquals(property.getValue(), "7712");
-                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) {
+                } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) {
                     assertEquals(property.getValue(), "7612");
-                } else if(property.getName().equals("payload_parameter.CEP_PORT")) {
+                } else if (property.getName().equals("payload_parameter.CEP_PORT")) {
                     assertEquals(property.getValue(), "7612");
-                } else if(property.getName().equals("payload_parameter.MB_PORT")) {
+                } else if (property.getName().equals("payload_parameter.MB_PORT")) {
                     assertEquals(property.getValue(), "61617");
                 }
             }
@@ -364,6 +784,18 @@ public class SampleApplicationsTest extends StratosTestServerManager {
     }
 
     /**
+     * Initialize Topology event receiver
+     */
+    private void initializeTopologyEventReceiver() {
+        if (topologyEventReceiver == null) {
+            topologyEventReceiver = new TopologyEventReceiver();
+            ExecutorService executorService = StratosThreadPool.getExecutorService("STRATOS_TEST_SERVER1", 1);
+            topologyEventReceiver.setExecutorService(executorService);
+            topologyEventReceiver.execute();
+        }
+    }
+
+    /**
      * Execute shell command
      *
      * @param commandText
@@ -401,12 +833,168 @@ public class SampleApplicationsTest extends StratosTestServerManager {
                 break;
             }
         }
-
         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());
     }
 
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    private void assertGroupActivation(String applicationName) {
+        Application application = ApplicationManager.getApplications().getApplication(applicationName);
+        assertNotNull(String.format("Application is not found: [application-id] %s",
+                applicationName), application);
+
+        Collection<Group> groups = application.getAllGroupsRecursively();
+        for(Group group : groups) {
+            assertEquals(group.getInstanceContextCount() >= group.getGroupMinInstances(), true);
+        }
+    }
+
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    private void assertClusterActivation(String applicationName) {
+        Application application = ApplicationManager.getApplications().getApplication(applicationName);
+        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();
+            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 clusterActive = false;
+
+            for (ClusterInstance instance : cluster.getInstanceIdToInstanceContextMap().values()) {
+                int activeInstances = 0;
+                for (Member member : cluster.getMembers()) {
+                    if (member.getClusterInstanceId().equals(instance.getInstanceId())) {
+                        if (member.getStatus().equals(MemberStatus.Active)) {
+                            activeInstances++;
+                        }
+                    }
+                }
+                clusterActive = activeInstances >= clusterDataHolder.getMinInstances();
+
+                if (!clusterActive) {
+                    break;
+                }
+            }
+            assertEquals(String.format("Cluster status did not change to active: [cluster-id] %s", clusterId),
+                    clusterActive, true);
+        }
+
+    }
+
+
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    private void assertApplicationUndeploy(String applicationName) {
+        long startTime = System.currentTimeMillis();
+        Application application = ApplicationManager.getApplications().getApplication(applicationName);
+        ApplicationContext applicationContext = null;
+        try {
+            applicationContext = AutoscalerServiceClient.getInstance().getApplication(applicationName);
+        } catch (RemoteException e) {
+            log.error("Error while getting the application context for [application] " + applicationName);
+        }
+        while (((application != null) && application.getInstanceContextCount() > 0) ||
+                (applicationContext == null || applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING))) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+            application = ApplicationManager.getApplications().getApplication(applicationName);
+            try {
+                applicationContext = AutoscalerServiceClient.getInstance().getApplication(applicationName);
+            } catch (RemoteException e) {
+                log.error("Error while getting the application context for [application] " + applicationName);
+            }
+            if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+                break;
+            }
+        }
+
+        assertNotNull(String.format("Application is not found: [application-id] %s",
+                applicationName), application);
+        assertNotNull(String.format("Application Context is not found: [application-id] %s",
+                applicationName), applicationContext);
+
+        //Force undeployment after the graceful deployment
+        if (application.getInstanceContextCount() > 0 ||
+                applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING)) {
+            log.info("Force undeployment is going to start for the [application] " + applicationName);
+
+            applicationTest.forceUndeployApplication(applicationName, endpoint, restClient);
+            while (application.getInstanceContextCount() > 0 ||
+                    applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING)) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException ignore) {
+                }
+                application = ApplicationManager.getApplications().getApplication(applicationName);
+                if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+                    break;
+                }
+            }
+        }
+        assertEquals(String.format("Application status did not change to Created: [application-id] %s", applicationName),
+                APPLICATION_STATUS_CREATED, applicationContext.getStatus());
+
+    }
+
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    private void assertGroupInstanceCount(String applicationName, String groupAlias, int count) {
+        long startTime = System.currentTimeMillis();
+        Application application = ApplicationManager.getApplications().getApplication(applicationName);
+        if (application != null) {
+            Group group = application.getGroupRecursively(groupAlias);
+            while (group.getInstanceContextCount() != count) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException ignore) {
+                }
+                if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+                    break;
+                }
+            }
+            for (GroupInstance instance : group.getInstanceIdToInstanceContextMap().values()) {
+                while (!instance.getStatus().equals(GroupStatus.Active)) {
+                    try {
+                        Thread.sleep(1000);
+                    } catch (InterruptedException ignore) {
+                    }
+                    if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+                        break;
+                    }
+                }
+            }
+            assertEquals(String.format("Application status did not change to active: [application-id] %s", applicationName),
+                    group.getInstanceContextCount(), count);
+        }
+        assertNotNull(String.format("Application is not found: [application-id] %s", applicationName), application);
+
+    }
+
     private void assertApplicationNotExists(String applicationName) {
         Application application = ApplicationManager.getApplications().getApplication(applicationName);
         assertNull(String.format("Application is found in the topology : [application-id] %s", applicationName), application);

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/application-policies/application-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-policies/application-policy-1.json b/products/stratos/modules/integration/src/test/resources/application-policies/application-policy-1.json
index 417b94f..17858bb 100644
--- a/products/stratos/modules/integration/src/test/resources/application-policies/application-policy-1.json
+++ b/products/stratos/modules/integration/src/test/resources/application-policies/application-policy-1.json
@@ -2,12 +2,13 @@
     "id": "application-policy-1",
     "algorithm": "one-after-another",
     "networkPartitions": [
-        "network-partition-1"
+        "network-partition-1",
+        "network-partition-2"
     ],
     "properties": [
         {
-            "name": "key-1",
-            "value": "value-1"
+            "name": "networkPartitionGroups",
+            "value": "network-partition-1,network-partition-2"
         },
         {
             "name": "key-2",

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app-multi-cloud/README.md
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app-multi-cloud/README.md b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app-multi-cloud/README.md
deleted file mode 100644
index b8b2c92..0000000
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app-multi-cloud/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-Single Cartridge Application in a multi cloud environment
-=========================================================
-A simple application with a php cartridge in two AWS EC2 regions and Openstack on-premise deployment 
-
-Application view
-----------------
-
-                                            single-cartridge-app
-                                                     |
-                _____________________________________|__________________________________
-                |                                    |                                 |
-    single-cartridge-app-1(ec2 R1)    single-cartridge-app-2(ec2 R2)   single-cartridge-app-3(Openstack region)
-                |                                    |                                 |
-         my-php(member 1)                     my-php(member 2)                  my-php(member 3)
-
-Application folder structure
-----------------------------
--- artifacts/multi/     IaaS specific artifacts                <br />
--- scripts/common/      Common scripts for all iaases            <br />
--- scripts/multi        IaaS specific scripts                     <br />
-
-How to run
-----------
-cd scripts/multi/          <br />
-./deploy.sh                 <br />
-
-How to undeploy
----------------
-cd scripts/multi/          <br />
-./undeploy.sh               <br />
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app-multi-cloud/artifacts/application.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app-multi-cloud/artifacts/application.json b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app-multi-cloud/artifacts/application.json
deleted file mode 100644
index cbe785c..0000000
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app-multi-cloud/artifacts/application.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-    "applicationId": "single-cartridge-multi-cloud-app",
-    "alias": "single-cartridge-multi-cloud-app",
-    "multiTenant": false,
-    "components": {
-        "cartridges": [
-            {
-                "type": "php",
-                "cartridgeMin": 1,
-                "cartridgeMax": 10,
-                "subscribableInfo": {
-                    "alias": "my-php",
-                    "autoscalingPolicy": "autoscaling-policy-1",
-                    "deploymentPolicy": "multi-cloud-deployment-policy",
-                    "artifactRepository": {
-                        "privateRepo": false,
-                        "repoUrl": "https://github.com/lakwarus/single-cartridge.git",
-                        "repoUsername": "",
-                        "repoPassword": ""
-                    }
-                }
-            }
-        ]
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/application-signup.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/application-signup.json b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/application-signup.json
deleted file mode 100644
index 73a5774..0000000
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/application-signup.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "artifactRepositories": [
-        {
-            "alias": "php",
-            "privateRepo": false,
-            "repoUrl": "https://github.com/imesh/stratos-php-applications.git",
-            "repoUsername": "",
-            "repoPassword": ""
-        },
-        {
-            "alias": "tomcat",
-            "privateRepo": false,
-            "repoUrl": "https://github.com/imesh/stratos-tomcat-applications.git",
-            "repoUsername": "",
-            "repoPassword": ""
-        }
-    ]
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/application.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/application.json b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/application.json
deleted file mode 100644
index 4043e4f..0000000
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/application.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-    "applicationId": "single-cartridge-app",
-    "alias": "single-cartridge-app",
-    "multiTenant": false,
-    "components": {
-        "cartridges": [
-            {
-                "type": "php",
-                "cartridgeMin": 1,
-                "cartridgeMax": 5,
-                "subscribableInfo": {
-                    "alias": "my-php",
-                    "autoscalingPolicy": "autoscaling-policy-1",
-                    "deploymentPolicy": "deployment-policy-1",
-                    "artifactRepository": {
-                        "privateRepo": false,
-                        "repoUrl": "https://github.com/lakwarus/single-cartridge.git",
-                        "repoUsername": "",
-                        "repoPassword": ""
-                    }
-                }
-            }
-        ]
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/domain-mappings.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/domain-mappings.json b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/domain-mappings.json
deleted file mode 100644
index d26db7f..0000000
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/artifacts/domain-mappings.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-    "domainMappings": [
-        {
-            "cartridgeAlias": "my-php",
-            "domainName": "abc.com",
-            "contextPath": "/abc/app"
-        }
-    ]
-}

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

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