geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aba...@apache.org
Subject [8/9] incubator-geode git commit: GEODE-1984: Adding more Tests and fixing the error message
Date Fri, 25 Nov 2016 15:17:55 GMT
GEODE-1984: Adding more Tests and fixing the error message


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/24a4dc44
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/24a4dc44
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/24a4dc44

Branch: refs/heads/feature/GEODE-1984
Commit: 24a4dc44e8d00ba9c56d828fb311dbae42974dfc
Parents: 43e45a9
Author: adongre <adongre@apache.org>
Authored: Mon Nov 21 14:03:48 2016 +0530
Committer: adongre <adongre@apache.org>
Committed: Mon Nov 21 14:03:48 2016 +0530

----------------------------------------------------------------------
 .../functions/GatewaySenderDestroyFunction.java |   2 +-
 ...mandCreateDestroyGatewaySenderDUnitTest.java | 107 +++++++++++++++++++
 2 files changed, 108 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/24a4dc44/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
index a7ca8c5..c1abc6b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction.java
@@ -51,7 +51,7 @@ public class GatewaySenderDestroyFunction extends FunctionAdapter implements
Int
         gatewaySender.destroy();
       } else {
         throw new GatewaySenderException(
-            "GateWaySender with Id " + gatewaySenderDestroyFunctionArgs.getId() + "not found");
+            "GateWaySender with Id " + gatewaySenderDestroyFunctionArgs.getId() + " not found");
       }
       resultSender.lastResult(new CliFunctionResult(memberNameOrId, true,
           CliStrings.format(CliStrings.DESTROY_GATEWAYSENDER__MSG__GATEWAYSENDER_0_DESTROYED_ON_1,

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/24a4dc44/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
index 6b96619..14a38b7 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WanCommandCreateDestroyGatewaySenderDUnitTest.java
@@ -104,6 +104,15 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
       getLogWriter().info(
           "testCreateDestroyGatewaySenderWithDefault stringResult : " + strCmdResult + ">>>>");
       assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+
     } else {
       fail("testCreateDestroyGatewaySenderWithDefault failed as did not get CommandResult");
     }
@@ -185,6 +194,14 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
       String strCmdResult = commandResultToString(cmdResult);
       getLogWriter().info("testCreateDestroyGatewaySender stringResult : " + strCmdResult
+ ">>>>");
       assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
     } else {
       fail("testCreateDestroyGatewaySender failed as did not get CommandResult");
     }
@@ -328,6 +345,14 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
       getLogWriter().info("testCreateDestroyGatewaySenderWithGatewayEventFilters stringResult
: "
           + strCmdResult + ">>>>");
       assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
     } else {
       fail(
           "testCreateDestroyGatewaySenderWithGatewayEventFilters failed as did not get CommandResult");
@@ -420,6 +445,15 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
           .info("testCreateDestroyGatewaySenderWithGatewayTransportFilters stringResult :
"
               + strCmdResult + ">>>>");
       assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+
     } else {
       fail(
           "testCreateDestroyGatewaySenderWithGatewayTransportFilters failed as did not get
CommandResult");
@@ -501,6 +535,15 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
       getLogWriter()
           .info("testCreateDestroyGatewaySender_OnMember stringResult : " + strCmdResult
+ ">>>>");
       assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(1, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+
     } else {
       fail("testCreateDestroyGatewaySender_OnMember failed as did not get CommandResult");
     }
@@ -577,6 +620,14 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
       getLogWriter()
           .info("testCreateDestroyGatewaySender_Group stringResult : " + strCmdResult + ">>>>");
       assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(3, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
     } else {
       fail("testCreateDestroyGatewaySender_Group failed as did not get CommandResult");
     }
@@ -657,6 +708,14 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
       getLogWriter().info(
           "testCreateDestroyGatewaySender_Group_Scenario2 stringResult : " + strCmdResult
+ ">>>>");
       assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(2, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
     } else {
       fail("testCreateDestroyGatewaySender_Group_Scenario2 failed as did not get CommandResult");
     }
@@ -741,6 +800,15 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
       getLogWriter()
           .info("testCreateDestroyParallelGatewaySender stringResult : " + strCmdResult +
">>>>");
       assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy failed with: " + status.get(i),
+            status.get(i).indexOf("ERROR:") == -1);
+      }
+
     } else {
       fail("testCreateDestroyParallelGatewaySender failed as did not get CommandResult");
     }
@@ -811,4 +879,43 @@ public class WanCommandCreateDestroyGatewaySenderDUnitTest extends WANCommandTes
     }
 
   }
+
+  @Test
+  public void testDestroyGatewaySender_NotCreatedSender() {
+
+    Integer punePort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
+
+    Properties props = getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, "1");
+    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
+    setUpJmxManagerOnVm0ThenConnect(props);
+
+    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
+
+    vm3.invoke(() -> createCache(punePort));
+    vm4.invoke(() -> createCache(punePort));
+    vm5.invoke(() -> createCache(punePort));
+
+    // Test Destroy Command
+    String command =
+        CliStrings.DESTROY_GATEWAYSENDER + " --" + CliStrings.DESTROY_GATEWAYSENDER__ID +
"=ln";
+    CommandResult cmdResult = executeCommandWithIgnoredExceptions(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter()
+          .info("testDestroyGatewaySender_NotCreatedSender stringResult : " + strCmdResult
+ ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(5, status.size());
+      for (int i = 0; i < status.size(); i++) {
+        assertTrue("GatewaySender destroy should fail", status.get(i).indexOf("ERROR:") !=
-1);
+      }
+
+    } else {
+      fail("testCreateDestroyParallelGatewaySender failed as did not get CommandResult");
+    }
+  }
 }


Mime
View raw message