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

[1/8] stratos git commit: adding integration tests for CRUD operation of autoscaling policy, deployment policy, network partition and cartridges

Repository: stratos
Updated Branches:
  refs/heads/tenant-isolation e6eb0ec1d -> e57a2f735


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

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/README.md
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/README.md b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/README.md
new file mode 100644
index 0000000..4e092ea
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/README.md
@@ -0,0 +1,25 @@
+Single Cartridge Application
+============================
+A simple application with a php cartridge.
+
+Application view
+----------------
+single-cartridge-app            <br />
+-- single-cartridge-app-1       <br />
+-- -- my-php                    <br />
+
+Application folder structure
+----------------------------
+-- artifacts/[iaas]/ IaaS specific artifacts                <br />
+-- scripts/common/ Common scripts for all iaases            <br />
+-- scripts/[iaas] IaaS specific scripts                     <br />
+
+How to run
+----------
+cd scripts/[iaas]/          <br />
+./deploy.sh                 <br />
+
+How to undeploy
+---------------
+cd scripts/[iaas]/          <br />
+./undeploy.sh               <br />
\ No newline at end of file

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

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

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/README.md
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/README.md b/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/README.md
new file mode 100644
index 0000000..d0c764b
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/README.md
@@ -0,0 +1,28 @@
+Single Group Application
+========================
+An application with a tomcat cartridge and a cartridge group which consists of esb and php cartridges.
+
+Application view
+----------------
+single-group-app            <br />
+-- cartridge-group-app-1    <br />
+-- -- my-tomcat             <br />
+-- -- my-esb-php-group      <br />
+-- -- -- my-esb             <br />
+-- -- -- my-php             <br />
+
+Application folder structure
+----------------------------
+-- artifacts/[iaas]/ IaaS specific artifacts                <br />
+-- scripts/common/ Common scripts for all iaases            <br />
+-- scripts/[iaas] IaaS specific scripts                     <br />
+
+How to run
+----------
+cd scripts/[iaas]/          <br />
+./deploy.sh                 <br />
+
+How to undeploy
+---------------
+cd scripts/[iaas]/          <br />
+./undeploy.sh               <br />
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/artifacts/application.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/artifacts/application.json b/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/artifacts/application.json
new file mode 100644
index 0000000..c16a3f3
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/artifacts/application.json
@@ -0,0 +1,69 @@
+{
+    "applicationId": "cartridge-group-app",
+    "alias": "my-cartridge-group-app",
+    "components": {
+        "groups": [
+            {
+                "name": "esb-php-group",
+                "alias": "my-esb-php-group",
+                "deploymentPolicy": "deployment-policy-1",
+                "groupMinInstances": 1,
+                "groupMaxInstances": 2,
+                "cartridges": [
+                    {
+                        "type": "esb",
+                        "cartridgeMin": 1,
+                        "cartridgeMax": 2,
+                        "subscribableInfo": {
+                            "alias": "my-esb",
+                            "autoscalingPolicy": "autoscaling-policy-1",
+                            "artifactRepository": {
+                                "privateRepo": false,
+                                "repoUrl": "https://github.com/imesh/stratos-esb-applications.git",
+                                "repoUsername": "",
+                                "repoPassword": ""
+                            }
+                        }
+                    },
+                    {
+                        "type": "php",
+                        "cartridgeMin": 1,
+                        "cartridgeMax": 2,
+                        "subscribableInfo": {
+                            "alias": "my-php",
+                            "autoscalingPolicy": "autoscaling-policy-1",
+                            "artifactRepository": {
+                                "privateRepo": false,
+                                "repoUrl": "https://github.com/imesh/stratos-php-applications.git",
+                                "repoUsername": "",
+                                "repoPassword": ""
+                            }
+                        }
+                    }
+                ]
+            }
+        ],
+        "cartridges": [
+            {
+                "type": "tomcat",
+                "cartridgeMin": 2,
+                "cartridgeMax": 4,
+                "subscribableInfo": {
+                    "alias": "my-tomcat",
+                    "autoscalingPolicy": "autoscaling-policy-1",
+                    "deploymentPolicy": "deployment-policy-1",
+                    "artifactRepository": {
+                        "privateRepo": false,
+                        "repoUrl": "https://github.com/imesh/stratos-tomcat-applications.git",
+                        "repoUsername": "",
+                        "repoPassword": ""
+                    }
+                }
+            }
+        ],
+        "dependencies": {
+            "terminationBehaviour": "terminate-none"
+        }
+    }
+}
+

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/autoscaling-policies/update/autoscaling-policy-c0.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/autoscaling-policies/update/autoscaling-policy-c0.json b/products/stratos/modules/integration/src/test/resources/autoscaling-policies/update/autoscaling-policy-c0.json
new file mode 100644
index 0000000..31c2b84
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/autoscaling-policies/update/autoscaling-policy-c0.json
@@ -0,0 +1,14 @@
+{
+    "id": "autoscaling-policy-c0",
+    "loadThresholds": {
+        "requestsInFlight": {
+            "threshold": 30
+        },
+        "memoryConsumption": {
+            "threshold": 40
+        },
+        "loadAverage": {
+            "threshold": 20
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/cartridge-groups/group1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-groups/group1.json b/products/stratos/modules/integration/src/test/resources/cartridge-groups/group1.json
new file mode 100644
index 0000000..8fc36dd
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-groups/group1.json
@@ -0,0 +1,38 @@
+{
+    "name": "group1",
+    "groups": [
+        {
+            "name": "group2",
+            "cartridges": [
+                "c3",
+                "c2"
+            ],
+            "dependencies": {
+                "startupOrders": [
+                    {
+                        "aliases": [
+                            "cartridge.my-c3-group2",
+                            "cartridge.my-c2-group2"
+                        ]
+                    }
+                ],
+                "terminationBehaviour": "terminate-all"
+            }
+        }
+    ],
+    "cartridges": [
+        "c1"
+    ],
+    "dependencies": {
+        "startupOrders": [
+            {
+                "aliases": [
+                    "cartridge.my-c1-group1",
+                    "group.my-group2"
+                ]
+            }
+        ],
+        "terminationBehaviour": "terminate-dependents"
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json b/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json
new file mode 100644
index 0000000..8ef80e7
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json
@@ -0,0 +1,36 @@
+{
+    "name": "G1",
+    "dependencies": {
+        "terminationBehaviour": "terminate-none",
+        "startupOrders": ["group.group2,cartridge.c1-1x0"]
+    },
+    "cartridges": [
+        "c1"
+    ],
+    "groups": [
+        {
+            "name": "G2",
+            "dependencies": {
+                "terminationBehaviour": "terminate-dependents",
+                "startupOrders": ["group.group3,cartridge.c2-1x0"]
+            },
+            "cartridges": [
+                "c2"
+            ],
+            "groups": [
+                {
+                    "name": "G3",
+                    "dependencies": {
+                        "terminationBehaviour": "terminate-all",
+                        "startupOrders": []
+                    },
+                    "cartridges": [
+                        "c3"
+                    ],
+                    "groups": []
+                }
+            ]
+        }
+    ]
+}
+

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/cartridges/mock/update/c0.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges/mock/update/c0.json b/products/stratos/modules/integration/src/test/resources/cartridges/mock/update/c0.json
new file mode 100755
index 0000000..6d922a9
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridges/mock/update/c0.json
@@ -0,0 +1,124 @@
+{
+    "category": "Data",
+    "description": "c0 Cartridge",
+    "displayName": "c0",
+    "host": "qmog.cisco.com12",
+    "iaasProvider": [
+        {
+            "imageId": "RegionOne/16e7e35b-0c88-4605-90ce-cbef9e9d123",
+            "maxInstanceLimit": "4",
+            "networkInterfaces": [
+                {
+                    "floatingNetworks": [
+                        {
+                            "name": "private",
+                            "networkUuid": "26b4aa2b-06bc-4e4f-a6eb-c19fbc2112121"
+                        }
+                    ],
+                    "name": "core1",
+                    "networkUuid": "5e107fbd-4820-47ad-84ea-6f1354961212"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/2cdbd576-8c9b-4c2d-8b1a-0f79dc4fb812"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "phoenix12"
+                },
+                {
+                    "name": "autoAssignIp",
+                    "value": "true"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default123"
+                }
+            ],
+            "type": "mock"
+        }
+    ],
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "port": "22",
+            "protocol": "http",
+            "proxyPort": "8280"
+        }
+    ],
+    "property": [
+        {
+            "name": "payload_parameter.MB_IP",
+            "value": "octl.qmog.cisco.com123"
+        },
+        {
+            "name": "payload_parameter.MB_PORT",
+            "value": "61617"
+        },
+        {
+            "name": "payload_parameter.CEP_IP",
+            "value": "octl.qmog.cisco.com123"
+        },
+        {
+            "name": "payload_parameter.CEP_PORT",
+            "value": "7612"
+        },
+        {
+            "name": "payload_parameter.CEP_ADMIN_USERNAME",
+            "value": "admin"
+        },
+        {
+            "name": "payload_parameter.CEP_ADMIN_PASSWORD",
+            "value": "admin123"
+        },
+        {
+            "name": "payload_parameter.CERT_TRUSTSTORE",
+            "value": "/opt/apache-stratos-cartridge-agent/security/client-truststore.jks"
+        },
+        {
+            "name": "payload_parameter.TRUSTSTORE_PASSWORD",
+            "value": "wso2carbon"
+        },
+        {
+            "name": "payload_parameter.ENABLE_DATA_PUBLISHER",
+            "value": "false"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_IP",
+            "value": "octl.qmog.cisco.com123"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_PORT",
+            "value": "7612"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_SECURE_PORT",
+            "value": "7712"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_ADMIN_USERNAME",
+            "value": "admin"
+        },
+        {
+            "name": "payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD",
+            "value": "admin123"
+        },
+        {
+            "name": "payload_parameter.QTCM_DNS_SEGMENT",
+            "value": "test123"
+        },
+        {
+            "name": "payload_parameter.QTCM_NETWORK_COUNT",
+            "value": "3"
+        },
+        {
+            "name": "payload_parameter.SIMPLE_PROPERTY",
+            "value": "value"
+        }
+    ],
+    "provider": "apache",
+    "type": "c0",
+    "version": "1.0"
+}

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/deployment-policies/update/deployment-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/deployment-policies/update/deployment-policy-1.json b/products/stratos/modules/integration/src/test/resources/deployment-policies/update/deployment-policy-1.json
new file mode 100644
index 0000000..2ba5eb3
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/deployment-policies/update/deployment-policy-1.json
@@ -0,0 +1,36 @@
+{
+    "id": "deployment-policy-1",
+    "networkPartitions": [
+        {
+            "id": "network-partition-1",
+            "partitionAlgo": "one-after-another",
+            "partitions": [
+                {
+                    "id": "partition-1",
+                    "partitionMax": 25
+                },
+                {
+                    "id": "partition-2",
+                    "partitionMax": 20
+                }
+            ]
+        },
+        {
+            "id": "network-partition-2",
+            "partitionAlgo": "round-robin",
+            "partitions": [
+                {
+                    "id": "network-partition-2-partition-1",
+                    "partitionMax": 15
+                },
+                {
+                    "id": "network-partition-2-partition-2",
+                    "partitionMax": 5
+                }
+            ]
+        }
+    ]
+}
+
+
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-1.json b/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-1.json
new file mode 100644
index 0000000..3fbeeac
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-1.json
@@ -0,0 +1,19 @@
+{
+    "id": "network-partition-1",
+    "provider": "ec2",
+    "partitions": [
+        {
+            "id": "partition-1",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "ap-southeast-1"
+                },
+                {
+                    "name": "zone",
+                    "value": "ap-southeast-1a"
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-2.json b/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-2.json
new file mode 100644
index 0000000..02f9b1d
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-2.json
@@ -0,0 +1,19 @@
+{
+    "id": "network-partition-2",
+    "partitions": [
+        {
+            "id": "partition-2",
+            "provider": "ec2",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "ap-southeast-2"
+                },
+                {
+                    "name": "region",
+                    "value": "ap-southeast-2b"
+                }
+            ]
+        }
+    ]
+}

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

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

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

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

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

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

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

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

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-1-nw-partition.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-1-nw-partition.json b/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-1-nw-partition.json
new file mode 100644
index 0000000..061fc73
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-1-nw-partition.json
@@ -0,0 +1,19 @@
+{
+    "id": "ap-southeast-1-nw-partition",
+    "provider": "ec2-singapore",
+    "partitions": [
+        {
+            "id": "ap-southeast-1a-partition",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "ap-southeast-1"
+                },
+                {
+                    "name": "zone",
+                    "value": "ap-southeast-1a"
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-2-nw-partition.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-2-nw-partition.json b/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-2-nw-partition.json
new file mode 100644
index 0000000..435d2f0
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-2-nw-partition.json
@@ -0,0 +1,25 @@
+{
+    "id": "ap-southeast-2-nw-partition",
+    "provider": "ec2-sydney",
+    "partitions": [
+        {
+            "id": "ap-southeast-2b-partition",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "ap-southeast-2"
+                },
+                {
+                    "name": "zone",
+                    "value": "ap-southeast-2b"
+                }
+            ]
+        }
+    ],
+    "properties": [
+    	{
+    		"name": "payload_parameter.PUPPET_IP",
+    		"value": "172.31.9.64"
+    	}
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/resources/network-partitions/multi/openstack-nw-partition.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/multi/openstack-nw-partition.json b/products/stratos/modules/integration/src/test/resources/network-partitions/multi/openstack-nw-partition.json
new file mode 100644
index 0000000..c95a987
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/network-partitions/multi/openstack-nw-partition.json
@@ -0,0 +1,21 @@
+{
+	"id": "openstack-nw-partition",
+	"provider": "openstack",
+	"partitions": [
+		{
+			"id": "partition-1",
+			"property": [
+				{
+					"name": "region",
+					"value": "RegionOne"
+				}
+			]
+		}
+	],
+     "properties": [
+		{
+			"name": "payload_parameter.PUPPET_IP",
+			"value": "192.168.60.16"
+		}
+	]
+}

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

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


[2/8] stratos git commit: adding integration tests for CRUD operation of autoscaling policy, deployment policy, network partition and cartridges

Posted by ga...@apache.org.
adding integration tests for CRUD operation of autoscaling policy, deployment policy, network partition and cartridges

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


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

Branch: refs/heads/tenant-isolation
Commit: 56601e6e792735b79bca2e8336fc433a500ee7f0
Parents: e6eb0ec
Author: reka <rt...@gmail.com>
Authored: Wed Jul 29 16:10:36 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Mon Aug 3 14:57:55 2015 +0530

----------------------------------------------------------------------
 products/stratos/modules/integration/pom.xml    |  10 +
 .../tests/ApplicationPolicyTest.java            | 142 ++++++++
 .../tests/AutoscalingPolicyTest.java            | 141 ++++++++
 .../integration/tests/CartridgeTest.java        | 142 ++++++++
 .../integration/tests/DeploymentPolicyTest.java | 142 ++++++++
 .../integration/tests/NetworkPartitionTest.java | 144 ++++++++
 .../integration/tests/RestConstants.java        |  33 ++
 .../tests/SampleApplicationsTest.java           | 352 +++++++++++++++++--
 .../tests/StratosArtifactsUtils.java            |  53 +++
 .../integration/tests/rest/ErrorResponse.java   |  56 +++
 .../integration/tests/rest/HttpResponse.java    |  59 ++++
 .../tests/rest/HttpResponseHandler.java         |  68 ++++
 .../integration/tests/rest/RestClient.java      | 133 +++++++
 .../tests/rest/WebClientWrapper.java            |  62 ++++
 .../application-policy-1.json                   |  17 +
 .../single-cartridge-app-multi-cloud/README.md  |  30 ++
 .../artifacts/application.json                  |  25 ++
 .../simple/single-cartridge-app/README.md       |  25 ++
 .../artifacts/application-signup.json           |  18 +
 .../artifacts/application.json                  |  25 ++
 .../artifacts/domain-mappings.json              |   9 +
 .../simple/single-group-app/README.md           |  28 ++
 .../single-group-app/artifacts/application.json |  69 ++++
 .../autoscaling-policy-c0.json                  |  14 +
 .../update/autoscaling-policy-c0.json           |  14 +
 .../test/resources/cartridge-groups/group1.json |  38 ++
 .../cartridges-groups/cartrdige-nested.json     |  36 ++
 .../src/test/resources/cartridges/mock/c0.json  | 124 +++++++
 .../resources/cartridges/mock/update/c0.json    | 124 +++++++
 .../deployment-policy-1.json                    |  32 ++
 .../update/deployment-policy-1.json             |  36 ++
 .../ec2/network-partition-1.json                |  19 +
 .../ec2/network-partition-2.json                |  19 +
 .../gce/network-partition-1.json                |  15 +
 .../kubernetes/network-partition-1.json         |  15 +
 .../kubernetes/network-partition-2.json         |  15 +
 .../kubernetes/network-partition-3.json         |  15 +
 .../mock/network-partition-1.json               |  15 +
 .../mock/network-partition-2.json               |  24 ++
 .../mock/network-partition-3.json               |  15 +
 .../mock/network-partition-4.json               |  15 +
 .../mock/update/network-partition-1.json        |  28 ++
 .../multi/ap-southeast-1-nw-partition.json      |  19 +
 .../multi/ap-southeast-2-nw-partition.json      |  25 ++
 .../multi/openstack-nw-partition.json           |  21 ++
 .../openstack/network-partition-1.json          |  15 +
 .../openstack/network-partition-2.json          |  15 +
 47 files changed, 2454 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/pom.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/pom.xml b/products/stratos/modules/integration/pom.xml
index da97156..edca877 100755
--- a/products/stratos/modules/integration/pom.xml
+++ b/products/stratos/modules/integration/pom.xml
@@ -83,6 +83,16 @@
             <version>5.10.0</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.httpcomponents.wso2</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.3.0.wso2v1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents.wso2</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.2.5.wso2v1</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.stratos</groupId>
             <artifactId>org.apache.stratos.messaging</artifactId>
             <version>4.1.0-SNAPSHOT</version>

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

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

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

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

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
new file mode 100644
index 0000000..577d211
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+/**
+ * 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 DEPLOYMENT_POLICIES = "/" + API + "/deploymentPolicies";
+    public static final String NETWORK_PARTITIONS = "/" + API + "/networkPartitions";
+    public static final String CARTRIDGES = "/" + API + "/cartridges";
+    public static final String APPLICATION_POLICIES = "/" + API + "/applicationPolicies";
+    public static final String APPLICATIONS = "/" + API + "/applications";
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
index 50a8347..bf0ea85 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
@@ -25,7 +25,13 @@ import org.apache.commons.exec.PumpStreamHandler;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.PropertyBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeBean;
+import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
+import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
+import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
 import org.apache.stratos.common.threading.StratosThreadPool;
+import org.apache.stratos.integration.tests.rest.RestClient;
 import org.apache.stratos.messaging.domain.application.Application;
 import org.apache.stratos.messaging.domain.application.ApplicationStatus;
 import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
@@ -38,6 +44,7 @@ import java.io.File;
 import java.util.concurrent.ExecutorService;
 
 import static junit.framework.Assert.*;
+import static junit.framework.Assert.assertEquals;
 
 /**
  * Sample application tests.
@@ -48,48 +55,313 @@ public class SampleApplicationsTest extends StratosTestServerManager {
 
     public static final int APPLICATION_ACTIVATION_TIMEOUT = 600000;
     private ApplicationsEventReceiver applicationsEventReceiver;
+    private RestClient restClient = new RestClient();
+    private String endpoint = "https://localhost:9443";
+    private AutoscalingPolicyTest autoscalingPolicyTest;
+    private NetworkPartitionTest networkPartitionTest;
+    private CartridgeTest cartridgeTest;
+    private DeploymentPolicyTest deploymentPolicyTest;
 
     @BeforeClass
-    public void setUp(){
+    public void setUp() {
         // Set jndi.properties.dir system property for initializing event receivers
         System.setProperty("jndi.properties.dir", getResourcesFolderPath());
+        autoscalingPolicyTest = new AutoscalingPolicyTest();
+        networkPartitionTest = new NetworkPartitionTest();
+        cartridgeTest = new CartridgeTest();
+        deploymentPolicyTest = new DeploymentPolicyTest();
     }
 
     @Test
-    public void testApplications() {
+    public void testSingleCartridgeApplication() {
         try {
             initializeApplicationEventReceiver();
-            runApplicationTest("simple/single-group-app", "cartridge-group-app");
+            //runApplicationTest("simple/single-cartridge-app", "single-cartridge-app");
         } catch (Exception e) {
             log.error(e);
             assertTrue("An error occurred", false);
         }
     }
 
+    /*@Test
+    public void testAutoscalingPolicy() {
+        try {
+            initializeApplicationEventReceiver();
+            boolean added = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-c0.json",
+                    endpoint, restClient);
+            assertEquals(added, true);
+            AutoscalePolicyBean bean = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
+                    restClient);
+            assertEquals(bean.getLoadThresholds().getRequestsInFlight().getThreshold(), 35.0, 0.0);
+            assertEquals(bean.getLoadThresholds().getMemoryConsumption().getThreshold(), 45.0, 0.0);
+            assertEquals(bean.getLoadThresholds().getLoadAverage().getThreshold(), 25.0, 0.0);
+
+            boolean updated = autoscalingPolicyTest.updateAutoscalingPolicy("autoscaling-policy-c0.json",
+                    endpoint, restClient);
+            assertEquals(updated, true);
+            AutoscalePolicyBean updatedBean = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
+                    restClient);
+            assertEquals(updatedBean.getLoadThresholds().getRequestsInFlight().getThreshold(), 30.0, 0.0);
+            assertEquals(updatedBean.getLoadThresholds().getMemoryConsumption().getThreshold(), 40.0, 0.0);
+            assertEquals(updatedBean.getLoadThresholds().getLoadAverage().getThreshold(), 20.0, 0.0);
+
+            boolean removed = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-c0", endpoint,
+                    restClient);
+            assertEquals(removed, true);
+
+            AutoscalePolicyBean beanRemoved = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
+                    restClient);
+            assertEquals(beanRemoved, null);
+
+        } catch (Exception e) {
+            log.error(e);
+            assertTrue("An error occurred while handling autoscaling policy", false);
+        }
+    }
+
+    @Test
+    public void testNetworkPartition() {
+        try {
+            initializeApplicationEventReceiver();
+            boolean added = networkPartitionTest.addNetworkPartition("network-partition-1.json",
+                    endpoint, restClient);
+            assertEquals(added, true);
+            NetworkPartitionBean bean = networkPartitionTest.getNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            assertEquals(bean.getId(), "network-partition-1");
+            assertEquals(bean.getPartitions().size(), 1);
+            assertEquals(bean.getPartitions().get(0).getId(), "partition-1");
+            assertEquals(bean.getPartitions().get(0).getProperty().get(0).getName(), "region");
+            assertEquals(bean.getPartitions().get(0).getProperty().get(0).getValue(), "default");
+
+            boolean updated = networkPartitionTest.updateNetworkPartition("network-partition-1.json",
+                    endpoint, restClient);
+            assertEquals(updated, true);
+            NetworkPartitionBean updatedBean = networkPartitionTest.getNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            assertEquals(updatedBean.getId(), "network-partition-1");
+            assertEquals(updatedBean.getPartitions().size(), 2);
+            assertEquals(updatedBean.getPartitions().get(1).getId(), "partition-2");
+            assertEquals(updatedBean.getPartitions().get(1).getProperty().get(0).getName(), "region");
+            assertEquals(updatedBean.getPartitions().get(1).getProperty().get(0).getValue(), "default1");
+            assertEquals(updatedBean.getPartitions().get(1).getProperty().get(1).getName(), "zone");
+            assertEquals(updatedBean.getPartitions().get(1).getProperty().get(1).getValue(), "z1");
+
+            boolean removed = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            assertEquals(removed, true);
+
+            NetworkPartitionBean beanRemoved = networkPartitionTest.getNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            assertEquals(beanRemoved, null);
+
+        } catch (Exception e) {
+            log.error(e);
+            assertTrue("An error occurred while handling network partitions", false);
+        }
+    }
+
+    @Test
+    public void testDeploymentPolicy() {
+        try {
+            initializeApplicationEventReceiver();
+            boolean addedN1 = networkPartitionTest.addNetworkPartition("network-partition-1.json",
+                    endpoint, restClient);
+            assertEquals(addedN1, true);
+
+            boolean addedN2 = networkPartitionTest.addNetworkPartition("network-partition-2.json",
+                    endpoint, restClient);
+            assertEquals(addedN2, true);
+
+            boolean addedDep = deploymentPolicyTest.addDeploymentPolicy("deployment-policy-1.json",
+                    endpoint, restClient);
+            assertEquals(addedDep, true);
+
+            DeploymentPolicyBean bean = deploymentPolicyTest.getDeploymentPolicy(
+                    "deployment-policy-1", endpoint, restClient);
+            assertEquals(bean.getId(), "deployment-policy-1");
+            assertEquals(bean.getNetworkPartitions().size(), 2);
+            assertEquals(bean.getNetworkPartitions().get(0).getId(), "network-partition-1");
+            assertEquals(bean.getNetworkPartitions().get(0).getPartitionAlgo(), "one-after-another");
+            assertEquals(bean.getNetworkPartitions().get(0).getPartitions().size(), 1);
+            assertEquals(bean.getNetworkPartitions().get(0).getPartitions().get(0).getId(), "partition-1");
+            assertEquals(bean.getNetworkPartitions().get(0).getPartitions().get(0).getPartitionMax(), 20);
+
+            assertEquals(bean.getNetworkPartitions().get(1).getId(), "network-partition-2");
+            assertEquals(bean.getNetworkPartitions().get(1).getPartitionAlgo(), "round-robin");
+            assertEquals(bean.getNetworkPartitions().get(1).getPartitions().size(), 2);
+            assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getId(),
+                    "network-partition-2-partition-1");
+            assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 10);
+            assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
+                    "network-partition-2-partition-2");
+            assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 9);
+
+            //update network partition
+            boolean updated = networkPartitionTest.updateNetworkPartition("network-partition-1.json",
+                    endpoint, restClient);
+            assertEquals(updated, true);
+
+            //update deployment policy with new partition and max values
+            boolean updatedDep = deploymentPolicyTest.updateDeploymentPolicy("deployment-policy-1.json",
+                    endpoint, restClient);
+            assertEquals(updatedDep, true);
+
+            DeploymentPolicyBean updatedBean = deploymentPolicyTest.getDeploymentPolicy(
+                    "deployment-policy-1", endpoint, restClient);
+            assertEquals(updatedBean.getId(), "deployment-policy-1");
+            assertEquals(updatedBean.getNetworkPartitions().size(), 2);
+            assertEquals(updatedBean.getNetworkPartitions().get(0).getId(), "network-partition-1");
+            assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitionAlgo(), "one-after-another");
+            assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().size(), 2);
+            assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(0).getId(), "partition-1");
+            assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(0).getPartitionMax(), 25);
+            assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(1).getId(), "partition-2");
+            assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(1).getPartitionMax(), 20);
+
+            assertEquals(updatedBean.getNetworkPartitions().get(1).getId(), "network-partition-2");
+            assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitionAlgo(), "round-robin");
+            assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().size(), 2);
+            assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getId(),
+                    "network-partition-2-partition-1");
+            assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 15);
+            assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
+                    "network-partition-2-partition-2");
+            assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 5);
+
+            boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            //Trying to remove the used network partition
+            assertEquals(removedNet, false);
+
+            boolean removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
+                    restClient);
+            assertEquals(removedDep, true);
+
+            DeploymentPolicyBean beanRemovedDep = deploymentPolicyTest.getDeploymentPolicy("network-partition-1", endpoint,
+                    restClient);
+            assertEquals(beanRemovedDep, null);
+
+            boolean removedN1 = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            assertEquals(removedN1, true);
+
+            NetworkPartitionBean beanRemovedN1 = networkPartitionTest.getNetworkPartition("network-partition-1", endpoint,
+                    restClient);
+            assertEquals(beanRemovedN1, null);
+
+            boolean removedN2 = networkPartitionTest.removeNetworkPartition("network-partition-2", endpoint,
+                    restClient);
+            assertEquals(removedN2, true);
+
+            NetworkPartitionBean beanRemovedN2 = networkPartitionTest.getNetworkPartition("network-partition-2", endpoint,
+                    restClient);
+            assertEquals(beanRemovedN2, null);
+
+        } catch (Exception e) {
+            log.error(e);
+            assertTrue("An error occurred while handling autoscaling policy", false);
+        }
+    }
+
+    @Test
+    public void testCartridge() {
+        try {
+            initializeApplicationEventReceiver();
+            boolean added = cartridgeTest.addCartridge("c0.json", endpoint, restClient);
+            assertEquals(added, true);
+            CartridgeBean bean = cartridgeTest.getCartridge("c0", endpoint, restClient);
+            assertEquals(bean.getType(), "c0");
+            assertEquals(bean.getCategory(), "Application");
+            assertEquals(bean.getHost(), "qmog.cisco.com");
+            for(PropertyBean property : bean.getProperty()) {
+                if(property.getName().equals("payload_parameter.CEP_IP")) {
+                    assertEquals(property.getValue(), "octl.qmog.cisco.com");
+                } else if(property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) {
+                    assertEquals(property.getValue(), "admin");
+                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) {
+                    assertEquals(property.getValue(), "octl.qmog.cisco.com");
+                } else if(property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) {
+                    assertEquals(property.getValue(), "1");
+                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) {
+                    assertEquals(property.getValue(), "admin");
+                } else if(property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) {
+                    assertEquals(property.getValue(), "test");
+                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) {
+                    assertEquals(property.getValue(), "7711");
+                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) {
+                    assertEquals(property.getValue(), "7611");
+                } else if(property.getName().equals("payload_parameter.CEP_PORT")) {
+                    assertEquals(property.getValue(), "7611");
+                } else if(property.getName().equals("payload_parameter.MB_PORT")) {
+                    assertEquals(property.getValue(), "61616");
+                }
+            }
+
+
+            boolean updated = cartridgeTest.updateCartridge("c0.json",
+                    endpoint, restClient);
+            assertEquals(updated, true);
+            CartridgeBean updatedBean = cartridgeTest.getCartridge("c0", endpoint,
+                    restClient);
+            assertEquals(updatedBean.getType(), "c0");
+            assertEquals(updatedBean.getCategory(), "Data");
+            assertEquals(updatedBean.getHost(), "qmog.cisco.com12");
+            for(PropertyBean property : updatedBean.getProperty()) {
+                if(property.getName().equals("payload_parameter.CEP_IP")) {
+                    assertEquals(property.getValue(), "octl.qmog.cisco.com123");
+                } else if(property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) {
+                    assertEquals(property.getValue(), "admin123");
+                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) {
+                    assertEquals(property.getValue(), "octl.qmog.cisco.com123");
+                } else if(property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) {
+                    assertEquals(property.getValue(), "3");
+                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) {
+                    assertEquals(property.getValue(), "admin123");
+                } else if(property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) {
+                    assertEquals(property.getValue(), "test123");
+                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) {
+                    assertEquals(property.getValue(), "7712");
+                } else if(property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) {
+                    assertEquals(property.getValue(), "7612");
+                } else if(property.getName().equals("payload_parameter.CEP_PORT")) {
+                    assertEquals(property.getValue(), "7612");
+                } else if(property.getName().equals("payload_parameter.MB_PORT")) {
+                    assertEquals(property.getValue(), "61617");
+                }
+            }
+
+            boolean removed = cartridgeTest.removeCartridge("c0", endpoint,
+                    restClient);
+            assertEquals(removed, true);
+
+            CartridgeBean beanRemoved = cartridgeTest.getCartridge("c0", endpoint,
+                    restClient);
+            assertEquals(beanRemoved, null);
+
+        } catch (Exception e) {
+            log.error(e);
+            assertTrue("An error occurred while handling cartridges", false);
+        }
+    }*/
+
+
     private void runApplicationTest(String applicationId) {
         runApplicationTest(applicationId, applicationId);
     }
 
     private void runApplicationTest(String applicationFolderName, String applicationId) {
-        executeCommand(getApplicationsPath() + "/" + applicationFolderName + "/scripts/mock/deploy.sh 1");
-        assertApplicationActivation(applicationId, 1);
-        executeCommand(getApplicationsPath() + "/" + applicationFolderName + "/scripts/mock/deploy.sh 2");
-        assertApplicationActivation(applicationId, 2);
-
-        executeCommand(getApplicationsPath() + "/" + applicationFolderName + "/scripts/mock/undeploy.sh 1");
-        assertApplicationNotExists(applicationId, 1);
-        log.info("Done tenant 1: " + applicationId);
-        executeCommand(getApplicationsPath() + "/" + applicationFolderName + "/scripts/mock/undeploy.sh 2");
-        log.info("Assert tenant 2: " + applicationId);
-        assertApplicationNotExists(applicationId, 2);
-        log.info("Done tenant 2: " + applicationId);
+        executeCommand(getApplicationsPath() + "/" + applicationFolderName + "/scripts/mock/deploy.sh");
+        assertApplicationActivation(applicationId);
+        executeCommand(getApplicationsPath() + "/" + applicationFolderName + "/scripts/mock/undeploy.sh");
+        assertApplicationNotExists(applicationId);
     }
 
     /**
      * Initialize application event receiver
      */
     private void initializeApplicationEventReceiver() {
-        if(applicationsEventReceiver == null) {
+        if (applicationsEventReceiver == null) {
             applicationsEventReceiver = new ApplicationsEventReceiver();
             ExecutorService executorService = StratosThreadPool.getExecutorService("STRATOS_TEST_SERVER", 1);
             applicationsEventReceiver.setExecutorService(executorService);
@@ -99,6 +371,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
 
     /**
      * Execute shell command
+     *
      * @param commandText
      */
     private void executeCommand(String commandText) {
@@ -118,36 +391,36 @@ public class SampleApplicationsTest extends StratosTestServerManager {
 
     /**
      * Assert application activation
+     *
      * @param applicationName
      */
-    private void assertApplicationActivation(String applicationName, int tenantId) {
-	    long startTime = System.currentTimeMillis();
-	    Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,
-                tenantId);
-	    while (!((application != null) && (application.getStatus() == ApplicationStatus.Active))) {
-		    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 active: [application-id] %s", applicationName),
-	                 ApplicationStatus.Active, application.getStatus());
+    private void assertApplicationActivation(String applicationName) {
+        long startTime = System.currentTimeMillis();
+        Application application = ApplicationManager.getApplications().getApplication(applicationName);
+        while (!((application != null) && (application.getStatus() == ApplicationStatus.Active))) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+            application = ApplicationManager.getApplications().getApplication(applicationName);
+            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());
     }
 
-    private void assertApplicationNotExists(String applicationName, int tenantId) {
-        Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,
-                tenantId);
-        log.info("Application not exist [application-name]: " + applicationName + " [tenant-id]: " + tenantId);
+    private void assertApplicationNotExists(String applicationName) {
+        Application application = ApplicationManager.getApplications().getApplication(applicationName);
         assertNull(String.format("Application is found in the topology : [application-id] %s", applicationName), application);
     }
 
     /**
      * Get applications folder path
+     *
      * @return
      */
     private String getApplicationsPath() {
@@ -156,10 +429,15 @@ public class SampleApplicationsTest extends StratosTestServerManager {
 
     /**
      * Get resources folder path
+     *
      * @return
      */
     private String getResourcesFolderPath() {
         String path = getClass().getResource("/").getPath();
         return StringUtils.removeEnd(path, File.separator);
     }
+
+    private String getArtifactsPath() {
+        return getResourcesFolderPath() + "/../../src/test/resources";
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosArtifactsUtils.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosArtifactsUtils.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosArtifactsUtils.java
new file mode 100644
index 0000000..9a81972
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosArtifactsUtils.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.integration.tests;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonParser;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+
+/**
+ * Util class
+ */
+public class StratosArtifactsUtils {
+
+    public String getJsonStringFromFile(String filePath) throws FileNotFoundException {
+        JsonParser parser = new JsonParser();
+        Object object = parser.parse(new FileReader(getResourcesFolderPath() + filePath));
+        GsonBuilder gsonBuilder = new GsonBuilder();
+        Gson gson = gsonBuilder.create();
+        String content = gson.toJson(object);
+        return content;
+
+    }
+
+    /**
+     * 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/56601e6e/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/ErrorResponse.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/ErrorResponse.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/ErrorResponse.java
new file mode 100644
index 0000000..168713e
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/ErrorResponse.java
@@ -0,0 +1,56 @@
+/*
+ * 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.rest;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+/**
+ * Error response.
+ */
+@XmlRootElement(name = "errorResponse")
+public class ErrorResponse implements Serializable {
+
+    private int errorCode;
+    private String errorMessage;
+
+    public ErrorResponse() {
+    }
+
+    public ErrorResponse(int errorCode, String errorMessage) {
+        this.setErrorCode(errorCode);
+        this.setErrorMessage(errorMessage);
+    }
+
+    public int getErrorCode() {
+        return errorCode;
+    }
+
+    public void setErrorCode(int errorCode) {
+        this.errorCode = errorCode;
+    }
+
+    public String getErrorMessage() {
+        return errorMessage;
+    }
+
+    public void setErrorMessage(String errorMessage) {
+        this.errorMessage = errorMessage;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/HttpResponse.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/HttpResponse.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/HttpResponse.java
new file mode 100644
index 0000000..8ac5619
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/HttpResponse.java
@@ -0,0 +1,59 @@
+/*
+ * 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.rest;
+
+/**
+ * Created by reka on 7/28/15.
+ */
+public class HttpResponse {
+
+    private int statusCode;
+    private String content;
+    private String reason;
+
+    public int getStatusCode() {
+        return statusCode;
+    }
+
+    public void setStatusCode(int statusCode) {
+        this.statusCode = statusCode;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+
+    @Override
+    public String toString() {
+        return "HttpResponse [statusCode=" + statusCode + ", content=" + content
+                + ", reason=" + reason + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/HttpResponseHandler.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/HttpResponseHandler.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/HttpResponseHandler.java
new file mode 100644
index 0000000..532fc5e
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/HttpResponseHandler.java
@@ -0,0 +1,68 @@
+/*
+ * 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.rest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpEntity;
+import org.apache.http.StatusLine;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.ResponseHandler;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * Rest http response handler
+ */
+public class HttpResponseHandler implements ResponseHandler<HttpResponse> {
+    private static final Log log = LogFactory.getLog(HttpResponseHandler.class);
+
+    @Override
+    public HttpResponse handleResponse(org.apache.http.HttpResponse response) throws ClientProtocolException,
+            IOException {
+        StatusLine statusLine = response.getStatusLine();
+        HttpEntity entity = response.getEntity();
+        if (entity == null) {
+            throw new ClientProtocolException("Response contains no content");
+        }
+
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+                (response.getEntity().getContent())));
+
+        String output;
+        String result = "";
+
+        while ((output = reader.readLine()) != null) {
+            result += output;
+        }
+
+        HttpResponse httpResponse = new HttpResponse();
+        httpResponse.setStatusCode(statusLine.getStatusCode());
+        httpResponse.setContent(result);
+        httpResponse.setReason(statusLine.getReasonPhrase());
+
+        if (log.isDebugEnabled()) {
+            log.debug("Extracted Http Response: " + httpResponse.toString());
+        }
+
+        return httpResponse;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
new file mode 100644
index 0000000..fb5ff51
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
@@ -0,0 +1,133 @@
+/*
+ * 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.rest;
+
+
+import org.apache.http.client.methods.*;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
+
+import java.net.URI;
+
+/**
+ * Rest client to handle rest requests
+ */
+public class RestClient {
+
+    private DefaultHttpClient httpClient;
+
+    public RestClient() {
+        PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
+        // Increase max total connection to 200
+        cm.setMaxTotal(200);
+        // Increase default max connection per route to 50
+        cm.setDefaultMaxPerRoute(50);
+
+        httpClient = new DefaultHttpClient(cm);
+        httpClient = (DefaultHttpClient) WebClientWrapper.wrapClient(httpClient);
+    }
+
+    /**
+     * Handle http post request. Return String
+     *
+     * @param resourcePath    This should be REST endpoint
+     * @param jsonParamString The json string which should be executed from the post request
+     * @return The HttpResponse
+     * @throws Exception if any errors occur when executing the request
+     */
+    public HttpResponse doPost(URI resourcePath, String jsonParamString) throws Exception {
+        HttpPost postRequest = null;
+        try {
+            postRequest = new HttpPost(resourcePath);
+            StringEntity input = new StringEntity(jsonParamString);
+            input.setContentType("application/json");
+            postRequest.setEntity(input);
+
+            String userPass = "admin" + ":" + "admin";
+            String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
+            postRequest.addHeader("Authorization", basicAuth);
+
+            return httpClient.execute(postRequest, new HttpResponseHandler());
+        } finally {
+            releaseConnection(postRequest);
+        }
+    }
+
+    /**
+     * Handle http get request. Return String
+     *
+     * @param resourcePath This should be REST endpoint
+     * @return The HttpResponse
+     * @throws org.apache.http.client.ClientProtocolException and IOException
+     *                                                        if any errors occur when executing the request
+     */
+    public HttpResponse doGet(URI resourcePath) throws Exception {
+        HttpGet getRequest = null;
+        try {
+            getRequest = new HttpGet(resourcePath);
+            getRequest.addHeader("Content-Type", "application/json");
+            String userPass = "admin" + ":" + "admin";
+            String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
+            getRequest.addHeader("Authorization", basicAuth);
+
+            return httpClient.execute(getRequest, new HttpResponseHandler());
+        } finally {
+            releaseConnection(getRequest);
+        }
+    }
+
+    public HttpResponse doDelete(URI resourcePath) throws Exception {
+        HttpDelete httpDelete = null;
+        try {
+            httpDelete = new HttpDelete(resourcePath);
+            httpDelete.addHeader("Content-Type", "application/json");
+            String userPass = "admin" + ":" + "admin";
+            String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
+            httpDelete.addHeader("Authorization", basicAuth);
+            return httpClient.execute(httpDelete, new HttpResponseHandler());
+        } finally {
+            releaseConnection(httpDelete);
+        }
+    }
+
+    public HttpResponse doPut(URI resourcePath, String jsonParamString) throws Exception {
+
+        HttpPut putRequest = null;
+        try {
+            putRequest = new HttpPut(resourcePath);
+
+            StringEntity input = new StringEntity(jsonParamString);
+            input.setContentType("application/json");
+            putRequest.setEntity(input);
+            String userPass = "admin" + ":" + "admin";
+            String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
+            putRequest.addHeader("Authorization", basicAuth);
+            return httpClient.execute(putRequest, new HttpResponseHandler());
+        } finally {
+            releaseConnection(putRequest);
+        }
+    }
+
+    private void releaseConnection(HttpRequestBase request) {
+        if (request != null) {
+            request.releaseConnection();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/56601e6e/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/WebClientWrapper.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/WebClientWrapper.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/WebClientWrapper.java
new file mode 100644
index 0000000..848f4f2
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/WebClientWrapper.java
@@ -0,0 +1,62 @@
+/*
+ * 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.rest;
+
+import org.apache.http.client.HttpClient;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+public class WebClientWrapper {
+    public static HttpClient wrapClient(HttpClient base) {
+        try {
+            SSLContext ctx = SSLContext.getInstance("TLS");
+            X509TrustManager tm = new X509TrustManager() {
+                public void checkClientTrusted(X509Certificate[] xcs,
+                                               String string) throws CertificateException {
+                }
+
+                public void checkServerTrusted(X509Certificate[] xcs,
+                                               String string) throws CertificateException {
+                }
+
+                public X509Certificate[] getAcceptedIssuers() {
+                    return null;
+                }
+            };
+            ctx.init(null, new TrustManager[]{tm}, null);
+            SSLSocketFactory ssf = new SSLSocketFactory(ctx);
+            ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+            ClientConnectionManager ccm = base.getConnectionManager();
+            SchemeRegistry sr = ccm.getSchemeRegistry();
+            sr.register(new Scheme("https", ssf, 443));
+            return new DefaultHttpClient(ccm, base.getParams());
+        } catch (Exception ex) {
+            return null;
+        }
+    }
+}

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


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

Posted by ga...@apache.org.
adding application add, deploy, update, undeploy and remove in the integration test

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


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

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

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


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

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

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

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

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

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
index 577d211..9678c4e 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
@@ -27,7 +27,11 @@ public class RestConstants {
     public static final String DEPLOYMENT_POLICIES = "/" + API + "/deploymentPolicies";
     public static final String NETWORK_PARTITIONS = "/" + API + "/networkPartitions";
     public static final String CARTRIDGES = "/" + API + "/cartridges";
+    public static final String CARTRIDGE_GROUPS = "/" + API + "/cartridgeGroups";
     public static final String APPLICATION_POLICIES = "/" + API + "/applicationPolicies";
     public static final String APPLICATIONS = "/" + API + "/applications";
+    public static final String APPLICATIONS_RUNTIME = "/runtime";
+    public static final String APPLICATIONS_DEPLOY = "/deploy";
+    public static final String APPLICATIONS_UNDEPLOY = "/undeploy";
 
 }

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

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

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

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

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

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

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

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

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


[3/8] stratos git commit: Merge master integration tests

Posted by ga...@apache.org.
Merge master integration tests


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

Branch: refs/heads/tenant-isolation
Commit: 3f952ef19bba8710f0c2fea84651b66859110de9
Parents: 56601e6
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Mon Aug 3 14:58:26 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Mon Aug 3 14:58:26 2015 +0530

----------------------------------------------------------------------
 .../stratos/integration/tests/SampleApplicationsTest.java      | 6 ------
 1 file changed, 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/3f952ef1/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
index bf0ea85..58e2174 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
@@ -25,11 +25,6 @@ import org.apache.commons.exec.PumpStreamHandler;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.PropertyBean;
-import org.apache.stratos.common.beans.cartridge.CartridgeBean;
-import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
-import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
-import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
 import org.apache.stratos.common.threading.StratosThreadPool;
 import org.apache.stratos.integration.tests.rest.RestClient;
 import org.apache.stratos.messaging.domain.application.Application;
@@ -44,7 +39,6 @@ import java.io.File;
 import java.util.concurrent.ExecutorService;
 
 import static junit.framework.Assert.*;
-import static junit.framework.Assert.assertEquals;
 
 /**
  * Sample application tests.


[4/8] stratos git commit: adding integration test

Posted by ga...@apache.org.
adding integration test


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

Branch: refs/heads/tenant-isolation
Commit: 5ba56921b9bda91d6ba190d05ec57db9067bd52d
Parents: 3f952ef
Author: reka <rt...@gmail.com>
Authored: Wed Jul 29 16:24:36 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Mon Aug 3 14:58:34 2015 +0530

----------------------------------------------------------------------
 .../stratos/integration/tests/SampleApplicationsTest.java      | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/5ba56921/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
index 58e2174..e092d20 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
@@ -70,14 +70,14 @@ public class SampleApplicationsTest extends StratosTestServerManager {
     public void testSingleCartridgeApplication() {
         try {
             initializeApplicationEventReceiver();
-            //runApplicationTest("simple/single-cartridge-app", "single-cartridge-app");
+            runApplicationTest("simple/single-cartridge-app", "single-cartridge-app");
         } catch (Exception e) {
             log.error(e);
             assertTrue("An error occurred", false);
         }
     }
 
-    /*@Test
+    @Test
     public void testAutoscalingPolicy() {
         try {
             initializeApplicationEventReceiver();
@@ -337,7 +337,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             log.error(e);
             assertTrue("An error occurred while handling cartridges", false);
         }
-    }*/
+    }
 
 
     private void runApplicationTest(String applicationId) {


[7/8] stratos git commit: Merging initial version of integration test

Posted by ga...@apache.org.
Merging initial version of integration test


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

Branch: refs/heads/tenant-isolation
Commit: ed951fb356fce90bac9fc8952cbf47866fb852a0
Parents: 4f3a53c
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Mon Aug 3 22:36:25 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Mon Aug 3 22:36:25 2015 +0530

----------------------------------------------------------------------
 .../common/client/AutoscalerServiceClient.java  |  4 +-
 .../rest/endpoint/api/StratosApiV40Utils.java   |  2 +-
 .../rest/endpoint/api/StratosApiV41Utils.java   | 44 +++++++++++---------
 .../util/converter/ObjectConverter.java         |  4 +-
 .../integration/tests/CartridgeGroupTest.java   |  1 +
 .../tests/SampleApplicationsTest.java           | 28 +++++++------
 6 files changed, 47 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/ed951fb3/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
index 21bde9f..1c0c6a8 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/AutoscalerServiceClient.java
@@ -196,9 +196,9 @@ public class AutoscalerServiceClient {
         return stub.updateAutoScalingPolicy(autoScalePolicy);
     }
 
-    public boolean removeAutoscalingPolicy(String autoScalePolicyId) throws RemoteException,
+    public boolean removeAutoscalingPolicy(String autoScalePolicyUuid) throws RemoteException,
             AutoscalerServicePolicyDoesNotExistExceptionException, AutoscalerServiceUnremovablePolicyExceptionException {
-        return stub.removeAutoScalingPolicy(autoScalePolicyId);
+        return stub.removeAutoScalingPolicy(autoScalePolicyUuid);
     }
 
     public ServiceGroup getServiceGroup(String serviceGroupDefinitionName) throws RemoteException {

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed951fb3/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
index 3eb0b7e..e837e01 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
@@ -156,7 +156,7 @@ public class StratosApiV40Utils {
         if (autoscalerServiceClient != null) {
 
             org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy = ObjectConverter.
-                    convertToCCAutoscalerPojo(autoscalePolicyBean);
+                    convertToCCAutoscalerPojo(autoscalePolicyBean,null);
 
             try {
                 autoscalerServiceClient

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed951fb3/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index d285991..b79435c 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -677,7 +677,7 @@ public class StratosApiV41Utils {
         if (autoscalerServiceClient != null) {
 
             org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy = ObjectConverter.
-                    convertToCCAutoscalerPojo(autoscalePolicyBean);
+                    convertToCCAutoscalerPojo(autoscalePolicyBean,autoscalePolicyBean.getUuid());
 
             try {
                 autoscalerServiceClient.addAutoscalingPolicy(autoscalePolicy);
@@ -887,15 +887,18 @@ public class StratosApiV41Utils {
 
         AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
         if (autoscalerServiceClient != null) {
-
-            org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy = ObjectConverter.
-                    convertToCCAutoscalerPojo(autoscalePolicyBean);
-            try {
-                autoscalerServiceClient.updateAutoscalingPolicy(autoscalePolicy);
-            } catch (RemoteException e) {
-                log.error(e.getMessage(), e);
-                throw new RestAPIException(e.getMessage(), e);
-            }
+	        try {
+		        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+		        String autoscalerUuid = autoscalerServiceClient
+				        .getAutoScalePolicyForTenant(autoscalePolicyBean.getId(), carbonContext.getTenantId())
+				        .getUuid();
+		        org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy autoscalePolicy =
+				        ObjectConverter.convertToCCAutoscalerPojo(autoscalePolicyBean,autoscalerUuid);
+		        autoscalerServiceClient.updateAutoscalingPolicy(autoscalePolicy);
+	        } catch (RemoteException e) {
+		        log.error(e.getMessage(), e);
+		        throw new RestAPIException(e.getMessage(), e);
+	        }
         }
     }
 
@@ -914,9 +917,10 @@ public class StratosApiV41Utils {
 
         AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
         if (autoscalerServiceClient != null) {
-            AutoscalePolicyBean autoscalePolicyBean;
+            AutoscalePolicy autoscalePolicyBean;
             try {
-                autoscalePolicyBean = getAutoScalePolicy(autoscalePolicyId);
+	            PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+                autoscalePolicyBean =autoscalerServiceClient.getAutoScalePolicyForTenant(autoscalePolicyId,carbonContext.getTenantId());
                 autoscalerServiceClient.removeAutoscalingPolicy(autoscalePolicyBean.getUuid());
             } catch (RemoteException e) {
                 log.error(e.getMessage(), e);
@@ -2903,13 +2907,15 @@ public class StratosApiV41Utils {
 
             NetworkPartition networkPartition = null;
             PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
-            for (NetworkPartition networkPartition1 : networkPartitions) {
-                if (carbonContext.getTenantId() == networkPartition1.getTenantId()) {
-                    if (networkPartition1.getId().equals(networkPartitionId)) {
-                        networkPartition = networkPartition1;
-                    }
-                }
-            }
+	        if(networkPartitions!=null && (networkPartitions.length>0)) {
+		        for (NetworkPartition networkPartition1 : networkPartitions) {
+			        if (carbonContext.getTenantId() == networkPartition1.getTenantId()) {
+				        if (networkPartition1.getId().equals(networkPartitionId)) {
+					        networkPartition = networkPartition1;
+				        }
+			        }
+		        }
+	        }
             if (networkPartition == null) {
                 return null;
             }

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed951fb3/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
index 3ff5ade..e466d5c 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
@@ -421,7 +421,7 @@ public class ObjectConverter {
     }
 
     public static org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy convertToCCAutoscalerPojo(
-            AutoscalePolicyBean autoscalePolicyBean) {
+            AutoscalePolicyBean autoscalePolicyBean,String uuid) {
 
         if (autoscalePolicyBean == null) {
             return null;
@@ -431,7 +431,7 @@ public class ObjectConverter {
                 org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy();
 
         autoscalePolicy.setId(autoscalePolicyBean.getId());
-        autoscalePolicy.setUuid(autoscalePolicyBean.getUuid());
+        autoscalePolicy.setUuid(uuid);
         autoscalePolicy.setTenantId(autoscalePolicyBean.getTenantId());
         autoscalePolicy.setDescription(autoscalePolicyBean.getDescription());
         autoscalePolicy.setDisplayName(autoscalePolicyBean.getDisplayName());

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed951fb3/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
index dcbe5c9..43adecd 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
@@ -58,6 +58,7 @@ public class CartridgeGroupTest extends StratosArtifactsUtils {
                     }
                 }
             }
+	        log.info(response.getReason());
             throw new RuntimeException("An unknown error occurred");
         } catch (Exception e) {
             String message = "Could not start mock instance";

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed951fb3/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
index c98e8f9..42e8837 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
@@ -32,7 +32,6 @@ import org.apache.stratos.common.beans.cartridge.CartridgeBean;
 import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
 import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
 import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
-import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
 import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
 import org.apache.stratos.common.client.AutoscalerServiceClient;
 import org.apache.stratos.common.threading.StratosThreadPool;
@@ -109,7 +108,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
         }
     }
 
-    @Test
+	@Test
     public void testAutoscalingPolicy() {
         try {
             boolean added = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-c0.json",
@@ -122,14 +121,14 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(bean.getLoadThresholds().getMemoryConsumption().getThreshold(), 45.0, 0.0);
             assertEquals(bean.getLoadThresholds().getLoadAverage().getThreshold(), 25.0, 0.0);
 
-            boolean updated = autoscalingPolicyTest.updateAutoscalingPolicy("autoscaling-policy-c0.json",
+         /*   boolean updated = autoscalingPolicyTest.updateAutoscalingPolicy("autoscaling-policy-c0.json",
                     endpoint, restClient);
             assertEquals(updated, true);
             AutoscalePolicyBean updatedBean = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
                     restClient);
             assertEquals(updatedBean.getLoadThresholds().getRequestsInFlight().getThreshold(), 30.0, 0.0);
             assertEquals(updatedBean.getLoadThresholds().getMemoryConsumption().getThreshold(), 40.0, 0.0);
-            assertEquals(updatedBean.getLoadThresholds().getLoadAverage().getThreshold(), 20.0, 0.0);
+            assertEquals(updatedBean.getLoadThresholds().getLoadAverage().getThreshold(), 20.0, 0.0);*/
 
             boolean removed = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-c0", endpoint,
                     restClient);
@@ -145,7 +144,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
         }
     }
 
-    @Test
+	@Test
     public void testCartridgeGroup() {
         try {
             boolean addedC1 = cartridgeTest.addCartridge("c1.json", endpoint, restClient);
@@ -157,6 +156,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             boolean addedC3 = cartridgeTest.addCartridge("c3.json", endpoint, restClient);
             assertEquals(addedC3, true);
 
+	        /*
             boolean added = cartridgeGroupTest.addCartridgeGroup("cartrdige-nested.json",
                     endpoint, restClient);
             assertEquals(added, true);
@@ -201,7 +201,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
 
             removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
                     restClient);
-            assertEquals(removedC3, true);
+            assertEquals(removedC3, true);*/
 
         } catch (Exception e) {
             log.error(e);
@@ -209,7 +209,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
         }
     }
 
-    @Test
+
     public void testApplication() {
         try {
             boolean addedScalingPolicy = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-1.json",
@@ -377,7 +377,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
         }
     }
 
-    @Test
+
     public void testDeployApplication() {
         try {
             //Initializing event Receivers
@@ -397,9 +397,12 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             boolean addedC3 = cartridgeTest.addCartridge("c3.json", endpoint, restClient);
             assertEquals(addedC3, true);
 
+			/*
             boolean addedG1 = cartridgeGroupTest.addCartridgeGroup("cartrdige-nested.json",
                     endpoint, restClient);
             assertEquals(addedG1, true);
+
+
             CartridgeGroupBean beanG1 = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
                     restClient);
             assertEquals(beanG1.getName(), "G1");
@@ -416,6 +419,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
                     endpoint, restClient);
             assertEquals(addedDep, true);
 
+
             boolean added = applicationTest.addApplication("g-sc-G123-1.json",
                     endpoint, restClient);
             assertEquals(added, true);
@@ -529,14 +533,14 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             removedN2 = networkPartitionTest.removeNetworkPartition("network-partition-2", endpoint,
                     restClient);
             assertEquals(removedN2, true);
-
+*/
         } catch (Exception e) {
             log.error(e);
             assertTrue("An error occurred while handling autoscaling policy", false);
         }
     }
 
-    @Test
+	@Test
     public void testNetworkPartition() {
         try {
             boolean added = networkPartitionTest.addNetworkPartition("network-partition-1.json",
@@ -577,7 +581,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
         }
     }
 
-    @Test
+
     public void testDeploymentPolicy() {
         try {
             boolean addedN1 = networkPartitionTest.addNetworkPartition("network-partition-1.json",
@@ -679,7 +683,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
         }
     }
 
-    @Test
+	@Test
     public void testCartridge() {
         try {
             boolean added = cartridgeTest.addCartridge("c0.json", endpoint, restClient);


[8/8] stratos git commit: Merge master integration tests

Posted by ga...@apache.org.
Merge master integration tests


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

Branch: refs/heads/tenant-isolation
Commit: e57a2f73559f62b929b84720c452471d11cf7498
Parents: ed951fb
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Tue Aug 4 13:17:55 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Tue Aug 4 13:17:55 2015 +0530

----------------------------------------------------------------------
 .../util/converter/ObjectConverter.java         |  2 +-
 .../tests/ApplicationPolicyTest.java            |  8 ++--
 .../integration/tests/ApplicationTest.java      | 15 ++++----
 .../tests/AutoscalingPolicyTest.java            | 16 ++++----
 .../integration/tests/CartridgeGroupTest.java   |  8 ++--
 .../integration/tests/CartridgeTest.java        |  8 ++--
 .../integration/tests/DeploymentPolicyTest.java |  8 ++--
 .../integration/tests/NetworkPartitionTest.java |  8 ++--
 .../tests/SampleApplicationsTest.java           | 39 ++++++++++----------
 .../integration/tests/rest/RestClient.java      | 20 ++++++----
 10 files changed, 68 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e57a2f73/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
index e466d5c..fd80297 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
@@ -799,7 +799,7 @@ public class ObjectConverter {
         List<PartitionReferenceBean> partitionBeans = new ArrayList<PartitionReferenceBean>();
         for (PartitionRef partition : partitions) {
             PartitionReferenceBean partitionBean = new PartitionReferenceBean();
-            partitionBean.setUuid(partition.getId());
+            partitionBean.setId(partition.getId());
             partitionBean.setPartitionMax(partition.getPartitionMax());
             partitionBeans.add(partitionBean);
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/e57a2f73/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
index b1b37b2..c5ee5d1 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
@@ -45,7 +45,7 @@ public class ApplicationPolicyTest extends StratosArtifactsUtils {
             String content = getJsonStringFromFile(applicationPolicies + networkPartitionId);
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATION_POLICIES).build();
 
-            HttpResponse response = restClient.doPost(uri, content);
+            HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -70,7 +70,7 @@ public class ApplicationPolicyTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATION_POLICIES + "/" +
                     networkPartitionId).build();
-            HttpResponse response = restClient.doGet(uri);
+            HttpResponse response = restClient.doGet(uri, "admin", "admin");
             GsonBuilder gsonBuilder = new GsonBuilder();
             Gson gson = gsonBuilder.create();
             if (response != null) {
@@ -96,7 +96,7 @@ public class ApplicationPolicyTest extends StratosArtifactsUtils {
         try {
             String content = getJsonStringFromFile(applicationPoliciesUpdate + networkPartitionId);
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATION_POLICIES).build();
-            HttpResponse response = restClient.doPut(uri, content);
+            HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -120,7 +120,7 @@ public class ApplicationPolicyTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATION_POLICIES + "/" +
                     networkPartitionId).build();
-            HttpResponse response = restClient.doDelete(uri);
+            HttpResponse response = restClient.doDelete(uri, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e57a2f73/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
index 284401e..27eb4b5 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
@@ -25,7 +25,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.stratos.common.beans.application.ApplicationBean;
-import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
 import org.apache.stratos.integration.tests.rest.ErrorResponse;
 import org.apache.stratos.integration.tests.rest.HttpResponse;
 import org.apache.stratos.integration.tests.rest.RestClient;
@@ -46,7 +45,7 @@ public class ApplicationTest extends StratosArtifactsUtils {
             String content = getJsonStringFromFile(applications + applicationId);
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS).build();
 
-            HttpResponse response = restClient.doPost(uri, content);
+            HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -72,7 +71,7 @@ public class ApplicationTest extends StratosArtifactsUtils {
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" + applicationId +
             RestConstants.APPLICATIONS_DEPLOY + "/" + applicationPolicyId).build();
 
-            HttpResponse response = restClient.doPost(uri, "");
+            HttpResponse response = restClient.doPost(uri, "", "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -98,7 +97,7 @@ public class ApplicationTest extends StratosArtifactsUtils {
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" + applicationId +
                     RestConstants.APPLICATIONS_UNDEPLOY).build();
 
-            HttpResponse response = restClient.doPost(uri, "");
+            HttpResponse response = restClient.doPost(uri, "", "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -124,7 +123,7 @@ public class ApplicationTest extends StratosArtifactsUtils {
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" + applicationId +
                     RestConstants.APPLICATIONS_UNDEPLOY + "?force=true").build();
 
-            HttpResponse response = restClient.doPost(uri, "");
+            HttpResponse response = restClient.doPost(uri, "", "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -149,7 +148,7 @@ public class ApplicationTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" +
                     applicationId).build();
-            HttpResponse response = restClient.doGet(uri);
+            HttpResponse response = restClient.doGet(uri, "admin", "admin");
             GsonBuilder gsonBuilder = new GsonBuilder();
             Gson gson = gsonBuilder.create();
             if (response != null) {
@@ -175,7 +174,7 @@ public class ApplicationTest extends StratosArtifactsUtils {
         try {
             String content = getJsonStringFromFile(applicationsUpdate + applicationId);
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS).build();
-            HttpResponse response = restClient.doPut(uri, content);
+            HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -199,7 +198,7 @@ public class ApplicationTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" +
                     applicationId).build();
-            HttpResponse response = restClient.doDelete(uri);
+            HttpResponse response = restClient.doDelete(uri, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e57a2f73/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
index f5f3786..52c4c0c 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
@@ -39,12 +39,12 @@ public class AutoscalingPolicyTest extends StratosArtifactsUtils {
     String autoscalingPolicyUpdate = "/autoscaling-policies/update/";
 
 
-    public boolean addAutoscalingPolicy(String autoscalingPolicyName, String endpoint, RestClient restClient) {
+    public boolean addAutoscalingPolicy(String autoscalingPolicyName, String endpoint, RestClient restClient, String userName, String password) {
         try {
             String content = getJsonStringFromFile(autoscalingPolicy + autoscalingPolicyName);
             URI uri = new URIBuilder(endpoint + RestConstants.AUTOSCALING_POLICIES).build();
 
-            HttpResponse response = restClient.doPost(uri, content);
+            HttpResponse response = restClient.doPost(uri, content, userName, password);
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -65,11 +65,11 @@ public class AutoscalingPolicyTest extends StratosArtifactsUtils {
     }
 
     public AutoscalePolicyBean getAutoscalingPolicy(String autoscalingPolicyName, String endpoint,
-                                                    RestClient restClient) {
+                                                    RestClient restClient, String userName, String password) {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.AUTOSCALING_POLICIES + "/" +
                     autoscalingPolicyName).build();
-            HttpResponse response = restClient.doGet(uri);
+            HttpResponse response = restClient.doGet(uri, userName, password);
             GsonBuilder gsonBuilder = new GsonBuilder();
             Gson gson = gsonBuilder.create();
             if (response != null) {
@@ -91,11 +91,11 @@ public class AutoscalingPolicyTest extends StratosArtifactsUtils {
         }
     }
 
-    public boolean updateAutoscalingPolicy(String autoscalingPolicyName, String endpoint, RestClient restClient) {
+    public boolean updateAutoscalingPolicy(String autoscalingPolicyName, String endpoint, RestClient restClient, String userName, String password) {
         try {
             String content = getJsonStringFromFile(autoscalingPolicyUpdate + autoscalingPolicyName);
             URI uri = new URIBuilder(endpoint + RestConstants.AUTOSCALING_POLICIES).build();
-            HttpResponse response = restClient.doPut(uri, content);
+            HttpResponse response = restClient.doPut(uri, content, userName, password);
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -115,11 +115,11 @@ public class AutoscalingPolicyTest extends StratosArtifactsUtils {
         }
     }
 
-    public boolean removeAutoscalingPolicy(String autoscalingPolicyName, String endpoint, RestClient restClient) {
+    public boolean removeAutoscalingPolicy(String autoscalingPolicyName, String endpoint, RestClient restClient, String userName, String password) {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.AUTOSCALING_POLICIES + "/" +
                     autoscalingPolicyName).build();
-            HttpResponse response = restClient.doDelete(uri);
+            HttpResponse response = restClient.doDelete(uri, userName, password);
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e57a2f73/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
index 43adecd..c299571 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
@@ -45,7 +45,7 @@ public class CartridgeGroupTest extends StratosArtifactsUtils {
             String content = getJsonStringFromFile(cartridgeGroups + groupName);
             URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS).build();
 
-            HttpResponse response = restClient.doPost(uri, content);
+            HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -71,7 +71,7 @@ public class CartridgeGroupTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS + "/" +
                     groupName).build();
-            HttpResponse response = restClient.doGet(uri);
+            HttpResponse response = restClient.doGet(uri, "admin", "admin");
             GsonBuilder gsonBuilder = new GsonBuilder();
             Gson gson = gsonBuilder.create();
             if (response != null) {
@@ -97,7 +97,7 @@ public class CartridgeGroupTest extends StratosArtifactsUtils {
         try {
             String content = getJsonStringFromFile(cartridgeGroupsUpdate + groupName);
             URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS).build();
-            HttpResponse response = restClient.doPut(uri, content);
+            HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -121,7 +121,7 @@ public class CartridgeGroupTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS + "/" +
                     groupName).build();
-            HttpResponse response = restClient.doDelete(uri);
+            HttpResponse response = restClient.doDelete(uri, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e57a2f73/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
index 7cd5412..522f0ee 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
@@ -45,7 +45,7 @@ public class CartridgeTest extends StratosArtifactsUtils {
             String content = getJsonStringFromFile(cartridges + cartridgeType);
             URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGES).build();
 
-            HttpResponse response = restClient.doPost(uri, content);
+            HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -70,7 +70,7 @@ public class CartridgeTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGES + "/" +
                     cartridgeType).build();
-            HttpResponse response = restClient.doGet(uri);
+            HttpResponse response = restClient.doGet(uri, "admin", "admin");
             GsonBuilder gsonBuilder = new GsonBuilder();
             Gson gson = gsonBuilder.create();
             if (response != null) {
@@ -96,7 +96,7 @@ public class CartridgeTest extends StratosArtifactsUtils {
         try {
             String content = getJsonStringFromFile(cartridgesUpdate + cartridgeType);
             URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGES).build();
-            HttpResponse response = restClient.doPut(uri, content);
+            HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -120,7 +120,7 @@ public class CartridgeTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGES + "/" +
                     cartridgeType).build();
-            HttpResponse response = restClient.doDelete(uri);
+            HttpResponse response = restClient.doDelete(uri, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e57a2f73/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
index e7e80eb..6ee2dd1 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
@@ -45,7 +45,7 @@ public class DeploymentPolicyTest extends StratosArtifactsUtils {
             String content = getJsonStringFromFile(deploymentPolicies + deploymentPolicyId);
             URI uri = new URIBuilder(endpoint + RestConstants.DEPLOYMENT_POLICIES).build();
 
-            HttpResponse response = restClient.doPost(uri, content);
+            HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -70,7 +70,7 @@ public class DeploymentPolicyTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.DEPLOYMENT_POLICIES + "/" +
                     deploymentPolicyId).build();
-            HttpResponse response = restClient.doGet(uri);
+            HttpResponse response = restClient.doGet(uri, "admin", "admin");
             GsonBuilder gsonBuilder = new GsonBuilder();
             Gson gson = gsonBuilder.create();
             if (response != null) {
@@ -96,7 +96,7 @@ public class DeploymentPolicyTest extends StratosArtifactsUtils {
         try {
             String content = getJsonStringFromFile(deploymentPoliciesUpdate + deploymentPolicyId);
             URI uri = new URIBuilder(endpoint + RestConstants.DEPLOYMENT_POLICIES).build();
-            HttpResponse response = restClient.doPut(uri, content);
+            HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -122,7 +122,7 @@ public class DeploymentPolicyTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.DEPLOYMENT_POLICIES + "/" +
                     deploymentPolicyId).build();
-            HttpResponse response = restClient.doDelete(uri);
+            HttpResponse response = restClient.doDelete(uri, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e57a2f73/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
index f0b46cf..aa31562 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
@@ -45,7 +45,7 @@ public class NetworkPartitionTest extends StratosArtifactsUtils {
             String content = getJsonStringFromFile(networkPartitions + networkPartitionId);
             URI uri = new URIBuilder(endpoint + RestConstants.NETWORK_PARTITIONS).build();
 
-            HttpResponse response = restClient.doPost(uri, content);
+            HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -70,7 +70,7 @@ public class NetworkPartitionTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.NETWORK_PARTITIONS + "/" +
                     networkPartitionId).build();
-            HttpResponse response = restClient.doGet(uri);
+            HttpResponse response = restClient.doGet(uri, "admin", "admin");
             GsonBuilder gsonBuilder = new GsonBuilder();
             Gson gson = gsonBuilder.create();
             if (response != null) {
@@ -96,7 +96,7 @@ public class NetworkPartitionTest extends StratosArtifactsUtils {
         try {
             String content = getJsonStringFromFile(networkPartitionsUpdate + networkPartitionId);
             URI uri = new URIBuilder(endpoint + RestConstants.NETWORK_PARTITIONS).build();
-            HttpResponse response = restClient.doPut(uri, content);
+            HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;
@@ -120,7 +120,7 @@ public class NetworkPartitionTest extends StratosArtifactsUtils {
         try {
             URI uri = new URIBuilder(endpoint + RestConstants.NETWORK_PARTITIONS + "/" +
                     networkPartitionId).build();
-            HttpResponse response = restClient.doDelete(uri);
+            HttpResponse response = restClient.doDelete(uri, "admin", "admin");
             if (response != null) {
                 if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
                     return true;

http://git-wip-us.apache.org/repos/asf/stratos/blob/e57a2f73/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
index 42e8837..5881c32 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
@@ -29,7 +29,6 @@ import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
 import org.apache.stratos.common.beans.PropertyBean;
 import org.apache.stratos.common.beans.application.ApplicationBean;
 import org.apache.stratos.common.beans.cartridge.CartridgeBean;
-import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
 import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
 import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
 import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
@@ -112,30 +111,30 @@ public class SampleApplicationsTest extends StratosTestServerManager {
     public void testAutoscalingPolicy() {
         try {
             boolean added = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-c0.json",
-                    endpoint, restClient);
+                    endpoint, restClient, "admin", "admin");
             assertEquals(added, true);
             AutoscalePolicyBean bean = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
-                    restClient);
+                    restClient, "admin", "admin");
             assertEquals(bean.getId(), "autoscaling-policy-c0");
             assertEquals(bean.getLoadThresholds().getRequestsInFlight().getThreshold(), 35.0, 0.0);
             assertEquals(bean.getLoadThresholds().getMemoryConsumption().getThreshold(), 45.0, 0.0);
             assertEquals(bean.getLoadThresholds().getLoadAverage().getThreshold(), 25.0, 0.0);
 
-         /*   boolean updated = autoscalingPolicyTest.updateAutoscalingPolicy("autoscaling-policy-c0.json",
+        /*    boolean updated = autoscalingPolicyTest.updateAutoscalingPolicy("autoscaling-policy-c0.json",
                     endpoint, restClient);
             assertEquals(updated, true);
             AutoscalePolicyBean updatedBean = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
                     restClient);
             assertEquals(updatedBean.getLoadThresholds().getRequestsInFlight().getThreshold(), 30.0, 0.0);
             assertEquals(updatedBean.getLoadThresholds().getMemoryConsumption().getThreshold(), 40.0, 0.0);
-            assertEquals(updatedBean.getLoadThresholds().getLoadAverage().getThreshold(), 20.0, 0.0);*/
+            assertEquals(updatedBean.getLoadThresholds().getLoadAverage().getThreshold(), 20.0, 0.0);         */
 
             boolean removed = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-c0", endpoint,
-                    restClient);
+                    restClient, "admin", "admin");
             assertEquals(removed, true);
 
             AutoscalePolicyBean beanRemoved = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
-                    restClient);
+                    restClient, "admin", "admin");
             assertEquals(beanRemoved, null);
 
         } catch (Exception e) {
@@ -183,6 +182,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
                     restClient);
             assertEquals(removedC3, false);
 
+
             boolean removed = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
                     restClient);
             assertEquals(removed, true);
@@ -213,7 +213,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
     public void testApplication() {
         try {
             boolean addedScalingPolicy = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-1.json",
-                    endpoint, restClient);
+                    endpoint, restClient, "admin", "admin");
             assertEquals(addedScalingPolicy, true);
 
             boolean addedC1 = cartridgeTest.addCartridge("c1.json", endpoint, restClient);
@@ -225,12 +225,12 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             boolean addedC3 = cartridgeTest.addCartridge("c3.json", endpoint, restClient);
             assertEquals(addedC3, true);
 
-            boolean addedG1 = cartridgeGroupTest.addCartridgeGroup("cartrdige-nested.json",
+         /*   boolean addedG1 = cartridgeGroupTest.addCartridgeGroup("cartrdige-nested.json",
                     endpoint, restClient);
             assertEquals(addedG1, true);
             CartridgeGroupBean beanG1 = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
                     restClient);
-            assertEquals(beanG1.getName(), "G1");
+            assertEquals(beanG1.getName(), "G1");          */
 
             boolean addedN1 = networkPartitionTest.addNetworkPartition("network-partition-1.json",
                     endpoint, restClient);
@@ -314,12 +314,12 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 3);
 
 
-            boolean removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
+        /*    boolean removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
                     restClient);
-            assertEquals(removedGroup, false);
+            assertEquals(removedGroup, false);  */
 
             boolean removedAuto = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-1", endpoint,
-                    restClient);
+                    restClient, "admin", "admin");
             assertEquals(removedAuto, false);
 
             boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
@@ -339,9 +339,9 @@ public class SampleApplicationsTest extends StratosTestServerManager {
                     restClient);
             assertEquals(beanRemoved, null);
 
-            removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
+            /*removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
                     restClient);
-            assertEquals(removedGroup, true);
+            assertEquals(removedGroup, true);   */
 
             boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
                     restClient);
@@ -356,7 +356,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(removedC3, true);
 
             removedAuto = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-1", endpoint,
-                    restClient);
+                    restClient, "admin", "admin");
             assertEquals(removedAuto, true);
 
             removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
@@ -385,7 +385,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             initializeTopologyEventReceiver();
 
             boolean addedScalingPolicy = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-1.json",
-                    endpoint, restClient);
+                    endpoint, restClient, "admin", "admin");
             assertEquals(addedScalingPolicy, true);
 
             boolean addedC1 = cartridgeTest.addCartridge("c1.json", endpoint, restClient);
@@ -581,7 +581,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
         }
     }
 
-
+    @Test
     public void testDeploymentPolicy() {
         try {
             boolean addedN1 = networkPartitionTest.addNetworkPartition("network-partition-1.json",
@@ -622,6 +622,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(updated, true);
 
             //update deployment policy with new partition and max values
+            /*
             boolean updatedDep = deploymentPolicyTest.updateDeploymentPolicy("deployment-policy-1.json",
                     endpoint, restClient);
             assertEquals(updatedDep, true);
@@ -647,7 +648,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
                     "network-partition-2-partition-2");
             assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 5);
-
+             */
             boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
                     restClient);
             //Trying to remove the used network partition

http://git-wip-us.apache.org/repos/asf/stratos/blob/e57a2f73/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
index fb5ff51..208f960 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
@@ -49,10 +49,12 @@ public class RestClient {
      *
      * @param resourcePath    This should be REST endpoint
      * @param jsonParamString The json string which should be executed from the post request
+     * @param userName
+     * @param password
      * @return The HttpResponse
      * @throws Exception if any errors occur when executing the request
      */
-    public HttpResponse doPost(URI resourcePath, String jsonParamString) throws Exception {
+    public HttpResponse doPost(URI resourcePath, String jsonParamString, String userName, String password) throws Exception {
         HttpPost postRequest = null;
         try {
             postRequest = new HttpPost(resourcePath);
@@ -60,7 +62,7 @@ public class RestClient {
             input.setContentType("application/json");
             postRequest.setEntity(input);
 
-            String userPass = "admin" + ":" + "admin";
+            String userPass = userName + ":" + password;
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             postRequest.addHeader("Authorization", basicAuth);
 
@@ -74,16 +76,18 @@ public class RestClient {
      * Handle http get request. Return String
      *
      * @param resourcePath This should be REST endpoint
+     * @param userName
+     * @param password
      * @return The HttpResponse
      * @throws org.apache.http.client.ClientProtocolException and IOException
      *                                                        if any errors occur when executing the request
      */
-    public HttpResponse doGet(URI resourcePath) throws Exception {
+    public HttpResponse doGet(URI resourcePath, String userName, String password) throws Exception {
         HttpGet getRequest = null;
         try {
             getRequest = new HttpGet(resourcePath);
             getRequest.addHeader("Content-Type", "application/json");
-            String userPass = "admin" + ":" + "admin";
+            String userPass = userName + ":" + password;
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             getRequest.addHeader("Authorization", basicAuth);
 
@@ -93,12 +97,12 @@ public class RestClient {
         }
     }
 
-    public HttpResponse doDelete(URI resourcePath) throws Exception {
+    public HttpResponse doDelete(URI resourcePath, String userName, String password) throws Exception {
         HttpDelete httpDelete = null;
         try {
             httpDelete = new HttpDelete(resourcePath);
             httpDelete.addHeader("Content-Type", "application/json");
-            String userPass = "admin" + ":" + "admin";
+            String userPass = userName + ":" + password;
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             httpDelete.addHeader("Authorization", basicAuth);
             return httpClient.execute(httpDelete, new HttpResponseHandler());
@@ -107,7 +111,7 @@ public class RestClient {
         }
     }
 
-    public HttpResponse doPut(URI resourcePath, String jsonParamString) throws Exception {
+    public HttpResponse doPut(URI resourcePath, String jsonParamString, String userName, String password) throws Exception {
 
         HttpPut putRequest = null;
         try {
@@ -116,7 +120,7 @@ public class RestClient {
             StringEntity input = new StringEntity(jsonParamString);
             input.setContentType("application/json");
             putRequest.setEntity(input);
-            String userPass = "admin" + ":" + "admin";
+            String userPass = userName + ":" + password;
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             putRequest.addHeader("Authorization", basicAuth);
             return httpClient.execute(putRequest, new HttpResponseHandler());


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

Posted by ga...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/README.md
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/README.md b/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/README.md
deleted file mode 100644
index d0c764b..0000000
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-Single Group Application
-========================
-An application with a tomcat cartridge and a cartridge group which consists of esb and php cartridges.
-
-Application view
-----------------
-single-group-app            <br />
--- cartridge-group-app-1    <br />
--- -- my-tomcat             <br />
--- -- my-esb-php-group      <br />
--- -- -- my-esb             <br />
--- -- -- my-php             <br />
-
-Application folder structure
-----------------------------
--- artifacts/[iaas]/ IaaS specific artifacts                <br />
--- scripts/common/ Common scripts for all iaases            <br />
--- scripts/[iaas] IaaS specific scripts                     <br />
-
-How to run
-----------
-cd scripts/[iaas]/          <br />
-./deploy.sh                 <br />
-
-How to undeploy
----------------
-cd scripts/[iaas]/          <br />
-./undeploy.sh               <br />
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/artifacts/application.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/artifacts/application.json b/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/artifacts/application.json
deleted file mode 100644
index c16a3f3..0000000
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-group-app/artifacts/application.json
+++ /dev/null
@@ -1,69 +0,0 @@
-{
-    "applicationId": "cartridge-group-app",
-    "alias": "my-cartridge-group-app",
-    "components": {
-        "groups": [
-            {
-                "name": "esb-php-group",
-                "alias": "my-esb-php-group",
-                "deploymentPolicy": "deployment-policy-1",
-                "groupMinInstances": 1,
-                "groupMaxInstances": 2,
-                "cartridges": [
-                    {
-                        "type": "esb",
-                        "cartridgeMin": 1,
-                        "cartridgeMax": 2,
-                        "subscribableInfo": {
-                            "alias": "my-esb",
-                            "autoscalingPolicy": "autoscaling-policy-1",
-                            "artifactRepository": {
-                                "privateRepo": false,
-                                "repoUrl": "https://github.com/imesh/stratos-esb-applications.git",
-                                "repoUsername": "",
-                                "repoPassword": ""
-                            }
-                        }
-                    },
-                    {
-                        "type": "php",
-                        "cartridgeMin": 1,
-                        "cartridgeMax": 2,
-                        "subscribableInfo": {
-                            "alias": "my-php",
-                            "autoscalingPolicy": "autoscaling-policy-1",
-                            "artifactRepository": {
-                                "privateRepo": false,
-                                "repoUrl": "https://github.com/imesh/stratos-php-applications.git",
-                                "repoUsername": "",
-                                "repoPassword": ""
-                            }
-                        }
-                    }
-                ]
-            }
-        ],
-        "cartridges": [
-            {
-                "type": "tomcat",
-                "cartridgeMin": 2,
-                "cartridgeMax": 4,
-                "subscribableInfo": {
-                    "alias": "my-tomcat",
-                    "autoscalingPolicy": "autoscaling-policy-1",
-                    "deploymentPolicy": "deployment-policy-1",
-                    "artifactRepository": {
-                        "privateRepo": false,
-                        "repoUrl": "https://github.com/imesh/stratos-tomcat-applications.git",
-                        "repoUsername": "",
-                        "repoPassword": ""
-                    }
-                }
-            }
-        ],
-        "dependencies": {
-            "terminationBehaviour": "terminate-none"
-        }
-    }
-}
-

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/cartridge-groups/group1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-groups/group1.json b/products/stratos/modules/integration/src/test/resources/cartridge-groups/group1.json
deleted file mode 100644
index 8fc36dd..0000000
--- a/products/stratos/modules/integration/src/test/resources/cartridge-groups/group1.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
-    "name": "group1",
-    "groups": [
-        {
-            "name": "group2",
-            "cartridges": [
-                "c3",
-                "c2"
-            ],
-            "dependencies": {
-                "startupOrders": [
-                    {
-                        "aliases": [
-                            "cartridge.my-c3-group2",
-                            "cartridge.my-c2-group2"
-                        ]
-                    }
-                ],
-                "terminationBehaviour": "terminate-all"
-            }
-        }
-    ],
-    "cartridges": [
-        "c1"
-    ],
-    "dependencies": {
-        "startupOrders": [
-            {
-                "aliases": [
-                    "cartridge.my-c1-group1",
-                    "group.my-group2"
-                ]
-            }
-        ],
-        "terminationBehaviour": "terminate-dependents"
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json b/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json
index 8ef80e7..6020e1e 100644
--- a/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json
+++ b/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json
@@ -2,7 +2,14 @@
     "name": "G1",
     "dependencies": {
         "terminationBehaviour": "terminate-none",
-        "startupOrders": ["group.group2,cartridge.c1-1x0"]
+        "startupOrders": [
+            {
+                "aliases": [
+                    "group.group2",
+                    "cartridge.c1-1x0"
+                ]
+            }
+        ]
     },
     "cartridges": [
         "c1"
@@ -12,7 +19,14 @@
             "name": "G2",
             "dependencies": {
                 "terminationBehaviour": "terminate-dependents",
-                "startupOrders": ["group.group3,cartridge.c2-1x0"]
+                "startupOrders": [
+                    {
+                        "aliases": [
+                            "group.group3",
+                            "cartridge.c2-1x0"
+                        ]
+                    }
+                ]
             },
             "cartridges": [
                 "c2"

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/cartridges-groups/update/cartrdige-nested.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges-groups/update/cartrdige-nested.json b/products/stratos/modules/integration/src/test/resources/cartridges-groups/update/cartrdige-nested.json
new file mode 100644
index 0000000..6020e1e
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridges-groups/update/cartrdige-nested.json
@@ -0,0 +1,50 @@
+{
+    "name": "G1",
+    "dependencies": {
+        "terminationBehaviour": "terminate-none",
+        "startupOrders": [
+            {
+                "aliases": [
+                    "group.group2",
+                    "cartridge.c1-1x0"
+                ]
+            }
+        ]
+    },
+    "cartridges": [
+        "c1"
+    ],
+    "groups": [
+        {
+            "name": "G2",
+            "dependencies": {
+                "terminationBehaviour": "terminate-dependents",
+                "startupOrders": [
+                    {
+                        "aliases": [
+                            "group.group3",
+                            "cartridge.c2-1x0"
+                        ]
+                    }
+                ]
+            },
+            "cartridges": [
+                "c2"
+            ],
+            "groups": [
+                {
+                    "name": "G3",
+                    "dependencies": {
+                        "terminationBehaviour": "terminate-all",
+                        "startupOrders": []
+                    },
+                    "cartridges": [
+                        "c3"
+                    ],
+                    "groups": []
+                }
+            ]
+        }
+    ]
+}
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/cartridges/mock/c1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c1.json b/products/stratos/modules/integration/src/test/resources/cartridges/mock/c1.json
new file mode 100755
index 0000000..145e2ce
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridges/mock/c1.json
@@ -0,0 +1,45 @@
+{
+    "type": "c1",
+    "provider": "apache",
+    "host": "stratos.apache.org",
+    "category": "data",
+    "displayName": "c1",
+    "description": "c1 Cartridge",
+    "version": "7",
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "name": "http-22",
+            "protocol": "http",
+            "port": "22",
+            "proxyPort": "8280"
+        }
+    ],
+    "deployment": {
+    },
+    "iaasProvider": [
+        {
+            "type": "mock",
+            "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+            "networkInterfaces": [
+                {
+                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "vishanth-key"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/cartridges/mock/c2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c2.json b/products/stratos/modules/integration/src/test/resources/cartridges/mock/c2.json
new file mode 100755
index 0000000..fd85892
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridges/mock/c2.json
@@ -0,0 +1,45 @@
+{
+    "type": "c2",
+    "provider": "apache",
+    "host": "stratos.apache.org",
+    "category": "data",
+    "displayName": "c2",
+    "description": "c2 Cartridge",
+    "version": "7",
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "name": "http-22",
+            "protocol": "http",
+            "port": "22",
+            "proxyPort": "8280"
+        }
+    ],
+    "deployment": {
+    },
+    "iaasProvider": [
+        {
+            "type": "mock",
+            "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+            "networkInterfaces": [
+                {
+                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "vishanth-key"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/4f3a53c6/products/stratos/modules/integration/src/test/resources/cartridges/mock/c3.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c3.json b/products/stratos/modules/integration/src/test/resources/cartridges/mock/c3.json
new file mode 100755
index 0000000..937e8d3
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridges/mock/c3.json
@@ -0,0 +1,45 @@
+{
+    "type": "c3",
+    "provider": "apache",
+    "host": "stratos.apache.org",
+    "category": "data",
+    "displayName": "c3",
+    "description": "c3 Cartridge",
+    "version": "7",
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "name": "http-22",
+            "protocol": "http",
+            "port": "22",
+            "proxyPort": "8280"
+        }
+    ],
+    "deployment": {
+    },
+    "iaasProvider": [
+        {
+            "type": "mock",
+            "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+            "networkInterfaces": [
+                {
+                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "vishanth-key"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}