You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2015/08/12 13:32:43 UTC
[20/50] [abbrv] stratos git commit: Re-organizing the package
structure
http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
new file mode 100644
index 0000000..9d13ca4
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
@@ -0,0 +1,157 @@
+/*
+ * 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.policies;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
+import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.testng.annotations.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Test to handle Deployment policy CRUD operations
+ */
+public class DeploymentPolicyTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(DeploymentPolicyTest.class);
+ private static final String TEST_PATH = "/deployment-policy-test";
+
+
+ @Test
+ public void testDeploymentPolicy() {
+ try {
+ String deploymentPolicyId = "deployment-policy-2";
+ log.info("Started deployment policy test case**************************************");
+
+ boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-5" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN1, true);
+
+ boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-6" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN2, true);
+
+ boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+ deploymentPolicyId + ".json",
+ RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(addedDep, true);
+
+ DeploymentPolicyBean bean = (DeploymentPolicyBean) restClient.
+ getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(bean.getId(), "deployment-policy-2");
+ assertEquals(bean.getNetworkPartitions().size(), 2);
+ assertEquals(bean.getNetworkPartitions().get(0).getId(), "network-partition-5");
+ 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-6");
+ 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-6-partition-1");
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 10);
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
+ "network-partition-6-partition-2");
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 9);
+
+ //update network partition
+ boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-5-v1.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(updated, true);
+
+ //update deployment policy with new partition and max values
+ boolean updatedDep = restClient.updateEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH +
+ "/" + deploymentPolicyId + "-v1.json", RestConstants.DEPLOYMENT_POLICIES,
+ RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(updatedDep, true);
+
+ DeploymentPolicyBean updatedBean = (DeploymentPolicyBean) restClient.
+ getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(updatedBean.getId(), "deployment-policy-2");
+ assertEquals(updatedBean.getNetworkPartitions().size(), 2);
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getId(), "network-partition-5");
+ 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-6");
+ 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-6-partition-1");
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 15);
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
+ "network-partition-6-partition-2");
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 5);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-5", RestConstants.NETWORK_PARTITIONS_NAME);
+ //Trying to remove the used network partition
+ assertEquals(removedNet, false);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, true);
+
+ DeploymentPolicyBean beanRemovedDep = (DeploymentPolicyBean) restClient.
+ getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(beanRemovedDep, null);
+
+ boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-5", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN1, true);
+
+ NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-5",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(beanRemovedN1, null);
+
+ boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-6", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, true);
+
+ NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-6",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(beanRemovedN2, null);
+
+ log.info("Ended deployment policy test case**************************************");
+
+ } catch (Exception e) {
+ log.error("An error occurred while handling deployment policy", e);
+ assertTrue("An error occurred while handling deployment policy", false);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
new file mode 100644
index 0000000..5df2313
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.policies;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.testng.annotations.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Test to handle Network partition CRUD operations
+ */
+public class NetworkPartitionTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(NetworkPartitionTest.class);
+ private static final String TEST_PATH = "/network-partition-test";
+
+
+ @Test
+ public void testNetworkPartition() {
+ try {
+ String networkPartitionId = "network-partition-3";
+ log.info("Started network partition test case**************************************");
+
+ boolean added = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ networkPartitionId + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+
+ assertEquals(added, true);
+ NetworkPartitionBean bean = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+
+ assertEquals(bean.getId(), "network-partition-3");
+ 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 = restClient.updateEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ networkPartitionId + "-v1.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+
+ assertEquals(updated, true);
+ NetworkPartitionBean updatedBean = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(updatedBean.getId(), "network-partition-3");
+ 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 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ networkPartitionId, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removed, true);
+
+ NetworkPartitionBean beanRemoved = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(beanRemoved, null);
+
+ log.info("Ended network partition test case**************************************");
+ } catch (Exception e) {
+ log.error("An error occurred while handling network partitions", e);
+ assertTrue("An error occurred while handling network partitions", false);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/resources/testng.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/testng.xml b/products/stratos/modules/integration/src/test/resources/testng.xml
index 849a282..356b5ec 100644
--- a/products/stratos/modules/integration/src/test/resources/testng.xml
+++ b/products/stratos/modules/integration/src/test/resources/testng.xml
@@ -24,42 +24,42 @@
<test name="CartridgeTest">
<classes>
- <class name="org.apache.stratos.integration.tests.CartridgeTest" />
+ <class name="org.apache.stratos.integration.tests.group.CartridgeTest" />
</classes>
</test>
<test name="CartridgeGroupTest">
<classes>
- <class name="org.apache.stratos.integration.tests.CartridgeGroupTest" />
+ <class name="org.apache.stratos.integration.tests.group.CartridgeGroupTest" />
</classes>
</test>
<test name="NetworkPartitionTest">
<classes>
- <class name="org.apache.stratos.integration.tests.NetworkPartitionTest" />
+ <class name="org.apache.stratos.integration.tests.policies.NetworkPartitionTest" />
</classes>
</test>
<test name="ApplicationPolicyTest">
<classes>
- <class name="org.apache.stratos.integration.tests.ApplicationPolicyTest" />
+ <class name="org.apache.stratos.integration.tests.policies.ApplicationPolicyTest" />
</classes>
</test>
<test name="DeploymentPolicyTest">
<classes>
- <class name="org.apache.stratos.integration.tests.DeploymentPolicyTest" />
+ <class name="org.apache.stratos.integration.tests.policies.DeploymentPolicyTest" />
</classes>
</test>
<test name="AutoscalingPolicyTest">
<classes>
- <class name="org.apache.stratos.integration.tests.AutoscalingPolicyTest" />
+ <class name="org.apache.stratos.integration.tests.policies.AutoscalingPolicyTest" />
</classes>
</test>
<test name="SampleApplicationsTest">
<classes>
- <class name="org.apache.stratos.integration.tests.SampleApplicationsTest" />
+ <class name="org.apache.stratos.integration.tests.application.SampleApplicationsTest" />
</classes>
</test>
<test name="ApplicationBurstingTest">
<classes>
- <class name="org.apache.stratos.integration.tests.ApplicationBurstingTest" />
+ <class name="org.apache.stratos.integration.tests.application.ApplicationBurstingTest" />
</classes>
</test>