You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/09/20 08:31:33 UTC
[09/17] stratos git commit: Refactoring integration test cases
according to guidelines, throwing all exceptions
http://git-wip-us.apache.org/repos/asf/stratos/blob/1803972c/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
deleted file mode 100644
index cf4e995..0000000
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.integration.tests.group;
-
-import com.google.gson.reflect.TypeToken;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
-import org.apache.stratos.integration.common.RestConstants;
-import org.apache.stratos.integration.tests.StratosIntegrationTest;
-import org.testng.annotations.Test;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.AssertJUnit.*;
-
-/**
- * Test to handle Cartridge group CRUD operations
- */
-public class CartridgeGroupTest extends StratosIntegrationTest {
- private static final Log log = LogFactory.getLog(CartridgeGroupTest.class);
- private static final String RESOURCES_PATH = "/cartridge-group-test";
-
- @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.deployment", "smoke"})
- public void testCartridgeGroup() {
- try {
- log.info("-------------------------Started Cartridge group test case-------------------------");
-
- boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
- "/" + "c4-cartridge-group-test.json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
- "c4-cartridge-group-test"), addedC1);
-
- boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
- "/" + "c5-cartridge-group-test.json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
- "c5-cartridge-group-test"), addedC2);
-
- boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
- "/" + "c6-cartridge-group-test.json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
- "c6-cartridge-group-test"), addedC3);
-
- boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
- "/" + "g4-g5-g6-cartridge-group-test.json", RestConstants.CARTRIDGE_GROUPS,
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
- "g4-g5-g6-cartridge-group-test"), added);
-
- CartridgeGroupBean bean = (CartridgeGroupBean) restClient.
- getEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
- CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
- assertEquals(bean.getName(), "G4-cartridge-group-test",
- String.format("Cartridge Group name did not match: [cartridge-group-name] %s",
- "g4-g5-g6-cartridge-group-test.json"));
-
- boolean updated = restClient.updateEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
- "/" + "g4-g5-g6-cartridge-group-test-v1.json",
- RestConstants.CARTRIDGE_GROUPS, RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge Group did not updated: [cartridge-group-name] %s",
- "g4-g5-g6-cartridge-group-test"), updated);
-
- CartridgeGroupBean updatedBean = (CartridgeGroupBean) restClient.
- getEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
- CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
- assertEquals(updatedBean.getName(), "G4-cartridge-group-test",
- String.format("Updated Cartridge Group didn't match: [cartridge-group-name] %s",
- "g4-g5-g6-cartridge-group-test"));
-
- boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertFalse(String.format("Cartridge can be removed while it is used in " +
- "cartridge group: [cartridge-name] %s", "c4-cartridge-group-test"), removedC1);
-
- boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertFalse(String.format("Cartridge can be removed while it is used in " +
- "cartridge group: [cartridge-name] %s",
- "c5-cartridge-group-test"), removedC2);
-
- boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertFalse(String.format("Cartridge can be removed while it is used in " +
- "cartridge group: [cartridge-name] %s",
- "c6-cartridge-group-test"), removedC3);
-
- boolean removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
- "g4-g5-g6-cartridge-group-test"), removed);
-
- CartridgeGroupBean beanRemoved = (CartridgeGroupBean) restClient.
- getEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
- CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
- assertEquals(beanRemoved, null,
- String.format("Cartridge Group did not removed completely: [cartridge-group-name] %s",
- "g4-g5-g6-cartridge-group-test"));
-
- removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
- "c4-cartridge-group-test"), removedC1);
-
- removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
- "c5-cartridge-group-test"), removedC2);
-
- removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
- "c6-cartridge-group-test"), removedC3);
-
- log.info("-------------------------Ended Cartridge group test case-------------------------");
-
- }
- catch (Exception e) {
- log.error("An error occurred while handling Cartridge group test case", e);
- assertFalse("An error occurred while handling Cartridge group test case", false);
- }
- }
-
- @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.deployment", "smoke"})
- public void testCartridgeGroupList() {
- try {
- log.info("-------------------------Started Cartridge group list test case-------------------------");
-
- boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
- "/" + "c4-cartridge-group-test.json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
- "c4-cartridge-group-test"), addedC1);
-
- boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
- "/" + "c5-cartridge-group-test.json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
- "c5-cartridge-group-test"), addedC2);
-
- boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
- "/" + "c6-cartridge-group-test.json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
- "c6-cartridge-group-test"), addedC3);
-
- String group1 = "group-1-cartridge-group-test";
- String group2 = "group-2-cartridge-group-test";
-
- boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
- "/" + group1 + ".json", RestConstants.CARTRIDGE_GROUPS,
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
- group1), added);
-
- added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
- "/" + group2 + ".json", RestConstants.CARTRIDGE_GROUPS,
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
- group1), added);
-
- Type listType = new TypeToken<ArrayList<CartridgeGroupBean>>() {
- }.getType();
-
- List<CartridgeGroupBean> cartridgeGroupList = (List<CartridgeGroupBean>) restClient.
- listEntity(RestConstants.CARTRIDGE_GROUPS,
- listType, RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(cartridgeGroupList.size() >= 2);
-
- CartridgeGroupBean bean1 = null;
- for (CartridgeGroupBean cartridgeGroupBean : cartridgeGroupList) {
- if (cartridgeGroupBean.getName().equals(group1)) {
- bean1 = cartridgeGroupBean;
- }
- }
- assertNotNull(bean1);
-
- CartridgeGroupBean bean2 = null;
- for (CartridgeGroupBean cartridgeGroupBean : cartridgeGroupList) {
- if (cartridgeGroupBean.getName().equals(group2)) {
- bean2 = cartridgeGroupBean;
- }
- }
- assertNotNull(bean2);
-
- boolean removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, group1,
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
- group1), removed);
-
- CartridgeGroupBean beanRemoved = (CartridgeGroupBean) restClient.
- getEntity(RestConstants.CARTRIDGE_GROUPS, group1,
- CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
- assertNull(String.format("Cartridge Group did not removed completely: " +
- "[cartridge-group-name] %s",
- group1), beanRemoved);
-
- boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertFalse(String.format("Cartridge can be removed while it is used in " +
- "cartridge group: [cartridge-name] %s", "c4-cartridge-group-test"), removedC1);
-
- boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertFalse(String.format("Cartridge can be removed while it is used in " +
- "cartridge group: [cartridge-name] %s",
- "c5-cartridge-group-test"), removedC2);
-
- boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertFalse(String.format("Cartridge can be removed while it is used in " +
- "cartridge group: [cartridge-name] %s",
- "c6-cartridge-group-test"), removedC3);
-
- removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, group2,
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
- group2), removed);
-
- beanRemoved = (CartridgeGroupBean) restClient.
- getEntity(RestConstants.CARTRIDGE_GROUPS, group2,
- CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
- assertNull(String.format("Cartridge Group did not removed completely: " +
- "[cartridge-group-name] %s",
- group2), beanRemoved);
-
- removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
- "c4-cartridge-group-test"), removedC1);
-
- removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
- "c5-cartridge-group-test"), removedC2);
-
- removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
- "c6-cartridge-group-test"), removedC3);
-
- log.info("-------------------------Ended Cartridge group list test case-------------------------");
- }
- catch (Exception e) {
- log.error("An error occurred while handling Cartridge list group test case", e);
- assertFalse("An error occurred while handling Cartridge list group test case", false);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/1803972c/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTestCase.java
new file mode 100644
index 0000000..38e440f
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTestCase.java
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.integration.tests.group;
+
+import com.google.gson.reflect.TypeToken;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.integration.common.RestConstants;
+import org.apache.stratos.integration.tests.StratosIntegrationTest;
+import org.testng.annotations.Test;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.AssertJUnit.*;
+
+/**
+ * Test to handle Cartridge group CRUD operations
+ */
+public class CartridgeGroupTestCase extends StratosIntegrationTest {
+ private static final Log log = LogFactory.getLog(CartridgeGroupTestCase.class);
+ private static final String RESOURCES_PATH = "/cartridge-group-test";
+
+ @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.deployment", "smoke"})
+ public void testCartridgeGroup() throws Exception {
+ boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
+ "/" + "c4-cartridge-group-test.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+ "c4-cartridge-group-test"), addedC1);
+
+ boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
+ "/" + "c5-cartridge-group-test.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+ "c5-cartridge-group-test"), addedC2);
+
+ boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
+ "/" + "c6-cartridge-group-test.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+ "c6-cartridge-group-test"), addedC3);
+
+ boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+ "/" + "g4-g5-g6-cartridge-group-test.json", RestConstants.CARTRIDGE_GROUPS,
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
+ "g4-g5-g6-cartridge-group-test"), added);
+
+ CartridgeGroupBean bean = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(bean.getName(), "G4-cartridge-group-test",
+ String.format("Cartridge Group name did not match: [cartridge-group-name] %s",
+ "g4-g5-g6-cartridge-group-test.json"));
+
+ boolean updated = restClient.updateEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+ "/" + "g4-g5-g6-cartridge-group-test-v1.json",
+ RestConstants.CARTRIDGE_GROUPS, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge Group did not updated: [cartridge-group-name] %s",
+ "g4-g5-g6-cartridge-group-test"), updated);
+
+ CartridgeGroupBean updatedBean = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(updatedBean.getName(), "G4-cartridge-group-test",
+ String.format("Updated Cartridge Group didn't match: [cartridge-group-name] %s",
+ "g4-g5-g6-cartridge-group-test"));
+
+ boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertFalse(String.format("Cartridge can be removed while it is used in " +
+ "cartridge group: [cartridge-name] %s", "c4-cartridge-group-test"), removedC1);
+
+ boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertFalse(String.format("Cartridge can be removed while it is used in " +
+ "cartridge group: [cartridge-name] %s",
+ "c5-cartridge-group-test"), removedC2);
+
+ boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertFalse(String.format("Cartridge can be removed while it is used in " +
+ "cartridge group: [cartridge-name] %s",
+ "c6-cartridge-group-test"), removedC3);
+
+ boolean removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
+ "g4-g5-g6-cartridge-group-test"), removed);
+
+ CartridgeGroupBean beanRemoved = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, "G4-cartridge-group-test",
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(beanRemoved, null,
+ String.format("Cartridge Group did not removed completely: [cartridge-group-name] %s",
+ "g4-g5-g6-cartridge-group-test"));
+
+ removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+ "c4-cartridge-group-test"), removedC1);
+
+ removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+ "c5-cartridge-group-test"), removedC2);
+
+ removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+ "c6-cartridge-group-test"), removedC3);
+ }
+
+ @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.deployment", "smoke"})
+ public void testCartridgeGroupList() throws Exception {
+ boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
+ "/" + "c4-cartridge-group-test.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+ "c4-cartridge-group-test"), addedC1);
+
+ boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
+ "/" + "c5-cartridge-group-test.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+ "c5-cartridge-group-test"), addedC2);
+
+ boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH +
+ "/" + "c6-cartridge-group-test.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertTrue(String.format("Cartridge did not added: [cartridge-name] %s",
+ "c6-cartridge-group-test"), addedC3);
+
+ String group1 = "group-1-cartridge-group-test";
+ String group2 = "group-2-cartridge-group-test";
+
+ boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+ "/" + group1 + ".json", RestConstants.CARTRIDGE_GROUPS,
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
+ group1), added);
+
+ added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+ "/" + group2 + ".json", RestConstants.CARTRIDGE_GROUPS,
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
+ group1), added);
+
+ Type listType = new TypeToken<ArrayList<CartridgeGroupBean>>() {
+ }.getType();
+
+ List<CartridgeGroupBean> cartridgeGroupList = (List<CartridgeGroupBean>) restClient.
+ listEntity(RestConstants.CARTRIDGE_GROUPS,
+ listType, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(cartridgeGroupList.size() >= 2);
+
+ CartridgeGroupBean bean1 = null;
+ for (CartridgeGroupBean cartridgeGroupBean : cartridgeGroupList) {
+ if (cartridgeGroupBean.getName().equals(group1)) {
+ bean1 = cartridgeGroupBean;
+ }
+ }
+ assertNotNull(bean1);
+
+ CartridgeGroupBean bean2 = null;
+ for (CartridgeGroupBean cartridgeGroupBean : cartridgeGroupList) {
+ if (cartridgeGroupBean.getName().equals(group2)) {
+ bean2 = cartridgeGroupBean;
+ }
+ }
+ assertNotNull(bean2);
+
+ boolean removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, group1,
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
+ group1), removed);
+
+ CartridgeGroupBean beanRemoved = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, group1,
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertNull(String.format("Cartridge Group did not removed completely: " +
+ "[cartridge-group-name] %s",
+ group1), beanRemoved);
+
+ boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertFalse(String.format("Cartridge can be removed while it is used in " +
+ "cartridge group: [cartridge-name] %s", "c4-cartridge-group-test"), removedC1);
+
+ boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertFalse(String.format("Cartridge can be removed while it is used in " +
+ "cartridge group: [cartridge-name] %s",
+ "c5-cartridge-group-test"), removedC2);
+
+ boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertFalse(String.format("Cartridge can be removed while it is used in " +
+ "cartridge group: [cartridge-name] %s",
+ "c6-cartridge-group-test"), removedC3);
+
+ removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, group2,
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
+ group2), removed);
+
+ beanRemoved = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, group2,
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertNull(String.format("Cartridge Group did not removed completely: " +
+ "[cartridge-group-name] %s",
+ group2), beanRemoved);
+
+ removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+ "c4-cartridge-group-test"), removedC1);
+
+ removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+ "c5-cartridge-group-test"), removedC2);
+
+ removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6-cartridge-group-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertTrue(String.format("Cartridge can not be removed : [cartridge-name] %s",
+ "c6-cartridge-group-test"), removedC3);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/1803972c/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
deleted file mode 100644
index 1e72dc5..0000000
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.integration.tests.group;
-
-import com.google.gson.reflect.TypeToken;
-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.integration.common.RestConstants;
-import org.apache.stratos.integration.tests.StratosIntegrationTest;
-import org.testng.annotations.Test;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-/**
- * Test to handle Cartridge CRUD operations
- */
-public class CartridgeTest extends StratosIntegrationTest {
- private static final Log log = LogFactory.getLog(CartridgeTest.class);
- private static final String RESOURCES_PATH = "/cartridge-test";
-
- @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.deployment", "smoke"})
- public void testCartridge() {
- log.info("--------------------Started Cartridge test case-----------------------------");
-
- try {
- String cartridgeType = "c0-cartridge-test";
- boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
- cartridgeType + ".json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertTrue(added);
- CartridgeBean bean = (CartridgeBean) restClient.
- getEntity(RestConstants.CARTRIDGES, cartridgeType,
- CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
- 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 = restClient.updateEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
- cartridgeType + "-v1.json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertTrue(updated);
- CartridgeBean updatedBean = (CartridgeBean) restClient.
- getEntity(RestConstants.CARTRIDGES, cartridgeType,
- CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
- assertEquals(updatedBean.getType(), "c0-cartridge-test");
- 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 = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType,
- RestConstants.CARTRIDGES_NAME);
- assertTrue(removed);
-
- CartridgeBean beanRemoved = (CartridgeBean) restClient.
- getEntity(RestConstants.CARTRIDGES, cartridgeType,
- CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
- assertNull(beanRemoved);
-
- log.info("---------------------------Ended Cartridge test case-------------------------");
- }
- catch (Exception e) {
- log.error("An error occurred while handling RESTConstants.CARTRIDGES_PATH", e);
- assertTrue("An error occurred while handling RESTConstants.CARTRIDGES_PATH", false);
- }
- }
-
- @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.deployment", "smoke"})
- public void testCartridgeList() {
- log.info("--------------------Started Cartridge list test case-----------------------------");
-
- try {
- String cartridgeType1 = "c1-cartridge-test";
- String cartridgeType2 = "c2-cartridge-test";
- boolean added1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
- cartridgeType1 + ".json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertTrue(added1);
-
- boolean added2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
- cartridgeType2 + ".json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertTrue(added2);
-
- Type listType = new TypeToken<ArrayList<CartridgeBean>>() {
- }.getType();
-
- List<CartridgeBean> cartridgeList = (List<CartridgeBean>) restClient.listEntity(RestConstants.CARTRIDGES,
- listType, RestConstants.CARTRIDGES_NAME);
- assertTrue(cartridgeList.size() >= 2);
-
- CartridgeBean bean1 = null;
- for (CartridgeBean cartridgeBean : cartridgeList) {
- if (cartridgeBean.getType().equals(cartridgeType1)) {
- bean1 = cartridgeBean;
- }
- }
- assertNotNull(bean1);
-
- CartridgeBean bean2 = null;
- for (CartridgeBean cartridgeBean : cartridgeList) {
- if (cartridgeBean.getType().equals(cartridgeType1)) {
- bean2 = cartridgeBean;
- }
- }
- assertNotNull(bean2);
-
- boolean removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType1,
- RestConstants.CARTRIDGES_NAME);
- assertTrue(removed);
-
- CartridgeBean beanRemoved = (CartridgeBean) restClient.
- getEntity(RestConstants.CARTRIDGES, cartridgeType1,
- CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
- assertEquals(beanRemoved, null);
-
- removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType2,
- RestConstants.CARTRIDGES_NAME);
- assertTrue(removed);
-
- beanRemoved = (CartridgeBean) restClient.
- getEntity(RestConstants.CARTRIDGES, cartridgeType2,
- CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
- assertNull(beanRemoved);
-
- log.info("---------------------------Ended Cartridge list test case-------------------------");
- }
- catch (Exception e) {
- log.error("An error occurred while handling Cartridges list", e);
- assertTrue("An error occurred while handling Cartridges list", false);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1803972c/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTestCase.java
new file mode 100644
index 0000000..4e9484a
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTestCase.java
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.integration.tests.group;
+
+import com.google.gson.reflect.TypeToken;
+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.integration.common.RestConstants;
+import org.apache.stratos.integration.tests.StratosIntegrationTest;
+import org.testng.annotations.Test;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
+
+/**
+ * Test to handle Cartridge CRUD operations
+ */
+public class CartridgeTestCase extends StratosIntegrationTest {
+ private static final Log log = LogFactory.getLog(CartridgeTestCase.class);
+ private static final String RESOURCES_PATH = "/cartridge-test";
+
+ @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.deployment", "smoke"})
+ public void testCartridge() throws Exception {
+ String cartridgeType = "c0-cartridge-test";
+ boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
+ cartridgeType + ".json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertTrue(added);
+ CartridgeBean bean = (CartridgeBean) restClient.
+ getEntity(RestConstants.CARTRIDGES, cartridgeType,
+ CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
+ 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 = restClient.updateEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
+ cartridgeType + "-v1.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertTrue(updated);
+ CartridgeBean updatedBean = (CartridgeBean) restClient.
+ getEntity(RestConstants.CARTRIDGES, cartridgeType,
+ CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
+ assertEquals(updatedBean.getType(), "c0-cartridge-test");
+ 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 = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType,
+ RestConstants.CARTRIDGES_NAME);
+ assertTrue(removed);
+
+ CartridgeBean beanRemoved = (CartridgeBean) restClient.
+ getEntity(RestConstants.CARTRIDGES, cartridgeType,
+ CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
+ assertNull(beanRemoved);
+ }
+
+ @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.deployment", "smoke"})
+ public void testCartridgeList() throws Exception {
+ String cartridgeType1 = "c1-cartridge-test";
+ String cartridgeType2 = "c2-cartridge-test";
+ boolean added1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
+ cartridgeType1 + ".json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertTrue(added1);
+
+ boolean added2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" +
+ cartridgeType2 + ".json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertTrue(added2);
+
+ Type listType = new TypeToken<ArrayList<CartridgeBean>>() {
+ }.getType();
+
+ List<CartridgeBean> cartridgeList = (List<CartridgeBean>) restClient.listEntity(RestConstants.CARTRIDGES,
+ listType, RestConstants.CARTRIDGES_NAME);
+ assertTrue(cartridgeList.size() >= 2);
+
+ CartridgeBean bean1 = null;
+ for (CartridgeBean cartridgeBean : cartridgeList) {
+ if (cartridgeBean.getType().equals(cartridgeType1)) {
+ bean1 = cartridgeBean;
+ }
+ }
+ assertNotNull(bean1);
+
+ CartridgeBean bean2 = null;
+ for (CartridgeBean cartridgeBean : cartridgeList) {
+ if (cartridgeBean.getType().equals(cartridgeType1)) {
+ bean2 = cartridgeBean;
+ }
+ }
+ assertNotNull(bean2);
+
+ boolean removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType1,
+ RestConstants.CARTRIDGES_NAME);
+ assertTrue(removed);
+
+ CartridgeBean beanRemoved = (CartridgeBean) restClient.
+ getEntity(RestConstants.CARTRIDGES, cartridgeType1,
+ CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
+ assertEquals(beanRemoved, null);
+
+ removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType2,
+ RestConstants.CARTRIDGES_NAME);
+ assertTrue(removed);
+
+ beanRemoved = (CartridgeBean) restClient.
+ getEntity(RestConstants.CARTRIDGES, cartridgeType2,
+ CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
+ assertNull(beanRemoved);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/1803972c/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
deleted file mode 100644
index 5df6f4f..0000000
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.integration.tests.policies;
-
-import com.google.gson.reflect.TypeToken;
-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.partition.NetworkPartitionBean;
-import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
-import org.apache.stratos.integration.common.RestConstants;
-import org.apache.stratos.integration.tests.StratosIntegrationTest;
-import org.testng.annotations.Test;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.testng.Assert.*;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-
-/**
- * Test to handle Network partition CRUD operations
- */
-public class ApplicationPolicyTest extends StratosIntegrationTest {
- private static final Log log = LogFactory.getLog(ApplicationPolicyTest.class);
- private static final String RESOURCES_PATH = "/application-policy-test";
-
- @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.policy.management", "smoke"})
- public void testApplicationPolicy() {
- try {
- String applicationPolicyId = "application-policy-application-policy-test";
- log.info("-------------------------Started Application policy test case-------------------------");
-
- boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- "network-partition-application-policy-test-1" + ".json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
- assertTrue(addedN1);
-
- boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- "network-partition-application-policy-test-2" + ".json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
- assertTrue(addedN2);
-
- boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
- applicationPolicyId + ".json",
- RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME);
- assertTrue(addedDep);
-
- ApplicationPolicyBean bean = (ApplicationPolicyBean) restClient.
- getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
- ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
- assertEquals(bean.getId(), applicationPolicyId);
- assertEquals(bean.getAlgorithm(), "one-after-another",
- String.format("The expected algorithm %s is not found in %s", "one-after-another",
- applicationPolicyId));
- assertEquals(bean.getId(), applicationPolicyId,
- String.format("The expected id %s is not found", applicationPolicyId));
- assertEquals(bean.getNetworkPartitions().length, 2,
- String.format("The expected networkpartitions size %s is not found in %s", 2, applicationPolicyId));
- assertEquals(bean.getNetworkPartitions()[0], "network-partition-application-policy-test-1",
- String.format("The first network partition is not %s in %s",
- "network-partition-application-policy-test-1", applicationPolicyId));
- assertEquals(bean.getNetworkPartitions()[1], "network-partition-application-policy-test-2",
- String.format("The Second network partition is not %s in %s",
- "network-partition-application-policy-test-2", applicationPolicyId));
- boolean algoFound = false;
- for (PropertyBean propertyBean : bean.getProperties()) {
- if (propertyBean.getName().equals("networkPartitionGroups")) {
- assertEquals(propertyBean.getValue(),
- "network-partition-application-policy-test-1,network-partition-application-policy-test-2",
- String.format("The networkPartitionGroups algorithm %s is not found in %s",
- "network-partition-application-policy-test-1, network-partition-application-policy-test-2",
- applicationPolicyId));
- algoFound = true;
-
- }
- }
- if (!algoFound) {
- assertNull(String.format("The networkPartitionGroups property is not found in %s",
- applicationPolicyId));
- }
-
- boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
- //Trying to remove the used network partition
- assertFalse(removedNet);
-
- boolean removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
- applicationPolicyId, RestConstants.APPLICATION_POLICIES_NAME);
- assertTrue(removedDep);
-
- ApplicationPolicyBean beanRemovedDep = (ApplicationPolicyBean) restClient.
- getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
- ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
- assertNull(beanRemovedDep);
-
- boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
- assertTrue(removedN1);
-
- NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
- getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-1",
- NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
- assertNull(beanRemovedN1);
-
- boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-application-policy-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
- assertTrue(removedN2);
-
- NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
- getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-2",
- NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
- assertNull(beanRemovedN2);
-
- 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);
- }
- }
-
- @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.policy.management", "smoke"})
- public void testApplicationPolicyList() {
- try {
- String applicationPolicyId1 = "application-policy-application-policy-test-1";
- String applicationPolicyId2 = "application-policy-application-policy-test-2";
- log.info("-------------------------Started Application policy list test case-------------------------");
-
- boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- "network-partition-application-policy-test-1" + ".json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
- assertTrue(addedN1);
-
- boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- "network-partition-application-policy-test-2" + ".json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
- assertTrue(addedN2);
-
- boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
- applicationPolicyId1 + ".json",
- RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME);
- assertTrue(addedDep);
-
- addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
- applicationPolicyId2 + ".json",
- RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME);
- assertTrue(addedDep);
-
- Type listType = new TypeToken<ArrayList<ApplicationPolicyBean>>() {
- }.getType();
-
- List<ApplicationPolicyBean> applicationPolicyList = (List<ApplicationPolicyBean>) restClient.
- listEntity(RestConstants.APPLICATION_POLICIES,
- listType, RestConstants.APPLICATION_POLICIES_NAME);
- assertTrue(applicationPolicyList.size() >= 2);
-
- ApplicationPolicyBean bean1 = null;
- for (ApplicationPolicyBean applicationPolicyBean : applicationPolicyList) {
- if (applicationPolicyBean.getId().equals(applicationPolicyId1)) {
- bean1 = applicationPolicyBean;
- }
- }
- assertNotNull(bean1);
-
- ApplicationPolicyBean bean2 = null;
- for (ApplicationPolicyBean applicationPolicyBean : applicationPolicyList) {
- if (applicationPolicyBean.getId().equals(applicationPolicyId2)) {
- bean2 = applicationPolicyBean;
- }
- }
- assertNotNull(bean2);
-
- boolean removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
- applicationPolicyId1, RestConstants.APPLICATION_POLICIES_NAME);
- assertTrue(removedDep);
-
- ApplicationPolicyBean beanRemovedDep = (ApplicationPolicyBean) restClient.
- getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId1,
- ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
- assertNull(beanRemovedDep);
-
- boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
- //Trying to remove the used network partition
- assertFalse(removedNet);
-
- removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
- applicationPolicyId2, RestConstants.APPLICATION_POLICIES_NAME);
- assertTrue(removedDep);
-
- beanRemovedDep = (ApplicationPolicyBean) restClient.
- getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId2,
- ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
- assertNull(beanRemovedDep);
-
- boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
- assertTrue(removedN1);
-
- NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
- getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-1",
- NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
- assertNull(beanRemovedN1);
-
- boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-application-policy-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
- assertTrue(removedN2);
-
- NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
- getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-2",
- NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
- assertNull(beanRemovedN2);
-
- 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);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/1803972c/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTestCase.java
new file mode 100644
index 0000000..2ae3207
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTestCase.java
@@ -0,0 +1,222 @@
+/*
+ * 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 com.google.gson.reflect.TypeToken;
+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.partition.NetworkPartitionBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.common.RestConstants;
+import org.apache.stratos.integration.tests.StratosIntegrationTest;
+import org.testng.annotations.Test;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.Assert.*;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+
+/**
+ * Test to handle Network partition CRUD operations
+ */
+public class ApplicationPolicyTestCase extends StratosIntegrationTest {
+ private static final Log log = LogFactory.getLog(ApplicationPolicyTestCase.class);
+ private static final String RESOURCES_PATH = "/application-policy-test";
+
+ @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.policy.management", "smoke"})
+ public void testApplicationPolicy() throws Exception {
+ String applicationPolicyId = "application-policy-application-policy-test";
+ boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-application-policy-test-1" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertTrue(addedN1);
+
+ boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-application-policy-test-2" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertTrue(addedN2);
+
+ boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+ applicationPolicyId + ".json",
+ RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME);
+ assertTrue(addedDep);
+
+ ApplicationPolicyBean bean = (ApplicationPolicyBean) restClient.
+ getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
+ ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(bean.getId(), applicationPolicyId);
+ assertEquals(bean.getAlgorithm(), "one-after-another",
+ String.format("The expected algorithm %s is not found in %s", "one-after-another",
+ applicationPolicyId));
+ assertEquals(bean.getId(), applicationPolicyId,
+ String.format("The expected id %s is not found", applicationPolicyId));
+ assertEquals(bean.getNetworkPartitions().length, 2,
+ String.format("The expected networkpartitions size %s is not found in %s", 2, applicationPolicyId));
+ assertEquals(bean.getNetworkPartitions()[0], "network-partition-application-policy-test-1",
+ String.format("The first network partition is not %s in %s",
+ "network-partition-application-policy-test-1", applicationPolicyId));
+ assertEquals(bean.getNetworkPartitions()[1], "network-partition-application-policy-test-2",
+ String.format("The Second network partition is not %s in %s",
+ "network-partition-application-policy-test-2", applicationPolicyId));
+ boolean algoFound = false;
+ for (PropertyBean propertyBean : bean.getProperties()) {
+ if (propertyBean.getName().equals("networkPartitionGroups")) {
+ assertEquals(propertyBean.getValue(),
+ "network-partition-application-policy-test-1,network-partition-application-policy-test-2",
+ String.format("The networkPartitionGroups algorithm %s is not found in %s",
+ "network-partition-application-policy-test-1, network-partition-application-policy-test-2",
+ applicationPolicyId));
+ algoFound = true;
+
+ }
+ }
+ if (!algoFound) {
+ assertNull(String.format("The networkPartitionGroups property is not found in %s",
+ applicationPolicyId));
+ }
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+ //Trying to remove the used network partition
+ assertFalse(removedNet);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+ applicationPolicyId, RestConstants.APPLICATION_POLICIES_NAME);
+ assertTrue(removedDep);
+
+ ApplicationPolicyBean beanRemovedDep = (ApplicationPolicyBean) restClient.
+ getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
+ ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
+ assertNull(beanRemovedDep);
+
+ boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertTrue(removedN1);
+
+ NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-1",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertNull(beanRemovedN1);
+
+ boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-application-policy-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertTrue(removedN2);
+
+ NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-2",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertNull(beanRemovedN2);
+ }
+
+ @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.policy.management", "smoke"})
+ public void testApplicationPolicyList() throws Exception {
+ String applicationPolicyId1 = "application-policy-application-policy-test-1";
+ String applicationPolicyId2 = "application-policy-application-policy-test-2";
+
+ boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-application-policy-test-1" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertTrue(addedN1);
+
+ boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-application-policy-test-2" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertTrue(addedN2);
+
+ boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+ applicationPolicyId1 + ".json",
+ RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME);
+ assertTrue(addedDep);
+
+ addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+ applicationPolicyId2 + ".json",
+ RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME);
+ assertTrue(addedDep);
+
+ Type listType = new TypeToken<ArrayList<ApplicationPolicyBean>>() {
+ }.getType();
+
+ List<ApplicationPolicyBean> applicationPolicyList = (List<ApplicationPolicyBean>) restClient.
+ listEntity(RestConstants.APPLICATION_POLICIES,
+ listType, RestConstants.APPLICATION_POLICIES_NAME);
+ assertTrue(applicationPolicyList.size() >= 2);
+
+ ApplicationPolicyBean bean1 = null;
+ for (ApplicationPolicyBean applicationPolicyBean : applicationPolicyList) {
+ if (applicationPolicyBean.getId().equals(applicationPolicyId1)) {
+ bean1 = applicationPolicyBean;
+ }
+ }
+ assertNotNull(bean1);
+
+ ApplicationPolicyBean bean2 = null;
+ for (ApplicationPolicyBean applicationPolicyBean : applicationPolicyList) {
+ if (applicationPolicyBean.getId().equals(applicationPolicyId2)) {
+ bean2 = applicationPolicyBean;
+ }
+ }
+ assertNotNull(bean2);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+ applicationPolicyId1, RestConstants.APPLICATION_POLICIES_NAME);
+ assertTrue(removedDep);
+
+ ApplicationPolicyBean beanRemovedDep = (ApplicationPolicyBean) restClient.
+ getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId1,
+ ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
+ assertNull(beanRemovedDep);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+ //Trying to remove the used network partition
+ assertFalse(removedNet);
+
+ removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+ applicationPolicyId2, RestConstants.APPLICATION_POLICIES_NAME);
+ assertTrue(removedDep);
+
+ beanRemovedDep = (ApplicationPolicyBean) restClient.
+ getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId2,
+ ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
+ assertNull(beanRemovedDep);
+
+ boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-application-policy-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertTrue(removedN1);
+
+ NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-1",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertNull(beanRemovedN1);
+
+ boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-application-policy-test-2", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertTrue(removedN2);
+
+ NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-application-policy-test-2",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertNull(beanRemovedN2);
+ }
+}
\ No newline at end of file