geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
@Test
  public void testCreateGatewayReceiver_Error() {
    VM puneLocator = Host.getLocator();
    int dsIdPort = puneLocator.invoke(this::getLocatorPort);
    propsSetUp(dsIdPort);
    vm2.invoke(() -> createFirstRemoteLocator(2, dsIdPort));

    vm3.invoke(() -> createCache(dsIdPort));
    vm4.invoke(() -> createCache(dsIdPort));
    vm5.invoke(() -> createCache(dsIdPort));

    String command =
        CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS
            + "=localhost" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT + "=11000" + " --"
            + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=10000" + " --"
            + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
            + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000";
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
      String strCmdResult = commandResultToString(cmdResult);
      getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
      assertEquals(Result.Status.OK, cmdResult.getStatus());

      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
      List<String> status = resultData.retrieveAllValues("Status");
      assertEquals(4, status.size());// expected size 4 includes the manager
                                     // node
      // verify there is no error in the status
      for (String stat : status) {
        assertTrue("GatewayReceiver creation should have failed", stat.contains("ERROR:"));
      }
    } else {
      fail("testCreateGatewayReceiver failed as did not get CommandResult");
    }
  }
/**
   * GatewayReceiver with given attributes. Error scenario where startPort is greater than endPort.
   */
GatewayReceiver with given attributes. Error scenario where startPort is greater than endPort.
GatewayReceiver with given attributes . Error scenario where startPort is greater than endPort .
@Test
  public void testCreateGatewayReceiver_Error() {
    VM puneLocator = Host.getLocator();
    int dsIdPort = puneLocator.invoke(this::getLocatorPort);
    propsSetUp(dsIdPort);
    vm2.invoke(() -> createFirstRemoteLocator(2, dsIdPort));
    vm3.invoke(() -> createCache(dsIdPort));
    vm4.invoke(() -> createCache(dsIdPort));
    vm5.invoke(() -> createCache(dsIdPort));
    String command =
        CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS
            + "=localhost" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT + "=11000" + " --"
            + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=10000" + " --"
            + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
            + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000";
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
      String strCmdResult = commandResultToString(cmdResult);
      getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
      assertEquals(Result.Status.OK, cmdResult.getStatus());
      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
      List<String> status = resultData.retrieveAllValues("Status");
      assertEquals(4, status.size());
      for (String stat : status) {
        assertTrue("GatewayReceiver creation should have failed", stat.contains("ERROR:"));
      }
    } else {
      fail("testCreateGatewayReceiver failed as did not get CommandResult");
    }
  }
@ Test public void testCreateGatewayReceiver_Error ( ) { VM puneLocator = Host . getLocator ( ) ; int dsIdPort = puneLocator . invoke ( this :: getLocatorPort ) ; propsSetUp ( dsIdPort ) ; vm2 . invoke ( ( ) -> createFirstRemoteLocator ( 2 , dsIdPort ) ) ; vm3 . invoke ( ( ) -> createCache ( dsIdPort ) ) ; vm4 . invoke ( ( ) -> createCache ( dsIdPort ) ) ; vm5 . invoke ( ( ) -> createCache ( dsIdPort ) ) ; String command = CliStrings . CREATE_GATEWAYRECEIVER + " --" + CliStrings . CREATE_GATEWAYRECEIVER__BINDADDRESS + "=localhost" + " --" + CliStrings . CREATE_GATEWAYRECEIVER__STARTPORT + "=11000" + " --" + CliStrings . CREATE_GATEWAYRECEIVER__ENDPORT + "=10000" + " --" + CliStrings . CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --" + CliStrings . CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" ; CommandResult cmdResult = executeCommand ( command ) ; if ( cmdResult != null ) { String strCmdResult = commandResultToString ( cmdResult ) ; getLogWriter ( ) . info ( "testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>" ) ; assertEquals ( Result . Status . OK , cmdResult . getStatus ( ) ) ; TabularResultData resultData = ( TabularResultData ) cmdResult . getResultData ( ) ; List < String > status = resultData . retrieveAllValues ( "Status" ) ; assertEquals ( 4 , status . size ( ) ) ; for ( String stat : status ) { assertTrue ( "GatewayReceiver creation should have failed" , stat . contains ( "ERROR:" ) ) ; } } else { fail ( "testCreateGatewayReceiver failed as did not get CommandResult" ) ; } }
GatewayReceiver with given attributes.
GatewayReceiver with given attributes .
// expected size 4 includes the manager // node // verify there is no error in the status