public void testListGatewayWithNoSenderReceiver() {

    Integer punePort = (Integer) vm1.invoke(() -> WANCommandTestBase.createFirstLocatorWithDSId(1));

    Properties props = getDistributedSystemProperties();
    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
    props.setProperty(DistributionConfig.DISTRIBUTED_SYSTEM_ID_NAME, "1");
    props.setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + punePort + "]");
    createDefaultSetup(props);

    Integer nyPort =
        (Integer) vm2.invoke(() -> WANCommandTestBase.createFirstRemoteLocator(2, punePort));

    vm3.invoke(() -> WANCommandTestBase.createCache(punePort));
    vm4.invoke(() -> WANCommandTestBase.createCache(punePort));
    vm5.invoke(() -> WANCommandTestBase.createCache(punePort));

    Wait.pause(10000);
    String command = CliStrings.LIST_GATEWAY;
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
      String strCmdResult = commandResultToString(cmdResult);
      Log.getLogWriter().info("testListGatewaySender : : " + strCmdResult);
      assertEquals(Result.Status.ERROR, cmdResult.getStatus());
    } else {
      fail("testListGatewaySender failed as did not get CommandResult");
    }
  }
  public void testListGatewayReceiver() {

    Integer lnPort = (Integer) vm1.invoke(() -> WANCommandTestBase.createFirstLocatorWithDSId(1));

    Properties props = getDistributedSystemProperties();
    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
    props.setProperty(DistributionConfig.DISTRIBUTED_SYSTEM_ID_NAME, "1");
    props.setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + lnPort + "]");
    createDefaultSetup(props);

    Integer nyPort =
        (Integer) vm2.invoke(() -> WANCommandTestBase.createFirstRemoteLocator(2, lnPort));

    vm3.invoke(() -> WANCommandTestBase.createAndStartReceiver(lnPort));
    vm4.invoke(() -> WANCommandTestBase.createAndStartReceiver(lnPort));

    vm5.invoke(() -> WANCommandTestBase.createCache(nyPort));
    vm5.invoke(
        () ->
            WANCommandTestBase.createSender(
                "ln_Serial", 1, false, 100, 400, false, false, null, false));
    vm6.invoke(() -> WANCommandTestBase.createCache(nyPort));
    vm6.invoke(
        () ->
            WANCommandTestBase.createSender(
                "ln_Serial", 1, false, 100, 400, false, false, null, false));
    vm6.invoke(
        () ->
            WANCommandTestBase.createSender(
                "ln_Parallel", 1, true, 100, 400, false, false, null, false));

    Wait.pause(10000);
    String command = CliStrings.LIST_GATEWAY;
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
      String strCmdResult = commandResultToString(cmdResult);
      Log.getLogWriter().info("testListGatewayReceiver" + strCmdResult);
      assertEquals(Result.Status.OK, cmdResult.getStatus());

      TabularResultData tableResultData =
          ((CompositeResultData) cmdResult.getResultData())
              .retrieveSection(CliStrings.SECTION_GATEWAY_RECEIVER)
              .retrieveTable(CliStrings.TABLE_GATEWAY_RECEIVER);
      List<String> ports = tableResultData.retrieveAllValues(CliStrings.RESULT_PORT);
      assertEquals(2, ports.size());
      List<String> hosts = tableResultData.retrieveAllValues(CliStrings.RESULT_HOST_MEMBER);
      assertEquals(2, hosts.size());

      assertEquals(
          null,
          ((CompositeResultData) cmdResult.getResultData())
              .retrieveSection(CliStrings.SECTION_GATEWAY_SENDER));

    } else {
      fail("testListGatewayReceiver failed as did not get CommandResult");
    }
  }
  /**
   * This test performs the following:<br>
   * 1)create server<br>
   * 2)initialize proxy object and create region for client<br>
   * 3)perform a PUT on client by acquiring Connection through proxy<br>
   * 4)stop server monitor threads in client to ensure that server treats this as dead client <br>
   * 5)wait for some time to allow server to clean up the dead client artifacts<br>
   * 6)again perform a PUT on client through same Connection and verify after the put that the
   * Connection object used was new one.
   */
  @Test
  public void testDeadClientRemovalByServer() throws Exception {
    PORT = createServer();
    createProxyAndRegionForClient();
    //    String connection2String = null;
    StatisticsType st = this.system.findType("CacheServerStats");
    final Statistics s = this.system.findStatisticsByType(st)[0];
    assertEquals(0, s.getInt("currentClients"));
    assertEquals(0, s.getInt("currentClientConnections"));
    this.system
        .getLogWriter()
        .info(
            "beforeAcquireConnection clients="
                + s.getInt("currentClients")
                + " cnxs="
                + s.getInt("currentClientConnections"));
    Connection connection1 = proxy.acquireConnection();
    this.system
        .getLogWriter()
        .info(
            "afterAcquireConnection clients="
                + s.getInt("currentClients")
                + " cnxs="
                + s.getInt("currentClientConnections"));
    this.system.getLogWriter().info("acquired connection " + connection1);
    WaitCriterion ev =
        new WaitCriterion() {
          public boolean done() {
            return s.getInt("currentClients") != 0;
          }

          public String description() {
            return null;
          }
        };
    Wait.waitForCriterion(ev, 20 * 1000, 200, true);

    assertEquals(1, s.getInt("currentClients"));
    assertEquals(1, s.getInt("currentClientConnections"));
    //    String connection1String = connection1.toString();
    ServerRegionProxy srp = new ServerRegionProxy("region1", proxy);
    srp.putOnForTestsOnly(connection1, "key-1", "value-1", new EventID(new byte[] {1}, 1, 1), null);
    this.system.getLogWriter().info("did put 1");
    // proxy.testfinalizeServerConnectionMonitor();
    ev =
        new WaitCriterion() {
          public boolean done() {
            return s.getInt("currentClients") == 0;
          }

          public String description() {
            return null;
          }
        };
    Wait.waitForCriterion(ev, TIME_BETWEEN_PINGS * 5, 200, true);

    {
      this.system
          .getLogWriter()
          .info(
              "currentClients="
                  + s.getInt("currentClients")
                  + " currentClientConnections="
                  + s.getInt("currentClientConnections"));
      assertEquals(0, s.getInt("currentClients"));
      assertEquals(0, s.getInt("currentClientConnections"));
    }
    addExceptions();
    // the connection should now fail since the server timed it out
    try {
      srp.putOnForTestsOnly(connection1, "key-1", "fail", new EventID(new byte[] {1}, 1, 2), null);
      fail("expected EOF");
    } catch (ServerConnectivityException expected) {
    }
    // The rest of this test no longer works.
    //     connection1.finalizeConnection();
    //     proxy.release();

    //     connection1 = proxy.acquireConnection();
    //     connection2String = connection1.toString();
    //     this.system.getLogWriter().info("connection is now " + connection2String);

    //     if (connection1String.equals(connection2String)) {
    //       fail("New connection object was not obtained");
    //     }
    //     connection1.putObject("region1", "key-1", "value-2", new EventID(new byte[] {1},1,3),
    // null);
    //     this.system.getLogWriter().info("did put 2");
    //     assertEquals(1, s.getInt("currentClients"));
    //     assertEquals(1, s.getInt("currentClientConnections"));

    //     // now lets see what happens when we close our connection
    //     // note we use a nasty close which just closes the socket instead
    //     // of sending a nice message to the server telling him we are going away
    //     ((ConnectionImpl)connection1).finalizeConnection();
    //     {
    //       int retry = (TIME_BETWEEN_PINGS*5) / 100;
    //       while (s.getInt("currentClients") > 0 && retry-- > 0) {
    //         Thread.sleep(100);
    //       }
    //       this.system.getLogWriter().info("currentClients="
    //                                       + s.getInt("currentClients")
    //                                       + " currentClientConnections="
    //                                       + s.getInt("currentClientConnections"));
    //       assertEquals(0, s.getInt("currentClients"));
    //       assertEquals(0, s.getInt("currentClientConnections"));
    //     }
  }