[ 
https://issues.apache.org/jira/browse/GEODE-3539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16292820#comment-16292820
 ] 

ASF GitHub Bot commented on GEODE-3539:
---------------------------------------

jinmeiliao closed pull request #1162: GEODE-3539: add tests for 
ExportStackTraceCommand
URL: https://github.com/apache/geode/pull/1162
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportStackTraceCommand.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportStackTraceCommand.java
index 4f8693d382..ddf84dd444 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportStackTraceCommand.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportStackTraceCommand.java
@@ -34,11 +34,9 @@
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.ConverterHint;
 import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.domain.StackTracesPerMember;
 import 
org.apache.geode.management.internal.cli.functions.GetStackTracesFunction;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
@@ -51,7 +49,8 @@
   private final GetStackTracesFunction getStackTracesFunction = new 
GetStackTracesFunction();
 
   /**
-   * Current implementation supports writing it to a file and returning the 
location of the file
+   * Current implementation supports writing it to a locator/server side file 
and returning the
+   * location of the file
    */
   @CliCommand(value = CliStrings.EXPORT_STACKTRACE, help = 
CliStrings.EXPORT_STACKTRACE__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
@@ -68,55 +67,43 @@ public Result exportStackTrace(@CliOption(key = 
{CliStrings.MEMBER, CliStrings.M
           help = CliStrings.EXPORT_STACKTRACE__FILE__HELP) String fileName,
 
       @CliOption(key = CliStrings.EXPORT_STACKTRACE__FAIL__IF__FILE__PRESENT,
-          unspecifiedDefaultValue = "false",
-          help = CliStrings.EXPORT_STACKTRACE__FAIL__IF__FILE__PRESENT__HELP) 
boolean failIfFilePresent) {
-
-    Result result;
-    StringBuilder filePrefix = new StringBuilder("stacktrace");
+          unspecifiedDefaultValue = "false", specifiedDefaultValue = "true",
+          help = CliStrings.EXPORT_STACKTRACE__FAIL__IF__FILE__PRESENT__HELP) 
boolean failIfFilePresent)
+      throws IOException {
 
     if (fileName == null) {
+      StringBuilder filePrefix = new StringBuilder("stacktrace");
       fileName = 
filePrefix.append("_").append(System.currentTimeMillis()).toString();
     }
     final File outFile = new File(fileName);
-    try {
-      if (outFile.exists() && failIfFilePresent) {
-        return ResultBuilder.createShellClientErrorResult(CliStrings.format(
-            CliStrings.EXPORT_STACKTRACE__ERROR__FILE__PRESENT, 
outFile.getCanonicalPath()));
-      }
-
 
-      InternalCache cache = getCache();
-      InternalDistributedSystem ads = cache.getInternalDistributedSystem();
+    if (outFile.exists() && failIfFilePresent) {
+      return ResultBuilder.createUserErrorResult(CliStrings
+          .format(CliStrings.EXPORT_STACKTRACE__ERROR__FILE__PRESENT, 
outFile.getCanonicalPath()));
+    }
 
-      InfoResultData resultData = ResultBuilder.createInfoResultData();
+    Map<String, byte[]> dumps = new HashMap<>();
+    Set<DistributedMember> targetMembers = getMembers(group, memberNameOrId);
 
-      Map<String, byte[]> dumps = new HashMap<>();
-      Set<DistributedMember> targetMembers = CliUtil.findMembers(group, 
memberNameOrId);
-      if (targetMembers.isEmpty()) {
-        return 
ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
-      }
+    InfoResultData resultData = ResultBuilder.createInfoResultData();
 
-      ResultCollector<?, ?> rc =
-          CliUtil.executeFunction(getStackTracesFunction, null, targetMembers);
-      ArrayList<Object> resultList = (ArrayList<Object>) rc.getResult();
+    ResultCollector<?, ?> rc = executeFunction(getStackTracesFunction, null, 
targetMembers);
+    ArrayList<Object> resultList = (ArrayList<Object>) rc.getResult();
 
-      for (Object resultObj : resultList) {
-        if (resultObj instanceof StackTracesPerMember) {
-          StackTracesPerMember stackTracePerMember = (StackTracesPerMember) 
resultObj;
-          dumps.put(stackTracePerMember.getMemberNameOrId(), 
stackTracePerMember.getStackTraces());
-        }
+    for (Object resultObj : resultList) {
+      if (resultObj instanceof StackTracesPerMember) {
+        StackTracesPerMember stackTracePerMember = (StackTracesPerMember) 
resultObj;
+        dumps.put(stackTracePerMember.getMemberNameOrId(), 
stackTracePerMember.getStackTraces());
       }
+    }
 
-      String filePath = writeStacksToFile(dumps, fileName);
-      
resultData.addLine(CliStrings.format(CliStrings.EXPORT_STACKTRACE__SUCCESS, 
filePath));
-      resultData.addLine(CliStrings.EXPORT_STACKTRACE__HOST + 
ads.getDistributedMember().getHost());
+    InternalDistributedSystem ads = getCache().getInternalDistributedSystem();
+    String filePath = writeStacksToFile(dumps, fileName);
+    
resultData.addLine(CliStrings.format(CliStrings.EXPORT_STACKTRACE__SUCCESS, 
filePath));
+    resultData.addLine(CliStrings.EXPORT_STACKTRACE__HOST + 
ads.getDistributedMember().getHost());
+
+    return ResultBuilder.buildResult(resultData);
 
-      result = ResultBuilder.buildResult(resultData);
-    } catch (IOException ex) {
-      result = ResultBuilder
-          .createGemFireErrorResult(CliStrings.EXPORT_STACKTRACE__ERROR + 
ex.getMessage());
-    }
-    return result;
   }
 
   /***
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStackTraceCommandDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStackTraceCommandDUnitTest.java
new file mode 100644
index 0000000000..eb7ed07389
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStackTraceCommandDUnitTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.geode.management.internal.cli.commands;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+
+
+@Category(DistributedTest.class)
+public class ExportStackTraceCommandDUnitTest {
+
+  @ClassRule
+  public static LocatorServerStartupRule lsRule = new 
LocatorServerStartupRule();
+
+  @Rule
+  public GfshCommandRule gfsh = new GfshCommandRule();
+
+  private static MemberVM locator;
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    locator = lsRule.startLocatorVM(0);
+    lsRule.startServerVM(1, locator.getPort());
+  }
+
+  @Before
+  public void before() throws Exception {
+    gfsh.connectAndVerify(locator);
+  }
+
+  @Test
+  public void exportStackTrace_no_file() {
+    gfsh.executeAndAssertThat("export stack-traces").statusIsSuccess()
+        .containsOutput("stack-trace(s) exported to file").containsOutput("On 
host : ");
+    File[] files = locator.getWorkingDir().listFiles(x -> 
x.getName().startsWith("stacktrace_"));
+    assertThat(files.length).isEqualTo(1);
+    // delete this file afterwards so that we won't pollute the other tests in 
this class
+    files[0].delete();
+  }
+
+  @Test
+  public void exportStackTrace_on_one_member() {
+    gfsh.executeAndAssertThat("export stack-traces 
--member=server-1").statusIsSuccess()
+        .containsOutput("stack-trace(s) exported to file").containsOutput("On 
host : ");
+    File[] files = locator.getWorkingDir().listFiles(x -> 
x.getName().startsWith("stacktrace_"));
+    assertThat(files.length).isEqualTo(1);
+    // delete this file afterwards so that we won't pollute the other tests in 
this class
+    files[0].delete();
+  }
+
+  @Test
+  public void exportStackTrace_with_file() {
+    File stackTraceFile = new File(locator.getWorkingDir(), "my_file");
+    gfsh.executeAndAssertThat("export stack-traces --file=" + 
stackTraceFile.getAbsolutePath())
+        .statusIsSuccess().containsOutput("stack-trace(s) exported to file");
+
+    // make sure file exists afterwards
+    File[] files = locator.getWorkingDir().listFiles(x -> 
x.getName().startsWith("my_file"));
+    assertThat(files.length).isEqualTo(1);
+
+    // execute the command again with the abort flag
+    gfsh.executeAndAssertThat(
+        "export stack-traces --abort-if-file-exists --file=" + 
stackTraceFile.getAbsolutePath())
+        .statusIsError().containsOutput("already present");
+
+    // execute the command again without the abort flag
+    gfsh.executeAndAssertThat("export stack-traces --file=" + 
stackTraceFile.getAbsolutePath())
+        .statusIsSuccess().containsOutput("stack-trace(s) exported to file");
+    // make sure the file is overwritten
+    files = locator.getWorkingDir().listFiles(x -> 
x.getName().startsWith("my_file"));
+    assertThat(files.length).isEqualTo(1);
+
+    // delete this file afterwards so that we won't pollute the other tests in 
this class
+    files[0].delete();
+  }
+}
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStackTraceCommandTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStackTraceCommandTest.java
new file mode 100644
index 0000000000..521e50d9ec
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStackTraceCommandTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.geode.management.internal.cli.commands;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.geode.test.junit.rules.GfshParserRule;
+
+
+@Category(UnitTest.class)
+public class ExportStackTraceCommandTest {
+
+  @ClassRule
+  public static GfshParserRule gfsh = new GfshParserRule();
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  private ExportStackTraceCommand command;
+
+  @Before
+  public void before() {
+    command = spy(ExportStackTraceCommand.class);
+  }
+
+  @Test
+  public void noMemberFound() {
+    doReturn(Collections.emptySet()).when(command).findMembers(any(), any());
+    gfsh.executeAndAssertThat(command, "export stack-traces").statusIsError()
+        .containsOutput("No Members Found");
+  }
+
+  @Test
+  public void abortIfFileExists() throws IOException {
+    File file = temporaryFolder.newFile("stackTrace.txt");
+    gfsh.executeAndAssertThat(command,
+        "export stack-traces --abort-if-file-exists --file=" + 
file.getAbsolutePath())
+        .statusIsError().containsOutput("already present");
+
+    // try again without the flag, the command should continue after the check
+    doReturn(Collections.emptySet()).when(command).findMembers(any(), any());
+    gfsh.executeAndAssertThat(command, "export stack-traces --file=" + 
file.getAbsolutePath())
+        .statusIsError().containsOutput("No Members Found");
+  }
+}
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowStackTraceDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowStackTraceDUnitTest.java
deleted file mode 100644
index b8b96be180..0000000000
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowStackTraceDUnitTest.java
+++ /dev/null
@@ -1,269 +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.geode.management.internal.cli.commands;
-
-import static 
org.apache.geode.distributed.ConfigurationProperties.ENABLE_TIME_STATISTICS;
-import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static 
org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLING_ENABLED;
-import static org.apache.geode.test.dunit.Assert.assertFalse;
-import static org.apache.geode.test.dunit.Assert.assertTrue;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
-
-import org.apache.geode.management.cli.Result.Status;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.json.GfJsonException;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.SerializableRunnable;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
-import 
org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
-
-/**
- * DUnit test for 'show stack-trace' command
- */
-@Category({DistributedTest.class, FlakyTest.class}) // GEODE-3530
-@SuppressWarnings("serial")
-public class ShowStackTraceDUnitTest extends CliCommandTestBase {
-
-  @Rule
-  public TemporaryFolder workDirectory = new SerializableTemporaryFolder();
-
-  private void createCache(Properties props) {
-    getSystem(props);
-    getCache();
-  }
-
-  private Properties createProperties(Host host, String name, String groups) {
-    Properties props = new Properties();
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(LOG_LEVEL, "info");
-    props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
-    props.setProperty(ENABLE_TIME_STATISTICS, "true");
-    props.setProperty(NAME, name);
-    props.setProperty(GROUPS, groups);
-    return props;
-  }
-
-  /***
-   * Sets up a system of 3 peers
-   */
-  private void setupSystem() {
-    disconnectAllFromDS();
-    final Host host = Host.getHost(0);
-    final VM[] servers = {host.getVM(0), host.getVM(1)};
-
-    final Properties propsManager = createProperties(host, "Manager", "G1");
-    final Properties propsServer2 = createProperties(host, "Server", "G2");
-
-    setUpJmxManagerOnVm0ThenConnect(propsManager);
-
-    servers[1].invoke(new SerializableRunnable("Create cache for server1") {
-      public void run() {
-        createCache(propsServer2);
-      }
-    });
-  }
-
-  /***
-   * Tests the default behavior of the show stack-trace command
-   *
-   * @throws ClassNotFoundException
-   * @throws IOException
-   */
-  @Test
-  public void testExportStacktrace() throws ClassNotFoundException, 
IOException {
-    setupSystem();
-
-    File allStacktracesFile = workDirectory.newFile("allStackTraces.txt");
-    CommandStringBuilder csb = new 
CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
-    csb.addOption(CliStrings.EXPORT_STACKTRACE__FILE, 
allStacktracesFile.getCanonicalPath());
-    String commandString = csb.toString();
-    getLogWriter().info("CommandString : " + commandString);
-    CommandResult commandResult = executeCommand(commandString);
-    getLogWriter().info("Output : \n" + commandResultToString(commandResult));
-    assertTrue(commandResult.getStatus().equals(Status.OK));
-
-    File mgrStacktraceFile = workDirectory.newFile("managerStacktrace.txt");
-    csb = new CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
-    csb.addOption(CliStrings.EXPORT_STACKTRACE__FILE, 
mgrStacktraceFile.getCanonicalPath());
-    csb.addOption(CliStrings.MEMBER, "Manager");
-    commandString = csb.toString();
-    getLogWriter().info("CommandString : " + commandString);
-    commandResult = executeCommand(commandString);
-    getLogWriter().info("Output : \n" + commandResultToString(commandResult));
-    assertTrue(commandResult.getStatus().equals(Status.OK));
-
-    File serverStacktraceFile = workDirectory.newFile("serverStacktrace.txt");
-    csb = new CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
-    csb.addOption(CliStrings.EXPORT_STACKTRACE__FILE, 
serverStacktraceFile.getCanonicalPath());
-    csb.addOption(CliStrings.MEMBER, "Server");
-    commandString = csb.toString();
-    getLogWriter().info("CommandString : " + commandString);
-    commandResult = executeCommand(commandString);
-    getLogWriter().info("Output : \n" + commandResultToString(commandResult));
-    assertTrue(commandResult.getStatus().equals(Status.OK));
-
-    File groupStacktraceFile = workDirectory.newFile("groupstacktrace.txt");
-    csb = new CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
-    csb.addOption(CliStrings.EXPORT_STACKTRACE__FILE, 
groupStacktraceFile.getCanonicalPath());
-    csb.addOption(CliStrings.GROUP, "G2");
-    commandString = csb.toString();
-    getLogWriter().info("CommandString : " + commandString);
-    commandResult = executeCommand(commandString);
-    getLogWriter().info("Output : \n" + commandResultToString(commandResult));
-    assertTrue(commandResult.getStatus().equals(Status.OK));
-
-    File wrongStackTraceFile = workDirectory.newFile("wrongStackTrace.txt");
-    csb = new CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
-    csb.addOption(CliStrings.EXPORT_STACKTRACE__FILE, 
wrongStackTraceFile.getCanonicalPath());
-    csb.addOption(CliStrings.MEMBER, "WrongMember");
-    commandString = csb.toString();
-    getLogWriter().info("CommandString : " + commandString);
-    commandResult = executeCommand(commandString);
-    getLogWriter().info("Output : \n" + commandResultToString(commandResult));
-    assertFalse(commandResult.getStatus().equals(Status.OK));
-  }
-
-  /***
-   * Tests the behavior of the show stack-trace command to verify that files 
with any extension are
-   * allowed Refer: GEODE-734
-   *
-   * @throws ClassNotFoundException
-   * @throws IOException
-   */
-  @Test
-  public void testExportStacktraceWithNonTXTFile() throws 
ClassNotFoundException, IOException {
-    setupSystem();
-
-    // Test non txt extension file is allowed
-    File stacktracesFile = workDirectory.newFile("allStackTraces.log");
-    CommandStringBuilder commandStringBuilder =
-        new CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
-    commandStringBuilder.addOption(CliStrings.EXPORT_STACKTRACE__FILE,
-        stacktracesFile.getCanonicalPath());
-    String exportCommandString = commandStringBuilder.toString();
-    getLogWriter().info("CommandString : " + exportCommandString);
-    CommandResult exportCommandResult = executeCommand(exportCommandString);
-    getLogWriter().info("Output : \n" + 
commandResultToString(exportCommandResult));
-    assertTrue(exportCommandResult.getStatus().equals(Status.OK));
-
-    // test file with-out any extension
-    File allStacktracesFile = workDirectory.newFile("allStackTraces");
-    commandStringBuilder = new 
CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
-    commandStringBuilder.addOption(CliStrings.EXPORT_STACKTRACE__FILE,
-        allStacktracesFile.getCanonicalPath());
-    exportCommandString = commandStringBuilder.toString();
-    getLogWriter().info("CommandString : " + exportCommandString);
-    exportCommandResult = executeCommand(exportCommandString);
-    getLogWriter().info("Output : \n" + 
commandResultToString(exportCommandResult));
-    assertTrue(exportCommandResult.getStatus().equals(Status.OK));
-  }
-
-  /***
-   * Tests the behavior of the show stack-trace command when file is already 
present and
-   * abort-if-file-exists option is set to false(which is default). As a 
result it should overwrite
-   * the file and return OK status
-   *
-   * @throws ClassNotFoundException
-   * @throws IOException
-   */
-  @Test
-  public void testExportStacktraceWhenFilePresent() throws 
ClassNotFoundException, IOException {
-    setupSystem();
-
-    // test pass although file present
-    File stacktracesFile = workDirectory.newFile("allStackTraces.log");
-    CommandStringBuilder commandStringBuilder =
-        new CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
-    commandStringBuilder.addOption(CliStrings.EXPORT_STACKTRACE__FILE,
-        stacktracesFile.getCanonicalPath());
-    String exportCommandString = commandStringBuilder.toString();
-    getLogWriter().info("CommandString : " + exportCommandString);
-    CommandResult exportCommandResult = executeCommand(exportCommandString);
-    getLogWriter().info("Output : \n" + 
commandResultToString(exportCommandResult));
-    assertTrue(exportCommandResult.getStatus().equals(Status.OK));
-
-  }
-
-  /***
-   * Tests the behavior of the show stack-trace command when file is already 
present and when
-   * abort-if-file-exists option is set to true. As a result it should fail 
with ERROR status
-   *
-   * @throws ClassNotFoundException
-   * @throws IOException
-   */
-  @Test
-  public void testExportStacktraceFilePresentWithAbort()
-      throws ClassNotFoundException, IOException, GfJsonException {
-    setupSystem();
-
-    File stacktracesFile = workDirectory.newFile("allStackTraces.log");
-    CommandStringBuilder commandStringBuilder =
-        new CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
-    commandStringBuilder.addOption(CliStrings.EXPORT_STACKTRACE__FILE,
-        stacktracesFile.getCanonicalPath());
-    
commandStringBuilder.addOption(CliStrings.EXPORT_STACKTRACE__FAIL__IF__FILE__PRESENT,
-        Boolean.TRUE.toString());
-    String exportCommandString = commandStringBuilder.toString();
-    getLogWriter().info("CommandString : " + exportCommandString);
-    CommandResult exportCommandResult = executeCommand(exportCommandString);
-    getLogWriter().info("Output : \n" + 
commandResultToString(exportCommandResult));
-    assertTrue(exportCommandResult.getStatus().equals(Status.ERROR));
-    assertTrue(((String) exportCommandResult.getResultData().getGfJsonObject()
-        .getJSONObject("content").getJSONArray("message").get(0))
-            .contains("file " + stacktracesFile.getCanonicalPath() + " already 
present"));
-  }
-
-  /***
-   * Tests the behavior of the show stack-trace command when file option is 
not provided File should
-   * get auto-generated
-   *
-   * @throws ClassNotFoundException
-   * @throws IOException
-   */
-  @Test
-  public void testExportStacktraceAutoGenerateFile()
-      throws ClassNotFoundException, IOException, GfJsonException {
-    setupSystem();
-
-    // test auto generated file when file name is not provided
-    CommandStringBuilder commandStringBuilder =
-        new CommandStringBuilder(CliStrings.EXPORT_STACKTRACE);
-    String exportCommandString = commandStringBuilder.toString();
-    getLogWriter().info("CommandString : " + exportCommandString);
-    CommandResult exportCommandResult = executeCommand(exportCommandString);
-    getLogWriter().info("Output : \n" + 
commandResultToString(exportCommandResult));
-    assertTrue(exportCommandResult.getStatus().equals(Status.OK));
-    assertTrue(
-        ((String) 
exportCommandResult.getResultData().getGfJsonObject().getJSONObject("content")
-            .getJSONArray("message").get(0)).contains("stack-trace(s) exported 
to file:"));
-
-  }
-}
diff --git 
a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
 
b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
index 99f0b1090e..3ce3e5abc6 100644
--- 
a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
+++ 
b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
@@ -29,8 +29,7 @@
  */
 @Category({DistributedTest.class, SecurityTest.class})
 @RunWith(SuiteRunner.class)
[email protected]({GemfireDataCommandsDUnitTest.class, 
ShellCommandsDUnitTest.class,
-    ShowStackTraceDUnitTest.class})
[email protected]({GemfireDataCommandsDUnitTest.class, 
ShellCommandsDUnitTest.class})
 public class CommandOverHttpDUnitTest {
   @ClassRule
   public static ProvideSystemProperty provideSystemProperty =


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Add more test coverage for p2p commands
> ---------------------------------------
>
>                 Key: GEODE-3539
>                 URL: https://issues.apache.org/jira/browse/GEODE-3539
>             Project: Geode
>          Issue Type: Improvement
>          Components: gfsh
>            Reporter: Jinmei Liao
>
> Add more command tests that would eventually get rid of the legacy tests.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to