You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/09/10 23:50:35 UTC

[09/21] stratos git commit: Uplifting automation engine to v4.4.3, dynamically pick ports for integration tests

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/stratos-testing.xml b/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
deleted file mode 100644
index 065ff5a..0000000
--- a/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
-
-<suite name="StratosIntegrationSuite">
-
-          <test name="CartridgeTest">
-              <classes>
-                  <class name="org.apache.stratos.integration.tests.group.CartridgeTest" />
-              </classes>
-          </test>
-          <test name="CartridgeGroupTest" >
-              <classes>
-                  <class name="org.apache.stratos.integration.tests.group.CartridgeGroupTest" />
-              </classes>
-          </test>
-
-          <test name="NetworkPartitionTest">
-              <classes>
-                  <class name="org.apache.stratos.integration.tests.policies.NetworkPartitionTest" />
-              </classes>
-          </test>
-          <test name="ApplicationPolicyTest">
-              <classes>
-                  <class name="org.apache.stratos.integration.tests.policies.ApplicationPolicyTest" />
-              </classes>
-          </test>
-          <test name="DeploymentPolicyTest">
-              <classes>
-                  <class name="org.apache.stratos.integration.tests.policies.DeploymentPolicyTest" />
-              </classes>
-          </test>
-          <test name="AutoscalingPolicyTest">
-              <classes>
-                  <class name="org.apache.stratos.integration.tests.policies.AutoscalingPolicyTest" />
-              </classes>
-          </test>
-           <test name="SampleApplicationsTest">
-               <classes>
-                   <class name="org.apache.stratos.integration.tests.application.SampleApplicationsTest" />
-               </classes>
-           </test>
-          <test name="ApplicationBurstingTest">
-              <classes>
-                  <class name="org.apache.stratos.integration.tests.application.ApplicationBurstingTest" />
-              </classes>
-          </test>
-           <test name="SingleClusterScalingTest">
-               <classes>
-                   <class name="org.apache.stratos.integration.tests.application.SingleClusterScalingTest" />
-               </classes>
-           </test>
-           <test name="PartitionRoundRobinClusterTest">
-               <classes>
-                   <class name="org.apache.stratos.integration.tests.application.PartitionRoundRobinClusterTest" />
-               </classes>
-           </test>
-
-            <test name="GroupTerminationBehaviorTest">
-                <classes>
-                    <class name="org.apache.stratos.integration.tests.application.GroupTerminationBehaviorTest" />
-             </classes>
-    </test>
-</suite>

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/src/test/resources/tenant/tenant1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/tenant/tenant1.json b/products/stratos/modules/integration/src/test/resources/tenant/tenant1.json
deleted file mode 100644
index f575b1b..0000000
--- a/products/stratos/modules/integration/src/test/resources/tenant/tenant1.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-  "admin": "admin",
-  "firstName": "Frank",
-  "lastName": "Myers",
-  "adminPassword": "admin123",
-  "tenantDomain": "test1.com",
-  "email": "foo1@bar.com",
-  "active": "true"
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/src/test/resources/tenant/tenant2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/tenant/tenant2.json b/products/stratos/modules/integration/src/test/resources/tenant/tenant2.json
deleted file mode 100644
index 3d2baf2..0000000
--- a/products/stratos/modules/integration/src/test/resources/tenant/tenant2.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-  "admin": "admin",
-  "firstName": "Frank",
-  "lastName": "Myers",
-  "adminPassword": "admin123",
-  "tenantDomain": "test2.com",
-  "email": "foo2@bar.com",
-  "active": "true"
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/src/test/resources/test-conf/integration-test.properties
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/test-conf/integration-test.properties b/products/stratos/modules/integration/src/test/resources/test-conf/integration-test.properties
deleted file mode 100644
index e856975..0000000
--- a/products/stratos/modules/integration/src/test/resources/test-conf/integration-test.properties
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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.
-
-# Stratos distribution properties added via filters during the build
-distribution.path=/../../../distribution/target/${stratos.distribution.name}-${project.version}.zip
-distribution.version=${project.version}
-distribution.name=${stratos.distribution.name}
-carbon.port.offset=0
-activemq.bind.address=tcp://localhost:61617
-stratos.endpoint=http://localhost:9763
-stratos.admin.username=admin
-stratos.admin.password=admin
-stratos.tenant1.username=admin@test1.com
-stratos.tenant1.password=admin123
-stratos.tenant2.username=admin@test2.com
-stratos.tenant2.password=admin123
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/src/test/resources/user-test/tenant-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/user-test/tenant-1.json b/products/stratos/modules/integration/src/test/resources/user-test/tenant-1.json
deleted file mode 100644
index 0f599e4..0000000
--- a/products/stratos/modules/integration/src/test/resources/user-test/tenant-1.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-    "admin": "admin",
-    "firstName": "Frank",
-    "lastName": "Myers",
-    "adminPassword": "admin123",
-    "tenantDomain": "frank.com",
-    "email": "foo@bar.com",
-    "active": "true"
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/src/test/resources/user-test/user-1-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/user-test/user-1-v1.json b/products/stratos/modules/integration/src/test/resources/user-test/user-1-v1.json
deleted file mode 100644
index 1d2bbfd..0000000
--- a/products/stratos/modules/integration/src/test/resources/user-test/user-1-v1.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "userName": "user-1",
-    "credential": "kim123456",
-    "role": "admin",
-    "firstName": "Frankn",
-    "lastName": "Myersn",
-    "email": "user-1@bar.com"
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/src/test/resources/user-test/user-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/user-test/user-1.json b/products/stratos/modules/integration/src/test/resources/user-test/user-1.json
deleted file mode 100644
index 6f7da8a..0000000
--- a/products/stratos/modules/integration/src/test/resources/user-test/user-1.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "userName": "user-1",
-    "credential": "kim12345",
-    "role": "admin",
-    "firstName": "Frank",
-    "lastName": "Myers",
-    "email": "foo@bar.com"
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/test-common/pom.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-common/pom.xml b/products/stratos/modules/integration/test-common/pom.xml
new file mode 100755
index 0000000..751e570
--- /dev/null
+++ b/products/stratos/modules/integration/test-common/pom.xml
@@ -0,0 +1,126 @@
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.stratos</groupId>
+        <artifactId>stratos-integration</artifactId>
+        <version>4.2.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>org.apache.stratos.integration.common</artifactId>
+    <packaging>jar</packaging>
+    <name>Apache Stratos - Integration Common Module</name>
+    <description>Apache Stratos Integration Common Module</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-exec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon.automation</groupId>
+            <artifactId>org.wso2.carbon.automation.test.utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon.automationutils</groupId>
+            <artifactId>org.wso2.carbon.integration.common.admin.client</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon.automation</groupId>
+            <artifactId>org.wso2.carbon.automation.extensions</artifactId>
+            <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.tomcat.embed</groupId>
+                    <artifactId>tomcat-embed-core</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.tomcat.embed</groupId>
+                    <artifactId>tomcat-embed-logging-juli</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon.automationutils</groupId>
+            <artifactId>org.wso2.carbon.integration.common.utils</artifactId>
+            <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>log4j-over-slf4j</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>jul-to-slf4j</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-jdk14</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon.automation</groupId>
+            <artifactId>org.wso2.carbon.automation.engine</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.activemq</groupId>
+            <artifactId>activemq-all</artifactId>
+            <version>5.10.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents.wso2</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>${httpcore.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents.wso2</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>${httpclient.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.messaging</artifactId>
+            <version>${project.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.mock.iaas.client</artifactId>
+            <version>${project.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jacoco</groupId>
+            <artifactId>org.jacoco.agent</artifactId>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/RestConstants.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/RestConstants.java b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/RestConstants.java
new file mode 100644
index 0000000..335008c
--- /dev/null
+++ b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/RestConstants.java
@@ -0,0 +1,63 @@
+/*
+ * 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.common;
+
+/**
+ * Constant class to keep track of rest endpoint context
+ */
+public class RestConstants {
+    public static final String API = "api";
+    public static final String AUTOSCALING_POLICIES = "/" + API + "/autoscalingPolicies";
+    public static final String USERS = "/" + API + "/users";
+    public static final String TENANTS = "/" + API + "/tenants";
+    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";
+
+    public static final String AUTOSCALING_POLICIES_PATH = "/autoscaling-policies/";
+    public static final String AUTOSCALING_POLICIES_NAME = "autoscalingPolicy";
+    public static final String CARTRIDGE_GROUPS_PATH = "/cartridges-groups/";
+    public static final String CARTRIDGE_GROUPS_NAME = "cartridgeGroup";
+    public static final String CARTRIDGES_PATH = "/cartridges/mock/";
+    public static final String CARTRIDGES_NAME = "cartridge";
+    public static final String NETWORK_PARTITIONS_PATH = "/network-partitions/mock/";
+    public static final String NETWORK_PARTITIONS_NAME = "networkPartition";
+    public static final String USERS_NAME = "users";
+    public static final String DEPLOYMENT_POLICIES_PATH = "/deployment-policies/";
+    public static final String DEPLOYMENT_POLICIES_NAME = "deploymentPolicy";
+    public static final String APPLICATIONS_PATH = "/applications/";
+    public static final String APPLICATIONS_NAME = "application";
+    public static final String APPLICATION_POLICIES_PATH = "/application-policies/";
+    public static final String APPLICATION_POLICIES_NAME = "applicationPolicy";
+
+    public static final String TENANT1_RESOURCE ="/tenant/tenant1.json";
+    public static final String TENANT2_RESOURCE ="/tenant/tenant2.json";
+    public static final String TENANT1_GET_RESOURCE ="test1.com";
+    public static final String TENANT2_GET_RESOURCE ="test2.com";
+    public static final String TENANT_API = "/" + API + "/tenants";
+    public static final String TENANTS_NAME = "tenants";
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
new file mode 100644
index 0000000..ed233c4
--- /dev/null
+++ b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
@@ -0,0 +1,619 @@
+/*
+ * Copyright 2005-2015 WSO2, Inc. (http://wso2.com)
+ *
+ * Licensed 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.common;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.wso2.carbon.automation.engine.context.AutomationContext;
+import org.wso2.carbon.automation.engine.context.beans.User;
+import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
+import org.wso2.carbon.automation.engine.frameworkutils.CodeCoverageUtils;
+import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil;
+import org.wso2.carbon.automation.engine.frameworkutils.ReportGenerator;
+import org.wso2.carbon.automation.engine.frameworkutils.TestFrameworkUtils;
+import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerManager;
+import org.wso2.carbon.automation.extensions.servers.carbonserver.TestServerManager;
+import org.wso2.carbon.automation.extensions.servers.utils.ArchiveExtractor;
+import org.wso2.carbon.automation.extensions.servers.utils.ClientConnectionUtil;
+import org.wso2.carbon.automation.extensions.servers.utils.FileManipulator;
+import org.wso2.carbon.automation.extensions.servers.utils.ServerLogReader;
+
+import javax.xml.xpath.XPathExpressionException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+public class StratosTestServerManager extends TestServerManager {
+    private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
+    public static final String PATH_SEP = File.separator;
+    public static final String MOCK_IAAS_XML_FILENAME = "mock-iaas.xml";
+    public static final String SCALING_DROOL_FILENAME = "scaling.drl";
+    public static final String JNDI_PROPERTIES_FILENAME = "jndi.properties";
+    public static final String JMS_OUTPUT_ADAPTER_FILENAME = "JMSOutputAdaptor.xml";
+    public static final String CLOUD_CONTROLLER_FILENAME = "cloud-controller.xml";
+    public static final String AUTOSCALER_FILENAME = "autoscaler.xml";
+    public static final String CARTRIDGE_CONFIG_PROPERTIES_FILENAME = "cartridge-config.properties";
+    public static final String IDENTITY_FILENAME = "identity.xml";
+    private static final String LOG4J_PROPERTIES_FILENAME = "log4j.properties";
+    private static final String THRIFT_CLIENT_CONFIG_FILENAME = "thrift-client-config.xml";
+    private int activeMQDynamicPort;
+    private int stratosSecureDynamicPort;
+    private int stratosDynamicPort;
+    private int thriftDynamicPort;
+    private int thriftSecureDynamicPort;
+    private String webAppURL;
+    private String webAppURLHttps;
+
+    public StratosTestServerManager(AutomationContext context) {
+        super(context);
+        this.carbonServer = new StratosServerManager(context);
+    }
+
+    public StratosTestServerManager(AutomationContext context, String carbonZip, Map<String, String> commandMap) {
+        super(context, carbonZip, commandMap);
+        this.carbonServer = new StratosServerManager(context);
+        this.carbonZip = carbonZip;
+        if (commandMap.get("-DportOffset") != null) {
+            this.portOffset = Integer.parseInt((String) commandMap.get("-DportOffset"));
+            this.commandMap = commandMap;
+        } else {
+            throw new IllegalArgumentException("portOffset value must be set in command list");
+        }
+    }
+
+    public StratosTestServerManager(AutomationContext context, int portOffset) {
+        super(context, portOffset);
+        this.carbonServer = new StratosServerManager(context);
+        this.portOffset = portOffset;
+        this.commandMap.put("-DportOffset", String.valueOf(portOffset));
+    }
+
+    public StratosTestServerManager(AutomationContext context, String carbonZip) {
+        super(context, carbonZip);
+        this.carbonServer = new StratosServerManager(context);
+        this.carbonZip = carbonZip;
+    }
+
+    public String startServer() throws AutomationFrameworkException, IOException, XPathExpressionException {
+        if (this.carbonHome == null) {
+            if (this.carbonZip == null) {
+                this.carbonZip = System.getProperty("carbon.zip");
+            }
+
+            if (this.carbonZip == null) {
+                throw new IllegalArgumentException("carbon zip file cannot find in the given location");
+            }
+
+            this.carbonHome = this.carbonServer.setUpCarbonHome(this.carbonZip);
+            this.configureServer();
+        }
+
+        log.info("Carbon Home - " + this.carbonHome);
+        if (this.commandMap.get("-DportOffset") != null) {
+            this.portOffset = Integer.parseInt((String) this.commandMap.get("-DportOffset"));
+        } else {
+            this.portOffset = 0;
+        }
+
+        this.carbonServer.startServerUsingCarbonHome(this.carbonHome, this.commandMap);
+        return this.carbonHome;
+    }
+
+    public void configureServer() throws AutomationFrameworkException {
+        try {
+            log.info("Configuring server using CARBON_HOME: " + carbonHome);
+            copyArtifacts();
+
+            // set truststores and jndi.properties path
+            setSystemproperties();
+        }
+        catch (IOException e) {
+            throw new AutomationFrameworkException("Could not configure Stratos server", e);
+        }
+    }
+
+    public void stopServer() throws AutomationFrameworkException {
+        super.stopServer();
+    }
+
+    protected void copyArtifacts() throws IOException {
+        String commonResourcesPath = Util.getCommonResourcesFolderPath();
+        copyConfigFile(commonResourcesPath, MOCK_IAAS_XML_FILENAME, Util.CARBON_CONF_PATH);
+        copyConfigFile(commonResourcesPath, JNDI_PROPERTIES_FILENAME, Util.CARBON_CONF_PATH);
+        copyConfigFile(commonResourcesPath, LOG4J_PROPERTIES_FILENAME, Util.CARBON_CONF_PATH);
+        copyConfigFile(commonResourcesPath, CLOUD_CONTROLLER_FILENAME, Util.CARBON_CONF_PATH);
+        copyConfigFile(commonResourcesPath, AUTOSCALER_FILENAME, Util.CARBON_CONF_PATH);
+        copyConfigFile(commonResourcesPath, CARTRIDGE_CONFIG_PROPERTIES_FILENAME, Util.CARBON_CONF_PATH);
+        copyConfigFile(commonResourcesPath, IDENTITY_FILENAME, Util.CARBON_CONF_PATH);
+        copyConfigFile(commonResourcesPath, THRIFT_CLIENT_CONFIG_FILENAME, Util.CARBON_CONF_PATH);
+        copyConfigFile(commonResourcesPath, SCALING_DROOL_FILENAME,
+                Util.CARBON_CONF_PATH + PATH_SEP + "drools");
+        copyConfigFile(commonResourcesPath, JMS_OUTPUT_ADAPTER_FILENAME,
+                "repository" + PATH_SEP + "deployment" + PATH_SEP + "server" + PATH_SEP + "outputeventadaptors");
+
+    }
+
+    private void copyConfigFile(String filePath, String fileName, String destinationFolder)
+            throws IOException {
+        assertNotNull(carbonHome, "CARBON_HOME is null");
+        String fileAbsPath = filePath + PATH_SEP + fileName;
+        log.info("Copying file: " + fileAbsPath);
+        File srcFile = new File(fileAbsPath);
+        assertTrue(srcFile.exists(), "File does not exist [file] " + srcFile.getAbsolutePath());
+        File destFile = new File(carbonHome + PATH_SEP + destinationFolder + PATH_SEP + fileName);
+        FileUtils.copyFile(srcFile, destFile);
+        log.info("Copying file [source] " + srcFile.getAbsolutePath() + " to [dest] " + destFile.getAbsolutePath());
+
+        // replace placeholders with dynamic values
+        String content = IOUtils.toString(new FileInputStream(destFile), StandardCharsets.UTF_8.displayName());
+        content = content.replaceAll(Util.ACTIVEMQ_DYNAMIC_PORT_PLACEHOLDER, String.valueOf(activeMQDynamicPort));
+        content = content.replaceAll(Util.STRATOS_SECURE_DYNAMIC_PORT_PLACEHOLDER,
+                String.valueOf(stratosSecureDynamicPort));
+        content = content.replaceAll(Util.STRATOS_DYNAMIC_PORT_PLACEHOLDER,
+                String.valueOf(stratosDynamicPort));
+        content = content.replaceAll(Util.THRIFT_SECURE_DYNAMIC_PORT_PLACEHOLDER,
+                String.valueOf(thriftSecureDynamicPort));
+        content = content.replaceAll(Util.THRIFT_DYNAMIC_PORT_PLACEHOLDER, String.valueOf(thriftDynamicPort));
+        IOUtils.write(content, new FileOutputStream(destFile), StandardCharsets.UTF_8.displayName());
+    }
+
+    public void setSystemproperties() throws AutomationFrameworkException {
+        URL resourceUrl = getClass().getResource(File.separator + "keystores" + File.separator
+                + "products" + File.separator + "wso2carbon.jks");
+        System.setProperty("javax.net.ssl.trustStore", resourceUrl.getPath());
+        System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
+        System.setProperty("javax.net.ssl.trustStoreType", "JKS");
+        log.info("trustStore set to " + resourceUrl.getPath());
+
+        // Set jndi.properties.dir system property for initializing event receivers
+        System.setProperty("jndi.properties.dir", carbonHome + PATH_SEP + Util.CARBON_CONF_PATH);
+        try {
+            String autoscalerServiceURL = webAppURLHttps + "/services/AutoscalerService";
+            System.setProperty(StratosConstants.AUTOSCALER_SERVICE_URL, autoscalerServiceURL);
+            log.info("Autoscaler service URL set to " + autoscalerServiceURL);
+        }
+        catch (Exception e) {
+            throw new AutomationFrameworkException("Could not set autoscaler service URL system property", e);
+        }
+    }
+
+    public int getActiveMQDynamicPort() {
+        return activeMQDynamicPort;
+    }
+
+    public void setActiveMQDynamicPort(int activeMQDynamicPort) {
+        this.activeMQDynamicPort = activeMQDynamicPort;
+    }
+
+    public int getStratosSecureDynamicPort() {
+        return stratosSecureDynamicPort;
+    }
+
+    public void setStratosSecureDynamicPort(int stratosSecureDynamicPort) {
+        this.stratosSecureDynamicPort = stratosSecureDynamicPort;
+    }
+
+    public int getStratosDynamicPort() {
+        return stratosDynamicPort;
+    }
+
+    public void setStratosDynamicPort(int stratosDynamicPort) {
+        this.stratosDynamicPort = stratosDynamicPort;
+    }
+
+    public int getThriftDynamicPort() {
+        return thriftDynamicPort;
+    }
+
+    public void setThriftDynamicPort(int thriftDynamicPort) {
+        this.thriftDynamicPort = thriftDynamicPort;
+    }
+
+    public int getThriftSecureDynamicPort() {
+        return thriftSecureDynamicPort;
+    }
+
+    public void setThriftSecureDynamicPort(int thriftSecureDynamicPort) {
+        this.thriftSecureDynamicPort = thriftSecureDynamicPort;
+    }
+
+    public String getWebAppURL() {
+        return webAppURL;
+    }
+
+    public String getWebAppURLHttps() {
+        return webAppURLHttps;
+    }
+
+    public void setWebAppURL(String webAppURL) {
+        this.webAppURL = webAppURL;
+    }
+
+    public void setWebAppURLHttps(String webAppURLHttps) {
+        this.webAppURLHttps = webAppURLHttps;
+    }
+}
+
+// TODO: get rid of this class once startup script issue is fixed in automation engine
+class StratosServerManager extends CarbonServerManager {
+    private final static Log log = LogFactory.getLog(StratosServerManager.class);
+    private Process process;
+    private String carbonHome;
+    private AutomationContext automationContext;
+    private ServerLogReader inputStreamHandler;
+    private ServerLogReader errorStreamHandler;
+    private boolean isCoverageEnable = false;
+    private String coverageDumpFilePath;
+    private int portOffset = 0;
+    private static final String SERVER_SHUTDOWN_MESSAGE = "Halting JVM";
+    private static final String SERVER_STARTUP_MESSAGE = "Mgt Console URL";
+    private static final long DEFAULT_START_STOP_WAIT_MS = 300000L;
+    private static final String CMD_ARG = "cmdArg";
+    private static int defaultHttpPort = Integer.parseInt("9763");
+    private static int defaultHttpsPort = Integer.parseInt("9443");
+
+    public StratosServerManager(AutomationContext context) {
+        super(context);
+        this.automationContext = context;
+    }
+
+    public synchronized void startServerUsingCarbonHome(String carbonHome, Map<String, String> commandMap)
+            throws AutomationFrameworkException {
+        if (this.process == null) {
+            this.portOffset = this.checkPortAvailability(commandMap);
+            Process tempProcess = null;
+
+            try {
+                if (!commandMap.isEmpty() && this.getPortOffsetFromCommandMap(commandMap) == 0) {
+                    System.setProperty("carbon.home", carbonHome);
+                }
+
+                File e = new File(carbonHome);
+                log.info("Starting carbon server............. ");
+                String scriptName = TestFrameworkUtils.getStartupScriptFileName(carbonHome);
+                String[] parameters = this.expandServerStartupCommandList(commandMap);
+                String[] cmdArray;
+                if (System.getProperty("os.name").toLowerCase().contains("windows")) {
+                    e = new File(carbonHome + File.separator + "bin");
+                    cmdArray = new String[]{"cmd.exe", "/c", scriptName + ".bat"};
+                    cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
+                    tempProcess = Runtime.getRuntime().exec(cmdArray, (String[]) null, e);
+                } else {
+                    cmdArray = new String[]{"sh", "bin/" + scriptName + ".sh"};
+                    cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
+                    tempProcess = Runtime.getRuntime().exec(cmdArray, (String[]) null, e);
+                }
+
+                this.errorStreamHandler = new ServerLogReader("errorStream", tempProcess.getErrorStream());
+                this.inputStreamHandler = new ServerLogReader("inputStream", tempProcess.getInputStream());
+                this.inputStreamHandler.start();
+                this.errorStreamHandler.start();
+                Runtime.getRuntime().addShutdownHook(new Thread() {
+                    public void run() {
+                        try {
+                            StratosServerManager.this.serverShutdown(StratosServerManager.this.portOffset);
+                        }
+                        catch (Exception var2) {
+                            log.error("Error while server shutdown ..", var2);
+                        }
+
+                    }
+                });
+                ClientConnectionUtil.waitForPort(defaultHttpPort + this.portOffset, 300000L, false,
+                        (String) this.automationContext.getInstance().getHosts().get("default"));
+                long time = System.currentTimeMillis() + 60000L;
+
+                while (true) {
+                    if (this.inputStreamHandler.getOutput().contains("Mgt Console URL") ||
+                            System.currentTimeMillis() >= time) {
+                        int httpsPort = defaultHttpsPort + this.portOffset;
+                        String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl()
+                                .replaceAll("(:\\d+)", ":" + httpsPort);
+                        User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
+                        ClientConnectionUtil.waitForLogin(backendURL, superUser);
+                        log.info("Server started successfully.");
+                        break;
+                    }
+                }
+            }
+            catch (XPathExpressionException | IOException var13) {
+                throw new IllegalStateException("Unable to start server", var13);
+            }
+
+            this.process = tempProcess;
+        }
+    }
+
+    private int checkPortAvailability(Map<String, String> commandMap) throws AutomationFrameworkException {
+        int portOffset = this.getPortOffsetFromCommandMap(commandMap);
+        if (ClientConnectionUtil.isPortOpen(defaultHttpPort + portOffset)) {
+            throw new AutomationFrameworkException(
+                    "Unable to start carbon server on port " + (defaultHttpPort + portOffset) +
+                            " : Port already in use");
+        } else if (ClientConnectionUtil.isPortOpen(defaultHttpsPort + portOffset)) {
+            throw new AutomationFrameworkException(
+                    "Unable to start carbon server on port " + (defaultHttpsPort + portOffset) +
+                            " : Port already in use");
+        } else {
+            return portOffset;
+        }
+    }
+
+    private String[] mergePropertiesToCommandArray(String[] parameters, String[] cmdArray) {
+        if (parameters != null) {
+            cmdArray = this.mergerArrays(cmdArray, parameters);
+        }
+
+        return cmdArray;
+    }
+
+    public synchronized String setUpCarbonHome(String carbonServerZipFile)
+            throws IOException, AutomationFrameworkException {
+        if (this.process != null) {
+            return this.carbonHome;
+        } else {
+            int indexOfZip = carbonServerZipFile.lastIndexOf(".zip");
+            if (indexOfZip == -1) {
+                throw new IllegalArgumentException(carbonServerZipFile + " is not a zip file");
+            } else {
+                String fileSeparator = File.separator.equals("\\") ? "\\" : "/";
+                if (fileSeparator.equals("\\")) {
+                    carbonServerZipFile = carbonServerZipFile.replace("/", "\\");
+                }
+
+                String extractedCarbonDir = carbonServerZipFile
+                        .substring(carbonServerZipFile.lastIndexOf(fileSeparator) + 1, indexOfZip);
+                FileManipulator.deleteDir(extractedCarbonDir);
+                String extractDir = "carbontmp" + System.currentTimeMillis();
+                String baseDir = System.getProperty("basedir", ".") + File.separator + "target";
+                log.info("Extracting carbon zip file.. ");
+                (new ArchiveExtractor()).extractFile(carbonServerZipFile, baseDir + File.separator + extractDir);
+                this.carbonHome =
+                        (new File(baseDir)).getAbsolutePath() + File.separator + extractDir + File.separator +
+                                extractedCarbonDir;
+
+                try {
+                    this.isCoverageEnable =
+                            Boolean.parseBoolean(this.automationContext.getConfigurationValue("//coverage"));
+                }
+                catch (XPathExpressionException var8) {
+                    throw new AutomationFrameworkException("Coverage configuration not found in automation.xml",
+                            var8);
+                }
+                // Fix startup script issue by copying stratos.sh as stratos-server.sh
+                // TODO: remove this class after automation engine provides a way to pass startup script name
+                // currently startup script should be either wso2server.sh or contain the string 'server'
+                FileUtils.copyFile(new File(carbonHome + File.separator + "bin" + File.separator + "stratos.sh"),
+                        new File(carbonHome + File.separator + "bin" + File.separator + "stratos-server.sh"));
+
+                if (this.isCoverageEnable) {
+                    this.instrumentForCoverage();
+                }
+
+                return this.carbonHome;
+            }
+        }
+    }
+
+    public synchronized void serverShutdown(int portOffset) throws AutomationFrameworkException {
+        if (this.process != null) {
+            log.info("Shutting down server..");
+            if (ClientConnectionUtil.isPortOpen(Integer.parseInt("9443") + portOffset)) {
+                int e = defaultHttpsPort + portOffset;
+                String url = null;
+
+                try {
+                    url = this.automationContext.getContextUrls().getBackEndUrl();
+                }
+                catch (XPathExpressionException var10) {
+                    throw new AutomationFrameworkException("Get context failed", var10);
+                }
+
+                String backendURL = url.replaceAll("(:\\d+)", ":" + e);
+
+                try {
+                    ClientConnectionUtil.sendForcefulShutDownRequest(backendURL,
+                            this.automationContext.getSuperTenant().getContextUser().getUserName(),
+                            this.automationContext.getSuperTenant().getContextUser().getPassword());
+                }
+                catch (AutomationFrameworkException var8) {
+                    throw new AutomationFrameworkException("Get context failed", var8);
+                }
+                catch (XPathExpressionException var9) {
+                    throw new AutomationFrameworkException("Get context failed", var9);
+                }
+
+                long time = System.currentTimeMillis() + 300000L;
+
+                while (!this.inputStreamHandler.getOutput().contains("Halting JVM") &&
+                        System.currentTimeMillis() < time) {
+                    ;
+                }
+
+                log.info("Server stopped successfully...");
+            }
+
+            this.inputStreamHandler.stop();
+            this.errorStreamHandler.stop();
+            this.process.destroy();
+            this.process = null;
+            if (this.isCoverageEnable) {
+                try {
+                    log.info("Generating Jacoco code coverage...");
+                    this.generateCoverageReport(new File(
+                            this.carbonHome + File.separator + "repository" + File.separator + "components" +
+                                    File.separator + "plugins" + File.separator));
+                }
+                catch (IOException var7) {
+                    log.error("Failed to generate code coverage ", var7);
+                    throw new AutomationFrameworkException("Failed to generate code coverage ", var7);
+                }
+            }
+
+            if (portOffset == 0) {
+                System.clearProperty("carbon.home");
+            }
+        }
+
+    }
+
+    private void generateCoverageReport(File classesDir) throws IOException, AutomationFrameworkException {
+        CodeCoverageUtils
+                .executeMerge(FrameworkPathUtil.getJacocoCoverageHome(),
+                        FrameworkPathUtil.getCoverageMergeFilePath());
+        ReportGenerator reportGenerator =
+                new ReportGenerator(new File(FrameworkPathUtil.getCoverageMergeFilePath()), classesDir,
+                        new File(CodeCoverageUtils.getJacocoReportDirectory()), (File) null);
+        reportGenerator.create();
+        log.info("Jacoco coverage dump file path : " + FrameworkPathUtil.getCoverageDumpFilePath());
+        log.info("Jacoco class file path : " + classesDir);
+        log.info("Jacoco coverage HTML report path : " + CodeCoverageUtils.getJacocoReportDirectory() +
+                File.separator + "index.html");
+    }
+
+    public synchronized void restartGracefully() throws AutomationFrameworkException {
+        try {
+            int time = defaultHttpsPort + this.portOffset;
+            String backendURL =
+                    this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + time);
+            User e = this.automationContext.getSuperTenant().getTenantAdmin();
+            ClientConnectionUtil.sendGraceFullRestartRequest(backendURL, e.getUserName(), e.getPassword());
+        }
+        catch (XPathExpressionException var5) {
+            throw new AutomationFrameworkException("restart failed", var5);
+        }
+
+        long time1 = System.currentTimeMillis() + 300000L;
+
+        while (!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time1) {
+            ;
+        }
+
+        time1 = System.currentTimeMillis();
+
+        while (System.currentTimeMillis() < time1 + 5000L) {
+            ;
+        }
+
+        try {
+            ClientConnectionUtil.waitForPort(
+                    Integer.parseInt((String) this.automationContext.getInstance().getPorts().get("https")),
+                    (String) this.automationContext.getInstance().getHosts().get("default"));
+            ClientConnectionUtil.waitForLogin(this.automationContext);
+        }
+        catch (XPathExpressionException var4) {
+            throw new AutomationFrameworkException("Connection attempt to carbon server failed", var4);
+        }
+    }
+
+    private String[] expandServerStartupCommandList(Map<String, String> commandMap) {
+        if (commandMap != null && commandMap.size() != 0) {
+            String[] cmdParaArray = null;
+            String cmdArg = null;
+            if (commandMap.containsKey("cmdArg")) {
+                cmdArg = (String) commandMap.get("cmdArg");
+                cmdParaArray = cmdArg.trim().split("\\s+");
+                commandMap.remove("cmdArg");
+            }
+
+            String[] parameterArray = new String[commandMap.size()];
+            int arrayIndex = 0;
+            Set entries = commandMap.entrySet();
+
+            String parameter;
+            for (Iterator i$ = entries.iterator(); i$.hasNext(); parameterArray[arrayIndex++] = parameter) {
+                Map.Entry entry = (Map.Entry) i$.next();
+                String key = (String) entry.getKey();
+                String value = (String) entry.getValue();
+                if (value != null && !value.isEmpty()) {
+                    parameter = key + "=" + value;
+                } else {
+                    parameter = key;
+                }
+            }
+
+            if (cmdArg != null) {
+                commandMap.put("cmdArg", cmdArg);
+            }
+
+            if (cmdParaArray != null && cmdParaArray.length != 0) {
+                return (String[]) ArrayUtils.addAll(parameterArray, cmdParaArray);
+            } else {
+                return parameterArray;
+            }
+        } else {
+            return null;
+        }
+    }
+
+    private int getPortOffsetFromCommandMap(Map<String, String> commandMap) {
+        return commandMap.containsKey("-DportOffset") ? Integer.parseInt((String) commandMap.get("-DportOffset")) :
+                0;
+    }
+
+    private String[] mergerArrays(String[] array1, String[] array2) {
+        return (String[]) ArrayUtils.addAll(array1, array2);
+    }
+
+    private void insertJacocoAgentToShellScript(String scriptName) throws IOException {
+        String jacocoAgentFile = CodeCoverageUtils.getJacocoAgentJarLocation();
+        this.coverageDumpFilePath = FrameworkPathUtil.getCoverageDumpFilePath();
+        CodeCoverageUtils.insertStringToFile(
+                new File(this.carbonHome + File.separator + "bin" + File.separator + scriptName + ".sh"),
+                new File(this.carbonHome + File.separator + "tmp" + File.separator + scriptName + ".sh"),
+                "-Dwso2.server.standalone=true",
+                "-javaagent:" + jacocoAgentFile + "=destfile=" + this.coverageDumpFilePath + "" +
+                        ",append=true,includes=" + CodeCoverageUtils.getInclusionJarsPattern(":") + " \\");
+    }
+
+    private void insertJacocoAgentToBatScript(String scriptName) throws IOException {
+        String jacocoAgentFile = CodeCoverageUtils.getJacocoAgentJarLocation();
+        this.coverageDumpFilePath = FrameworkPathUtil.getCoverageDumpFilePath();
+        CodeCoverageUtils.insertJacocoAgentToStartupBat(
+                new File(this.carbonHome + File.separator + "bin" + File.separator + scriptName + ".bat"),
+                new File(this.carbonHome + File.separator + "tmp" + File.separator + scriptName + ".bat"),
+                "-Dcatalina.base", "-javaagent:" + jacocoAgentFile + "=destfile=" + this.coverageDumpFilePath + "" +
+                        ",append=true,includes=" + CodeCoverageUtils.getInclusionJarsPattern(":"));
+    }
+
+    private void instrumentForCoverage() throws IOException, AutomationFrameworkException {
+        String scriptName = TestFrameworkUtils.getStartupScriptFileName(this.carbonHome);
+        if (System.getProperty("os.name").toLowerCase().contains("windows")) {
+            this.insertJacocoAgentToBatScript(scriptName);
+            if (log.isDebugEnabled()) {
+                log.debug("Included files " + CodeCoverageUtils.getInclusionJarsPattern(":"));
+                log.debug("Excluded files " + CodeCoverageUtils.getExclusionJarsPattern(":"));
+            }
+        } else {
+            this.insertJacocoAgentToShellScript(scriptName);
+        }
+
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/TopologyHandler.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/TopologyHandler.java b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/TopologyHandler.java
new file mode 100644
index 0000000..84ec17f
--- /dev/null
+++ b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/TopologyHandler.java
@@ -0,0 +1,689 @@
+/*
+ * 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.common;
+
+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.integration.common.rest.IntegrationMockClient;
+import org.apache.stratos.messaging.domain.application.*;
+import org.apache.stratos.messaging.domain.instance.ClusterInstance;
+import org.apache.stratos.messaging.domain.instance.GroupInstance;
+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.event.Event;
+import org.apache.stratos.messaging.event.application.*;
+import org.apache.stratos.messaging.event.topology.*;
+import org.apache.stratos.messaging.listener.application.*;
+import org.apache.stratos.messaging.listener.topology.*;
+import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
+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.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+
+import static org.testng.AssertJUnit.*;
+
+/**
+ * To start the Topology receivers
+ */
+public class TopologyHandler {
+    private static final Log log = LogFactory.getLog(TopologyHandler.class);
+
+
+    public static final int APPLICATION_ACTIVATION_TIMEOUT = 400000;
+    public static final int APPLICATION_UNDEPLOYMENT_TIMEOUT = 60000;
+    public static final int APPLICATION_TOPOLOGY_TIMEOUT = 60000;
+
+    public static final String APPLICATION_STATUS_CREATED = "Created";
+    public static final String APPLICATION_STATUS_UNDEPLOYING = "Undeploying";
+    private ApplicationsEventReceiver applicationsEventReceiver;
+    private TopologyEventReceiver topologyEventReceiver;
+    public static TopologyHandler topologyHandler;
+    private Map<String, Long> terminatedMembers = new ConcurrentHashMap<String, Long>();
+    private Map<String, Long> terminatingMembers = new ConcurrentHashMap<String, Long>();
+    private Map<String, Long> createdMembers = new ConcurrentHashMap<String, Long>();
+    private Map<String, Long> inActiveMembers = new ConcurrentHashMap<String, Long>();
+    private Map<String, Long> activateddMembers = new ConcurrentHashMap<String, Long>();
+
+    private TopologyHandler() {
+        initializeApplicationEventReceiver();
+        initializeTopologyEventReceiver();
+        assertApplicationTopologyInitialized();
+        assertTopologyInitialized();
+        addTopologyEventListeners();
+        addApplicationEventListeners();
+    }
+
+    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 tenantId
+     * @param applicationName
+     */
+    public void assertApplicationStatus(String applicationName, ApplicationStatus status, int tenantId) {
+        long startTime = System.currentTimeMillis();
+        Application application =
+                ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
+        while (!((application != null) && (application.getStatus() == status))) {
+            try {
+                Thread.sleep(1000);
+            }
+            catch (InterruptedException ignore) {
+            }
+            application = ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
+            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 %s: [application-id] %s",
+                        status.toString(), applicationName),
+                status, application.getStatus());
+    }
+
+    public Application getApplication(String applicationName, int tenantId) {
+        return ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
+    }
+
+    public void assertApplicationForNonAvailability(String applicationName, int tenantId) {
+
+        Application application =
+                ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
+        assertNull(String.format("Application is found for other tenant : [application-id] %s", applicationName),
+                application);
+    }
+
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     * @param tenantId
+     */
+    public void assertGroupActivation(String applicationName, int tenantId) {
+        Application application =
+                ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
+        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
+     * @param tenantId
+     */
+    public void assertClusterActivation(String applicationName, int tenantId) {
+        Application application =
+                ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
+        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);
+        }
+
+    }
+
+    /**
+     * Assert application activation
+     *
+     * @param tenantId
+     * @param applicationName
+     */
+
+    public void terminateMemberFromCluster(String cartridgeName, String applicationName,
+                                           IntegrationMockClient mockIaasApiClient, int tenantId) {
+        Application application =
+                ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
+        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();
+            if (cartridgeName.equals(serviceUuid)) {
+                String clusterId = clusterDataHolder.getClusterId();
+                Service service = TopologyManager.getTopology().getService(serviceUuid);
+                assertNotNull(String.format("Service is not found: [application-id] %s [service uuid] %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 memberTerminated = false;
+
+                for (ClusterInstance instance : cluster.getInstanceIdToInstanceContextMap().values()) {
+                    for (Member member : cluster.getMembers()) {
+                        if (member.getClusterInstanceId().equals(instance.getInstanceId())) {
+                            if (member.getStatus().equals(MemberStatus.Active)) {
+                                mockIaasApiClient.terminateInstance(member.getMemberId());
+                                memberTerminated = true;
+                                break;
+                            }
+                        }
+                    }
+
+                    if (memberTerminated) {
+                        break;
+                    }
+
+                }
+                assertTrue("Any member couldn't be terminated from the mock IaaS client", memberTerminated);
+            }
+
+        }
+
+    }
+
+    public void assertClusterMinMemberCount(String applicationName, int minMembers, int tenantId) {
+        long startTime = System.currentTimeMillis();
+
+        Application application =
+                ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
+        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
+     * @param tenantId
+     */
+    public boolean assertApplicationUndeploy(String applicationName, int tenantId) {
+        long startTime = System.currentTimeMillis();
+        Application application =
+                ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
+        ApplicationContext applicationContext = null;
+        try {
+            applicationContext =
+                    AutoscalerServiceClient.getInstance().getApplicationByTenant(applicationName, tenantId);
+        }
+        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, tenantId);
+            try {
+                applicationContext =
+                        AutoscalerServiceClient.getInstance().getApplicationByTenant(applicationName, tenantId);
+            }
+            catch (RemoteException e) {
+                log.error("Error while getting the application context for [application] " + applicationName);
+            }
+            if ((System.currentTimeMillis() - startTime) > APPLICATION_UNDEPLOYMENT_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 tenantId
+     * @param applicationName
+     */
+    public void assertGroupInstanceCount(String applicationName, String groupAlias, int count, int tenantId) {
+        long startTime = System.currentTimeMillis();
+        Application application =
+                ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
+        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);
+    }
+
+    private void addTopologyEventListeners() {
+        topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event;
+                getTerminatedMembers().put(memberTerminatedEvent.getMemberId(), System.currentTimeMillis());
+
+            }
+        });
+
+
+        topologyEventReceiver.addEventListener(new ClusterInstanceCreatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                ClusterInstanceCreatedEvent event1 = (ClusterInstanceCreatedEvent) event;
+                String clusterId = event1.getClusterId();
+                getCreatedMembers().put(clusterId, System.currentTimeMillis());
+            }
+        });
+
+        topologyEventReceiver.addEventListener(new ClusterInstanceActivatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                ClusterInstanceActivatedEvent event1 = (ClusterInstanceActivatedEvent) event;
+                String clusterId = event1.getClusterId();
+                getActivateddMembers().put(clusterId, System.currentTimeMillis());
+
+            }
+        });
+
+        topologyEventReceiver.addEventListener(new ClusterInstanceInactivateEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                ClusterInstanceInactivateEvent event1 = (ClusterInstanceInactivateEvent) event;
+                String clusterId = event1.getClusterId();
+                getInActiveMembers().put(clusterId, System.currentTimeMillis());
+            }
+        });
+
+        topologyEventReceiver.addEventListener(new ClusterInstanceTerminatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                ClusterInstanceTerminatedEvent event1 = (ClusterInstanceTerminatedEvent) event;
+                String clusterId = event1.getClusterId();
+                getTerminatedMembers().put(clusterId, System.currentTimeMillis());
+            }
+        });
+
+        topologyEventReceiver.addEventListener(new ClusterInstanceTerminatingEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                ClusterInstanceTerminatingEvent event1 = (ClusterInstanceTerminatingEvent) event;
+                String clusterId = event1.getClusterId();
+                getTerminatingMembers().put(clusterId, System.currentTimeMillis());
+            }
+        });
+
+
+    }
+
+    private void addApplicationEventListeners() {
+
+        applicationsEventReceiver.addEventListener(new GroupInstanceCreatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                GroupInstanceCreatedEvent event1 = (GroupInstanceCreatedEvent) event;
+                String appId = event1.getAppId();
+                String groupId = event1.getGroupId();
+                String instanceId = event1.getGroupInstance().getInstanceId();
+                String id = generateId(appId, groupId, instanceId);
+                getCreatedMembers().put(id, System.currentTimeMillis());
+
+            }
+        });
+
+        applicationsEventReceiver.addEventListener(new GroupInstanceActivatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                GroupInstanceActivatedEvent event1 = (GroupInstanceActivatedEvent) event;
+                String appId = event1.getAppId();
+                String groupId = event1.getGroupId();
+                String instanceId = event1.getInstanceId();
+                String id = generateId(appId, groupId, instanceId);
+                getActivateddMembers().put(id, System.currentTimeMillis());
+            }
+        });
+
+        applicationsEventReceiver.addEventListener(new GroupInstanceInactivateEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                GroupInstanceInactivatedEvent event1 = (GroupInstanceInactivatedEvent) event;
+                String appId = event1.getAppId();
+                String groupId = event1.getGroupId();
+                String instanceId = event1.getInstanceId();
+                String id = generateId(appId, groupId, instanceId);
+                getInActiveMembers().put(id, System.currentTimeMillis());
+            }
+        });
+
+        applicationsEventReceiver.addEventListener(new GroupInstanceTerminatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                GroupInstanceTerminatedEvent event1 = (GroupInstanceTerminatedEvent) event;
+                String appId = event1.getAppId();
+                String groupId = event1.getGroupId();
+                String instanceId = event1.getInstanceId();
+                String id = generateId(appId, groupId, instanceId);
+                getTerminatedMembers().put(id, System.currentTimeMillis());
+            }
+        });
+
+        applicationsEventReceiver.addEventListener(new GroupInstanceTerminatingEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                GroupInstanceTerminatingEvent event1 = (GroupInstanceTerminatingEvent) event;
+                String appId = event1.getAppId();
+                String groupId = event1.getGroupId();
+                String instanceId = event1.getInstanceId();
+                String id = generateId(appId, groupId, instanceId);
+                getTerminatingMembers().put(id, System.currentTimeMillis());
+            }
+        });
+    }
+
+    public String generateId(String appId, String groupId, String instanceId) {
+        return appId + "-" + groupId + "-" + instanceId;
+    }
+
+    public String getClusterIdFromAlias(String applicationId, String alias, int tenantId) {
+        Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationId, tenantId);
+        assertNotNull(application);
+
+        ClusterDataHolder dataHolder = application.getClusterDataHolderRecursivelyByAlias(alias);
+        assertNotNull(dataHolder);
+
+        return dataHolder.getClusterId();
+    }
+
+
+    public void removeMembersFromMaps(String applicationId) {
+        for (Map.Entry<String, Long> entry : getActivateddMembers().entrySet()) {
+            if (entry.getKey().contains(applicationId)) {
+                getActivateddMembers().remove(entry.getKey());
+            }
+        }
+
+        for (Map.Entry<String, Long> entry : getTerminatedMembers().entrySet()) {
+            if (entry.getKey().contains(applicationId)) {
+                getTerminatedMembers().remove(entry.getKey());
+            }
+        }
+    }
+
+    public Map<String, Long> getTerminatedMembers() {
+        return terminatedMembers;
+    }
+
+    public void setTerminatedMembers(Map<String, Long> terminatedMembers) {
+        this.terminatedMembers = terminatedMembers;
+    }
+
+    public Map<String, Long> getTerminatingMembers() {
+        return terminatingMembers;
+    }
+
+    public void setTerminatingMembers(Map<String, Long> terminatingMembers) {
+        this.terminatingMembers = terminatingMembers;
+    }
+
+    public Map<String, Long> getCreatedMembers() {
+        return createdMembers;
+    }
+
+    public void setCreatedMembers(Map<String, Long> createdMembers) {
+        this.createdMembers = createdMembers;
+    }
+
+    public Map<String, Long> getInActiveMembers() {
+        return inActiveMembers;
+    }
+
+    public void setInActiveMembers(Map<String, Long> inActiveMembers) {
+        this.inActiveMembers = inActiveMembers;
+    }
+
+    public Map<String, Long> getActivateddMembers() {
+        return activateddMembers;
+    }
+
+    public void setActivateddMembers(Map<String, Long> activateddMembers) {
+        this.activateddMembers = activateddMembers;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/Util.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/Util.java b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/Util.java
new file mode 100644
index 0000000..4cdf4a7
--- /dev/null
+++ b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/Util.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2005-2015 WSO2, Inc. (http://wso2.com)
+ *
+ * Licensed 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.common;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.ServerSocket;
+
+public class Util {
+    public static final String CARBON_ZIP_KEY = "carbon.zip";
+    public static final String ACTIVEMQ_BIND_ADDRESS = "activemq.bind.address";
+    public static final String CARBON_CONF_PATH = "repository" + File.separator + "conf";
+    public static final String BASE_PATH = Util.class.getResource(File.separator).getPath();
+    public static final int MIN_PORT_NUMBER = 1;
+    public static final int MAX_PORT_NUMBER = 65535;
+    public static final int SUPER_TENANT_ID = -1234;
+
+    public static final String STRATOS_SECURE_DYNAMIC_PORT_PLACEHOLDER = "STRATOS_SECURE_DYNAMIC_PORT";
+    public static final String ACTIVEMQ_DYNAMIC_PORT_PLACEHOLDER = "ACTIVEMQ_DYNAMIC_PORT";
+    public static final String THRIFT_DYNAMIC_PORT_PLACEHOLDER = "THRIFT_DYNAMIC_PORT";
+    public static final String STRATOS_DYNAMIC_PORT_PLACEHOLDER = "STRATOS_DYNAMIC_PORT";
+    public static final String THRIFT_SECURE_DYNAMIC_PORT_PLACEHOLDER = "THRIFT_SECURE_DYNAMIC_PORT";
+
+    public static final int THRIFT_DEFAULT_PORT = 7611;
+    public static final int THRIFT_DEFAULT_SECURE_PORT = 7711;
+    public static final int STRATOS_DEFAULT_PORT = 9763;
+    public static final int STRATOS_DEFAULT_SECURE_PORT = 9443;
+    public static final int STRATOS_DEFAULT_RMI_REGISTRY_PORT = 9999;
+    public static final int STRATOS_DEFAULT_RMI_SERVER_PORT = 11111;
+
+    /**
+     * Get resources folder path
+     *
+     * @return path to resources folder
+     */
+    public static String getCommonResourcesFolderPath() {
+        return BASE_PATH + ".." + File.separator + ".." + File.separator + "src" + File.separator + "test" +
+                File.separator + "resources" + File.separator + "common";
+    }
+
+    /**
+     * Checks to see if a specific port is available.
+     *
+     * @param port the port to check for availability
+     */
+    public static boolean isPortAvailable(int port) {
+        if (port < Util.MIN_PORT_NUMBER || port > Util.MAX_PORT_NUMBER) {
+            throw new IllegalArgumentException("Invalid start port: " + port);
+        }
+
+        ServerSocket ss = null;
+        try {
+            ss = new ServerSocket(port);
+            ss.setReuseAddress(true);
+            return true;
+        }
+        catch (IOException ignored) {
+        }
+        finally {
+            if (ss != null) {
+                try {
+                    ss.close();
+                }
+                catch (IOException ignored) {
+                }
+            }
+        }
+        return false;
+    }
+}
\ No newline at end of file