stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject [6/6] stratos git commit: Add the updated integration tests
Date Mon, 10 Aug 2015 11:03:22 GMT
Add the updated integration tests


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

Branch: refs/heads/tenant-isolation
Commit: 366babaf271b9b3dadd15b39bc55510ef3ca2dee
Parents: 4b96ba0
Author: Gayan Gunarathne <gayang@wso2.com>
Authored: Mon Aug 10 16:17:32 2015 +0530
Committer: Gayan Gunarathne <gayang@wso2.com>
Committed: Mon Aug 10 16:17:32 2015 +0530

----------------------------------------------------------------------
 .../integration/tests/TopologyHandler.java      | 393 +++++++++++++++++
 .../application/ApplicationBurstingTest.java    | 226 ++++++++++
 .../application/SampleApplicationsTest.java     | 427 +++++++++++++++++++
 .../application/SingleClusterScalingTest.java   | 233 ++++++++++
 .../tests/config/ApplicationBean.java           |  25 ++
 .../tests/config/ApplicationConfigParser.java   |  25 ++
 .../tests/group/CartridgeGroupTest.java         | 129 ++++++
 .../integration/tests/group/CartridgeTest.java  | 130 ++++++
 .../tests/policies/ApplicationPolicyTest.java   | 133 ++++++
 .../tests/policies/AutoscalingPolicyTest.java   |  91 ++++
 .../tests/policies/DeploymentPolicyTest.java    | 157 +++++++
 .../tests/policies/NetworkPartitionTest.java    |  92 ++++
 .../application-policy-3.json                   |  18 +
 .../app-bursting-single-cartriddge-group.json   |  70 +++
 .../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 ++
 .../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      |  66 +++
 58 files changed, 4044 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/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
new file mode 100644
index 0000000..2ff1cc5
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
@@ -0,0 +1,393 @@
+/*
+ * 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 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.client.AutoscalerServiceClient;
+import org.apache.stratos.common.threading.StratosThreadPool;
+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.listener.topology.MemberInitializedEventListener;
+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 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.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+
+/**
+ * To start the Topology receivers
+ */
+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_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 TopologyHandler() {
+        // 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");
+        initializeApplicationEventReceiver();
+        initializeTopologyEventReceiver();
+        assertApplicationTopologyInitialized();
+        assertTopologyInitialized();
+    }
+
+    public static TopologyHandler getInstance() {
+        if (topologyHandler == null) {
+            synchronized (TopologyHandler.class) {
+                if (topologyHandler == null) {
+                    topologyHandler = new TopologyHandler();
+                }
+            }
+        }
+        return topologyHandler;
+    }
+
+
+    /**
+     * Initialize application event receiver
+     */
+    private void initializeApplicationEventReceiver() {
+        if (applicationsEventReceiver == null) {
+            applicationsEventReceiver = new ApplicationsEventReceiver();
+            ExecutorService executorService = StratosThreadPool.getExecutorService("STRATOS_TEST_SERVER", 1);
+            applicationsEventReceiver.setExecutorService(executorService);
+            applicationsEventReceiver.execute();
+        }
+    }
+
+    /**
+     * 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();
+        }
+    }
+
+    /**
+     * Assert application Topology initialization
+     */
+    private void assertApplicationTopologyInitialized() {
+        long startTime = System.currentTimeMillis();
+        boolean applicationTopologyInitialized = ApplicationManager.getApplications().isInitialized();
+        while (!applicationTopologyInitialized) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+            applicationTopologyInitialized = ApplicationManager.getApplications().isInitialized();
+            if ((System.currentTimeMillis() - startTime) > APPLICATION_TOPOLOGY_TIMEOUT) {
+                break;
+            }
+        }
+        assertEquals(String.format("Application Topology didn't get initialized "), applicationTopologyInitialized, true);
+    }
+
+    /**
+     * Assert Topology initialization
+     */
+    private void assertTopologyInitialized() {
+        long startTime = System.currentTimeMillis();
+        boolean topologyInitialized = TopologyManager.getTopology().isInitialized();
+        while (!topologyInitialized) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+            topologyInitialized = TopologyManager.getTopology().isInitialized();
+            if ((System.currentTimeMillis() - startTime) > APPLICATION_TOPOLOGY_TIMEOUT) {
+                break;
+            }
+        }
+        assertEquals(String.format("Topology didn't get initialized "), topologyInitialized, true);
+    }
+
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    public void assertApplicationActivation(String applicationName) {
+        long startTime = System.currentTimeMillis();
+        Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+        while (!((application != null) && (application.getStatus() == ApplicationStatus.Active))) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+            application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+            if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+                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
+     */
+    public void assertGroupActivation(String applicationName) {
+        Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+        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
+     */
+    public void assertClusterActivation(String applicationName) {
+        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 serviceUuid = clusterDataHolder.getServiceUuid();
+            String clusterId = clusterDataHolder.getClusterId();
+            Service service = TopologyManager.getTopology().getService(serviceUuid);
+            assertNotNull(String.format("Service is not found: [application-id] %s [service] %s",
+                    applicationName, serviceUuid), service);
+
+            Cluster cluster = service.getCluster(clusterId);
+            assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
+                    applicationName, serviceUuid, 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);
+        }
+
+    }
+
+    public void assertClusterMinMemberCount(String applicationName, int minMembers) {
+        long startTime = System.currentTimeMillis();
+
+        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.getServiceUuid();
+            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 >= minMembers;
+
+                while (!clusterActive) {
+                    try {
+                        Thread.sleep(1000);
+                    } catch (InterruptedException ignore) {
+                    }
+                    service = TopologyManager.getTopology().getService(serviceName);
+                    assertNotNull(String.format("Service is not found: [application-id] %s [service] %s",
+                            applicationName, serviceName), service);
+
+                    cluster = service.getCluster(clusterId);
+                    activeInstances = 0;
+                    for (Member member : cluster.getMembers()) {
+                        if (member.getClusterInstanceId().equals(instance.getInstanceId())) {
+                            if (member.getStatus().equals(MemberStatus.Active)) {
+                                activeInstances++;
+                            }
+                        }
+                    }
+                    clusterActive = activeInstances >= minMembers;
+                    assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
+                            applicationName, serviceName, clusterId), cluster);
+
+                    if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+                        break;
+                    }
+                }
+            }
+            assertEquals(String.format("Cluster status did not change to active: [cluster-id] %s", clusterId),
+                    clusterActive, true);
+        }
+
+    }
+
+
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    public boolean assertApplicationUndeploy(String applicationName) {
+        long startTime = System.currentTimeMillis();
+        Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName, -1234);
+        ApplicationContext applicationContext = null;
+        try {
+            applicationContext = AutoscalerServiceClient.getInstance().getApplicationByTenant(applicationName,-1234);
+        } 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().getApplicationByTenant(applicationName,-1234);
+            try {
+                applicationContext = AutoscalerServiceClient.getInstance().getApplicationByTenant(applicationName,-1234);
+            } 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)) {
+            return false;
+        }
+        assertEquals(String.format("Application status did not change to Created: [application-id] %s", applicationName),
+                APPLICATION_STATUS_CREATED, applicationContext.getStatus());
+        return true;
+    }
+
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    public void assertGroupInstanceCount(String applicationName, String groupAlias, int count) {
+        long startTime = System.currentTimeMillis();
+        Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+        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);
+
+    }
+
+    public void assertApplicationNotExists(String applicationName) {
+        Application application = ApplicationManager.getApplications().getApplication(applicationName);
+        assertNull(String.format("Application is found in the topology : [application-id] %s", applicationName), application);
+    }
+
+    /**
+     * Get resources folder path
+     *
+     * @return
+     */
+    private String getResourcesFolderPath() {
+        String path = getClass().getResource("/").getPath();
+        return StringUtils.removeEnd(path, File.separator);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/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
new file mode 100644
index 0000000..815ccd8
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
@@ -0,0 +1,226 @@
+/*
+ * 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.application;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.apache.stratos.integration.tests.TopologyHandler;
+import org.testng.annotations.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * This will handle the application bursting test cases
+ */
+public class ApplicationBurstingTest extends StratosTestServerManager {
+    private static final Log log = LogFactory.getLog(SampleApplicationsTest.class);
+    private static final String TEST_PATH = "/application-bursting-test";
+
+
+    @Test
+    public void testApplicationBusting() {
+        try {
+            log.info("Started application Bursting test case**************************************");
+
+            String autoscalingPolicyId = "autoscaling-policy-2";
+
+            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 + "/" + "esb.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC1, true);
+
+            boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC2, true);
+
+            boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat.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,
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(addedG1, true);
+
+            CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+                            CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(beanG1.getName(), "esb-php-group");
+
+            boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-9.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",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(addedN2, true);
+
+            boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                            "deployment-policy-4.json",
+                    RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(addedDep, true);
+
+            boolean added = restClient.addEntity(TEST_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");
+
+            boolean addAppPolicy = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+                            "application-policy-3.json", RestConstants.APPLICATION_POLICIES,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(addAppPolicy, true);
+
+            ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity(
+                    RestConstants.APPLICATION_POLICIES,
+                    "application-policy-3", ApplicationPolicyBean.class,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+
+            //deploy the application
+            String resourcePath = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+                    RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-3";
+            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());
+
+        /*    boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+                    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-9",
+                    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);
+            assertEquals(removedDep, false);     */
+
+            //Un-deploying the application
+            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+                    RestConstants.APPLICATIONS_UNDEPLOY;
+
+            boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(unDeployed, true);
+
+            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app");
+            if (!undeploy) {
+                //Need to forcefully undeploy the application
+                log.info("Force undeployment is going to start for the [application] " + "cartridge-group-app");
+
+                restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+                        RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
+
+                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app");
+                assertEquals(String.format("Forceful undeployment failed for the application %s",
+                        "cartridge-group-app"), forceUndeployed, true);
+
+            }
+
+            boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "cartridge-group-app",
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(removed, true);
+
+            ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+                    "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertEquals(beanRemoved, null);
+
+            boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(removedGroup, true);
+
+            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "esb",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC1, true);
+
+            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "php",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC2, true);
+
+            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC3, true);
+
+            boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, true);
+
+            boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, true);
+
+            boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, false);
+
+            boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedN2, false);
+
+            boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+                    "application-policy-3", RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(removeAppPolicy, true);
+
+            removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, true);
+
+            removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedN2, true);
+
+            log.info("Ended application bursting test case**************************************");
+
+        } catch (Exception e) {
+            log.error("An error occurred while handling  application bursting", e);
+            assertTrue("An error occurred while handling  application bursting", false);
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/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
new file mode 100644
index 0000000..8737249
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
@@ -0,0 +1,427 @@
+/*
+ * 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.application;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.apache.stratos.integration.tests.TopologyHandler;
+import org.testng.annotations.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Sample application tests with application add, .
+ */
+public class SampleApplicationsTest extends StratosTestServerManager {
+    private static final Log log = LogFactory.getLog(SampleApplicationsTest.class);
+    private static final String TEST_PATH = "/sample-applications-test";
+
+    @Test
+    public void testApplication() {
+        log.info("Started application test case**************************************");
+        String autoscalingPolicyId = "autoscaling-policy-1";
+
+        try {
+            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");
+
+            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",
+                    RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME);
+            assertEquals(updated, true);
+
+            ApplicationBean updatedBean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+                    "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+
+            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 = 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);   */
+
+            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);
+
+            boolean 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);
+
+            boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, true);
+
+            boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, true);
+
+            boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-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);
+
+            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);
+
+            boolean 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);
+
+            boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, true);
+
+            boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, true);
+
+            boolean 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);
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
new file mode 100644
index 0000000..633c456
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
@@ -0,0 +1,233 @@
+/*
+ * 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.application;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.apache.stratos.integration.tests.TopologyHandler;
+import org.testng.annotations.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * This will handle the scale-up and scale-down of a particular cluster bursting test cases
+ */
+public class SingleClusterScalingTest extends StratosTestServerManager {
+    private static final Log log = LogFactory.getLog(SampleApplicationsTest.class);
+    private static final String TEST_PATH = "/application-bursting-test";
+
+
+    @Test
+    public void testDeployApplication() {
+        try {
+            log.info("Started application Bursting test case**************************************");
+
+            String autoscalingPolicyId = "autoscaling-policy-2";
+
+            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 + "/" + "esb.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC1, true);
+
+            boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC2, true);
+
+            boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat.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,
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(addedG1, true);
+
+            CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+                            CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(beanG1.getName(), "esb-php-group");
+
+            boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-9.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",
+                    RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(addedN2, true);
+
+            boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                            "deployment-policy-4.json",
+                    RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(addedDep, true);
+
+            boolean added = restClient.addEntity(TEST_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");
+
+            boolean addAppPolicy = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+                            "application-policy-3.json", RestConstants.APPLICATION_POLICIES,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(addAppPolicy, true);
+
+            ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity(
+                    RestConstants.APPLICATION_POLICIES,
+                    "application-policy-3", ApplicationPolicyBean.class,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+
+            //deploy the application
+            String resourcePath = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+                    RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-3";
+            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());
+
+           /* boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+                    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-9",
+                    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);
+            assertEquals(removedDep, false);*/
+
+            //Un-deploying the application
+            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+                    RestConstants.APPLICATIONS_UNDEPLOY;
+
+            boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(unDeployed, true);
+
+            boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app");
+            if (!undeploy) {
+                //Need to forcefully undeploy the application
+                log.info("Force undeployment is going to start for the [application] " + "cartridge-group-app");
+
+                restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+                        RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
+
+                boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app");
+                assertEquals(String.format("Forceful undeployment failed for the application %s",
+                        "cartridge-group-app"), forceUndeployed, true);
+
+            }
+
+            boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "cartridge-group-app",
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(removed, true);
+
+            ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+                    "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertEquals(beanRemoved, null);
+
+            boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(removedGroup, true);
+
+            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "esb",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC1, true);
+
+            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "php",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC2, true);
+
+            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC3, true);
+
+            boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, true);
+
+            boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, true);
+
+            boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, false);
+
+            boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedN2, false);
+
+            boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+                    "application-policy-3", RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(removeAppPolicy, true);
+
+            removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, true);
+
+            removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedN2, true);
+
+            log.info("Ended application bursting test case**************************************");
+
+        } catch (Exception e) {
+            log.error("An error occurred while handling  application bursting", e);
+            assertTrue("An error occurred while handling  application bursting", false);
+        }
+    }
+
+    @Test(dependsOnMethods = {"testApplication"})
+    public void testClusterScalingUp() {
+
+    }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationBean.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationBean.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationBean.java
new file mode 100644
index 0000000..ce23728
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationBean.java
@@ -0,0 +1,25 @@
+/*
+ * 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.config;
+
+/**
+ * Created by reka on 5/7/15.
+ */
+public class ApplicationBean {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationConfigParser.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationConfigParser.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationConfigParser.java
new file mode 100644
index 0000000..ace17e6
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationConfigParser.java
@@ -0,0 +1,25 @@
+/*
+ * 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.config;
+
+/**
+ * Created by reka on 5/7/15.
+ */
+public class ApplicationConfigParser {
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
new file mode 100644
index 0000000..8db4af8
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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.group;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.testng.annotations.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Test to handle Cartridge group CRUD operations
+ */
+public class CartridgeGroupTest extends StratosTestServerManager {
+    private static final Log log = LogFactory.getLog(CartridgeGroupTest.class);
+    private static final String TEST_PATH = "/cartridge-group-test";
+
+    @Test
+    public void testCartridgeGroup() {
+        try {
+            log.info("Started Cartridge group test case**************************************");
+
+            boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c4.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(String.format("Cartridge did not added: [cartridge-name] %s", "c4"), addedC1, true);
+
+            boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c5.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(String.format("Cartridge did not added: [cartridge-name] %s", "c5"), addedC2, true);
+
+            boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c6.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(String.format("Cartridge did not added: [cartridge-name] %s", "c6"), addedC3, true);
+
+            boolean added = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+                            "/" + "g4-g5-g6.json", RestConstants.CARTRIDGE_GROUPS,
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
+                    "g4-g5-g6"), added, true);
+            CartridgeGroupBean bean = (CartridgeGroupBean) restClient.
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, "G4",
+                            CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge Group name did not match: [cartridge-group-name] %s",
+                    "g4-g5-g6.json"), bean.getName(), "G4");
+
+            boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+                            "/" + "g4-g5-g6-v1.json",
+                    RestConstants.CARTRIDGE_GROUPS, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge Group did not updated: [cartridge-group-name] %s",
+                    "g4-g5-g6"), updated, true);
+            CartridgeGroupBean updatedBean = (CartridgeGroupBean) restClient.
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, "G4",
+                            CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Updated Cartridge Group didn't match: [cartridge-group-name] %s",
+                    "g4-g5-g6"), updatedBean.getName(), "G4");
+
+         /*   boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge can be removed while it is used in " +
+                    "cartridge group: [cartridge-name] %s", "c4"), removedC1, false);
+
+            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge can be removed while it is used in " +
+                            "cartridge group: [cartridge-name] %s",
+                    "c5"), removedC2, false);
+
+            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge can be removed while it is used in " +
+                            "cartridge group: [cartridge-name] %s",
+                    "c6"), removedC3, false);    */
+
+            boolean removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G4",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
+                    "g4-g5-g6"), removed, true);
+
+            CartridgeGroupBean beanRemoved = (CartridgeGroupBean) restClient.
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, "G4",
+                            CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge Group did not removed completely: " +
+                            "[cartridge-group-name] %s",
+                    "g4-g5-g6"), beanRemoved, null);
+
+            boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
+                    "c4"), removedC1, true);
+
+            boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
+                    "c5"), removedC2, true);
+
+            boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
+                    "c6"), removedC3, true);
+
+            log.info("Ended Cartridge group test case**************************************");
+
+        } catch (Exception e) {
+            log.error("An error occurred while handling Cartridge group test case", e);
+            assertTrue("An error occurred while handling Cartridge group test case", false);
+        }
+    }
+}


Mime
View raw message