You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/05/03 00:42:15 UTC

incubator-geode git commit: Test cleanup

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1255 8b83be64c -> ed244d56e


Test cleanup


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

Branch: refs/heads/feature/GEODE-1255
Commit: ed244d56ed98a95fdce9d6afa9af1cc11c01ddce
Parents: 8b83be6
Author: Kirk Lund <kl...@apache.org>
Authored: Mon May 2 15:42:03 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon May 2 15:42:03 2016 -0700

----------------------------------------------------------------------
 .../SharedConfigurationEndToEndDUnitTest.java   | 60 ++++++++-----
 .../gemstone/gemfire/internal/ClassBuilder.java |  2 +-
 .../management/internal/cli/HeadlessGfsh.java   | 23 ++---
 .../cli/HeadlessGfshIntegrationTest.java        | 90 ++++++++++++++++++++
 .../internal/cli/HeadlessGfshJUnitTest.java     | 85 ------------------
 .../cli/commands/CliCommandTestBase.java        | 27 +++++-
 .../cli/commands/DeployCommandsDUnitTest.java   |  2 +-
 ...WithCacheLoaderDuringCacheMissDUnitTest.java |  2 +-
 ...stAndDescribeDiskStoreCommandsDUnitTest.java |  2 +-
 .../cli/commands/ListIndexCommandDUnitTest.java |  2 +-
 .../cli/commands/ShellCommandsDUnitTest.java    |  2 +-
 .../cli/commands/UserCommandsDUnitTest.java     |  2 +-
 12 files changed, 167 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
index 9e2e94a..2998722 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
@@ -24,6 +24,7 @@ import static com.gemstone.gemfire.internal.lang.StringUtils.*;
 import static com.gemstone.gemfire.management.internal.cli.CliUtil.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.Host.*;
+import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 import static com.gemstone.gemfire.test.dunit.Wait.*;
 
@@ -55,7 +56,6 @@ import com.gemstone.gemfire.management.internal.cli.commands.CliCommandTestBase;
 import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
 import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
 import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
@@ -75,34 +75,45 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
 
   private transient ClassBuilder classBuilder = new ClassBuilder();
 
-  // TODO: move setup and teardown to @Before and @After
+  private transient String jmxHost;
+  private transient int jmxPort;
+  private transient int httpPort;
+  private transient String locatorString;
+
+  @Override
+  public final void postSetUpCliCommandTestBase() throws Exception {
+    disconnectAllFromDS();
+
+    addIgnoredException("EntryDestroyedException");
 
-  @Test
-  public void testStartServerAndExecuteCommands() throws Exception {
-    IgnoredException.addIgnoredException("EntryDestroyedException");
     Object[] result = setup();
-    final int locatorPort = (Integer) result[0];
-    final String jmxHost = (String) result[1];
-    final int jmxPort = (Integer) result[2];
-    final int httpPort = (Integer) result[3];
-    final String locatorString = "localHost[" + locatorPort + "]";
+    int locatorPort = (Integer) result[0];
+
+    this.jmxHost = (String) result[1];
+    this.jmxPort = (Integer) result[2];
+    this.httpPort = (Integer) result[3];
+    this.locatorString = "localHost[" + locatorPort + "]";
+  }
 
-    final HeadlessGfsh gfsh = new HeadlessGfsh("gfsh2", 300);
+  public final void preTearDownCliCommandTestBase() throws Exception {
+    //shutdown everything
+    shutdownAll();
+  }
+
+  @Test
+  public void testStartServerAndExecuteCommands() throws Exception {
+    final HeadlessGfsh gfsh = new HeadlessGfsh("gfsh2", 300, this.gfshDir);
     assertNotNull(gfsh);
     shellConnect(jmxHost, jmxPort, httpPort, gfsh);
 
     serverNames.addAll(startServers(gfsh, locatorString, 2, "Server", 1));
     doCreateCommands();
     serverNames.addAll(startServers(gfsh, locatorString, 1, "NewMember", 4));
+
     verifyRegionCreateOnAllMembers(REGION1);
     verifyRegionCreateOnAllMembers(REGION2);
     verifyIndexCreationOnAllMembers(INDEX1);
     verifyAsyncEventQueueCreation();
-
-    //shutdown everything
-    getLogWriter().info("Shutting down all the members");
-    shutdownAll();
-    deleteSavedJarFiles();
   }
 
   private Set<String> startServers(final HeadlessGfsh gfsh, final String locatorString, final int numServers, final String serverNamePrefix, final int startNum) throws ClassNotFoundException, IOException {
@@ -112,11 +123,14 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     for (int i=0; i<numServers; i++) {
       int port = serverPorts[i];
       String serverName = serverNamePrefix+ Integer.toString(i+startNum) + "-" + port;
+
       CommandStringBuilder csb = new CommandStringBuilder(CliStrings.START_SERVER);
       csb.addOption(CliStrings.START_SERVER__NAME, serverName);
       csb.addOption(CliStrings.START_SERVER__LOCATORS, locatorString);
       csb.addOption(CliStrings.START_SERVER__SERVER_PORT, Integer.toString(port));
+
       CommandResult cmdResult = executeCommand(gfsh, csb.getCommandString());
+
       assertEquals(Status.OK, cmdResult.getStatus());
     }
     return serverNames;
@@ -126,7 +140,7 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     createRegion(REGION1, REPLICATE, null);
     createRegion(REGION2, PARTITION, null);
     createIndex(INDEX1 , "AAPL", REGION1, null);
-    createAndDeployJar("Deploy1.jar");
+    createAndDeployJar(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + "Deploy1.jar");
     createAsyncEventQueue("q1");
     final String autoCompact = "true";
     final String allowForceCompaction = "true";
@@ -286,13 +300,14 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     delete(new File("Deploy1.jar"));
   }
 
-  private Object[] setup() {
-    disconnectAllFromDS();
+  private Object[] setup() throws IOException {
     final int [] ports = getRandomAvailableTCPPorts(3);
     final int locator1Port = ports[0];
+
     final String locator1Name = "locator1-" + locator1Port;
-    VM locatorAndMgr = getHost(0).getVM(3);
+    final String locatorLogPath = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + "locator-" + locator1Port + ".log";
 
+    VM locatorAndMgr = getHost(0).getVM(3);
     Object[] result = (Object[]) locatorAndMgr.invoke(new SerializableCallable() {
       @Override
       public Object call() throws IOException {
@@ -312,7 +327,7 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
         jmxPort = ports[0];
         httpPort = ports[1];
 
-        final File locatorLogFile = new File("locator-" + locator1Port + ".log");
+        final File locatorLogFile = new File(locatorLogPath);
 
         final Properties locatorProps = new Properties();
         locatorProps.setProperty(NAME_NAME, locator1Name);
@@ -326,12 +341,12 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
         locatorProps.setProperty(HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
 
         final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null, locatorProps);
+
         WaitCriterion wc = new WaitCriterion() {
           @Override
           public boolean done() {
             return locator.isSharedConfigurationRunning();
           }
-
           @Override
           public String description() {
             return "Waiting for shared configuration to be started";
@@ -354,6 +369,7 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     int httpPort = (Integer)result[3];
 
     shellConnect(jmxHost, jmxPort, httpPort, gfsh);
+
     // Create a cache in VM 1
     VM dataMember = getHost(0).getVM(1);
     dataMember.invoke(new SerializableCallable() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/internal/ClassBuilder.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/ClassBuilder.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/ClassBuilder.java
index 780ed4f..97062e5 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/ClassBuilder.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/ClassBuilder.java
@@ -40,7 +40,7 @@ import javax.tools.SimpleJavaFileObject;
 import javax.tools.ToolProvider;
 
 /**
- * Test framework utility class to programatically create classes, JARs and ClassLoaders that include the classes.
+ * Test framework utility class to programmatically create classes, JARs and ClassLoaders that include the classes.
  * 
  * @since 7.0
  */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfsh.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfsh.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfsh.java
index 2835731..1f2d11c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfsh.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfsh.java
@@ -23,16 +23,12 @@ import jline.console.ConsoleReader;
 import org.springframework.shell.core.ExitShellRequest;
 import org.springframework.shell.event.ShellStatus.Status;
 
-import java.io.BufferedWriter;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileDescriptor;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.io.OutputStreamWriter;
 import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.Writer;
 import java.util.Properties;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -60,14 +56,14 @@ public class HeadlessGfsh implements ResultHandler {
   private long timeout = 20;
   public String outputString = null;
 
-  public HeadlessGfsh(String name, int timeout) throws ClassNotFoundException, IOException {
-    this(name, timeout, null);
+  public HeadlessGfsh(String name, int timeout, String parentDir) throws ClassNotFoundException, IOException {
+    this(name, timeout, null, parentDir);
   }
 
-  public HeadlessGfsh(String name, int timeout, Properties envProps) throws ClassNotFoundException, IOException {
+  public HeadlessGfsh(String name, int timeout, Properties envProps, String parentDir) throws ClassNotFoundException, IOException {
     this.timeout = timeout;
     System.setProperty("jline.terminal", GfshUnsupportedTerminal.class.getName());
-    this.shell = new HeadlessGfshShell(name, this);
+    this.shell = new HeadlessGfshShell(name, this, parentDir);
     this.shell.setEnvProperty(Gfsh.ENV_APP_RESULT_VIEWER, "non-basic");
 
     if (envProps != null) {
@@ -175,8 +171,8 @@ public class HeadlessGfsh implements ResultHandler {
     private boolean hasError = false;
     boolean stopCalledThroughAPI = false;
 
-    protected HeadlessGfshShell(String testName, ResultHandler handler) throws ClassNotFoundException, IOException {
-      super(false, new String[]{}, new HeadlessGfshConfig(testName));
+    protected HeadlessGfshShell(String testName, ResultHandler handler, String parentDir) throws ClassNotFoundException, IOException {
+      super(false, new String[]{}, new HeadlessGfshConfig(testName, parentDir));
       this.handler = handler;
     }
 
@@ -297,7 +293,6 @@ public class HeadlessGfsh implements ResultHandler {
     }
   }
 
-
   /**
    * HeadlessGfshConfig for tests. Taken from TestableGfsh
    */
@@ -312,7 +307,7 @@ public class HeadlessGfsh implements ResultHandler {
     private String name;
     private String generatedHistoryFileName = null;
 
-    public HeadlessGfshConfig(String name) {
+    public HeadlessGfshConfig(String name, String parentDir) {
       this.name = name;
 
       if (isDUnitTest(this.name)) {
@@ -321,8 +316,8 @@ public class HeadlessGfsh implements ResultHandler {
         fileNamePrefix = "non-hydra-client";
       }
 
-      parentDir = new File("gfsh_files");
-      parentDir.mkdirs();
+      this.parentDir = new File(parentDir);
+      this.parentDir.mkdirs();
     }
 
     private static boolean isDUnitTest(String name) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfshIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfshIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfshIntegrationTest.java
new file mode 100644
index 0000000..05b2d8e
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfshIntegrationTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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 com.gemstone.gemfire.management.internal.cli;
+
+import static org.junit.Assert.*;
+
+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.junit.rules.TestName;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * TODO : Add more tests for error-catch, different type of results etc
+ */
+@Category(IntegrationTest.class)
+public class HeadlessGfshIntegrationTest {
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Rule
+  public TestName testName = new TestName();
+
+  @SuppressWarnings({"deprecation"})
+  @Test
+  public void testHeadlessGfshTest() throws ClassNotFoundException, IOException, InterruptedException {
+    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+
+    Properties properties = new Properties();
+    properties.put(DistributionConfig.NAME_NAME, this.testName.getMethodName());
+    properties.put(DistributionConfig.JMX_MANAGER_NAME, "true");
+    properties.put(DistributionConfig.JMX_MANAGER_START_NAME, "true");
+    properties.put(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(port));
+    properties.put(DistributionConfig.HTTP_SERVICE_PORT_NAME, "0");
+    properties.put(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    DistributedSystem ds = DistributedSystem.connect(properties);
+    GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.create(ds);
+
+    HeadlessGfsh gfsh = new HeadlessGfsh("Test", 25, this.temporaryFolder.newFolder("gfsh_files").getCanonicalPath());
+    for (int i = 0; i < 5; i++) {
+      gfsh.executeCommand("connect --jmx-manager=localhost[" + port + "]");
+      Object result = gfsh.getResult();
+      assertTrue(gfsh.isConnectedAndReady());
+      assertNotNull(result);
+      gfsh.clear();
+      gfsh.executeCommand("list members");
+      result = gfsh.getResult();
+      assertNotNull(result);
+      gfsh.executeCommand("disconnect");
+      gfsh.getResult();
+    }
+
+    long l1 = System.currentTimeMillis();
+    gfsh.executeCommand("exit");
+    long l2 = System.currentTimeMillis();
+    gfsh.getResult();
+    long l3 = System.currentTimeMillis();
+    System.out.println("L3-l2=" + (l3 - l2) + " Total time= " + (l3 - l1) / 1000);
+    gfsh.terminate();
+    cache.close();
+    ds.disconnect();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfshJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfshJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfshJUnitTest.java
deleted file mode 100644
index 86fe03e..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/HeadlessGfshJUnitTest.java
+++ /dev/null
@@ -1,85 +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 com.gemstone.gemfire.management.internal.cli;
-
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.management.internal.MBeanJMXAdapter;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import javax.management.ObjectName;
-import java.io.IOException;
-import java.util.Properties;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * TODO : Add more tests for error-catch, different type of results etc
- *
- */
-@Category(IntegrationTest.class)
-public class HeadlessGfshJUnitTest {
-
-  @SuppressWarnings({"deprecation"})
-  @Test
-  public void testHeadlessGfshTest() throws ClassNotFoundException, IOException, InterruptedException {
-    GemFireCacheImpl cache = null;
-    DistributedSystem ds = null;
-    Properties pr = new Properties();
-    pr.put("name", "testHeadlessGfshTest");
-    pr.put(DistributionConfig.JMX_MANAGER_NAME, "true");
-    pr.put(DistributionConfig.JMX_MANAGER_START_NAME, "true");
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    pr.put(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(port));
-    pr.put(DistributionConfig.HTTP_SERVICE_PORT_NAME, "0");
-    pr.put(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    ds = DistributedSystem.connect(pr);
-    cache = (GemFireCacheImpl) CacheFactory.create(ds);
-
-    HeadlessGfsh gfsh = new HeadlessGfsh("Test", 25);
-    for (int i = 0; i < 5; i++) {
-      gfsh.executeCommand("connect --jmx-manager=localhost[" + port + "]");
-      Object result = gfsh.getResult();
-      assertTrue(gfsh.isConnectedAndReady());
-      assertNotNull(result);
-      gfsh.clear();
-      gfsh.executeCommand("list members");
-      result = gfsh.getResult();
-      assertNotNull(result);
-      gfsh.executeCommand("disconnect");
-      gfsh.getResult();
-    }
-
-    long l1 = System.currentTimeMillis();
-    gfsh.executeCommand("exit");
-    long l2 = System.currentTimeMillis();
-    gfsh.getResult();
-    long l3 = System.currentTimeMillis();
-    System.out.println("L3-l2=" + (l3 - l2) + " Total time= " + (l3 - l1) / 1000);
-    gfsh.terminate();
-    cache.close();
-    ds.disconnect();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
index acb07ca..0ab68c8 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
@@ -42,6 +42,9 @@ import java.util.regex.Pattern;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter;
 
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
 /**
  * Base class for all the CLI/gfsh command dunit tests.
  */
@@ -57,10 +60,26 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
 
   private boolean useHttpOnConnect = Boolean.getBoolean("useHTTP");
 
-  private int httpPort;
-  private int jmxPort;
+  private transient int httpPort;
+  private transient int jmxPort;
+  private transient String jmxHost;
+  protected transient String gfshDir;
+
+  @Rule
+  public transient TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Override
+  public final void postSetUp() throws Exception {
+    setUpCliCommandTestBase();
+    postSetUpCliCommandTestBase();
+  }
+
+  private void setUpCliCommandTestBase() throws Exception {
+    this.gfshDir = this.temporaryFolder.newFolder("gfsh_files").getCanonicalPath();
+  }
 
-  private String jmxHost;
+  protected void postSetUpCliCommandTestBase() throws Exception {
+  }
 
   @Override
   public final void preTearDownCacheTestCase() throws Exception {
@@ -250,7 +269,7 @@ public abstract class CliCommandTestBase extends JUnit4CacheTestCase {
     try {
       Gfsh.SUPPORT_MUTLIPLESHELL = true;
       String shellId = getClass().getSimpleName() + "_" + getName();
-      HeadlessGfsh shell = new HeadlessGfsh(shellId, 30);
+      HeadlessGfsh shell = new HeadlessGfsh(shellId, 30, this.gfshDir);
       //Added to avoid trimming of the columns
       info("Started testable shell: " + shell);
       return shell;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommandsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommandsDUnitTest.java
index fee3978..40e61d7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommandsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/DeployCommandsDUnitTest.java
@@ -63,7 +63,7 @@ public class DeployCommandsDUnitTest extends CliCommandTestBase {
   transient private CommandProcessor commandProcessor;
 
   @Override
-  public final void postSetUp() throws Exception {
+  public final void postSetUpCliCommandTestBase() throws Exception {
     this.commandProcessor = new CommandProcessor();
     assertFalse(this.commandProcessor.isStopped());
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.java
index 19a354e..4d41189 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.java
@@ -90,7 +90,7 @@ public class GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest extends C
   }
 
   @Override
-  public final void postSetUp() throws Exception {
+  public final void postSetUpCliCommandTestBase() throws Exception {
     Properties managerDistributedSystemProperties = createDistributedSystemProperties(GEMFIRE_MANAGER_NAME);
     HeadlessGfsh gfsh = createDefaultSetup(managerDistributedSystemProperties);
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
index 6466033..6fbe62d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
@@ -65,7 +65,7 @@ public class ListAndDescribeDiskStoreCommandsDUnitTest extends CliCommandTestBas
   }
 
   @Override
-  public final void postSetUp() throws Exception {
+  public final void postSetUpCliCommandTestBase() throws Exception {
     createDefaultSetup(null);
     setupGemFire();
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListIndexCommandDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListIndexCommandDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListIndexCommandDUnitTest.java
index deb8860..3013ba6 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListIndexCommandDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListIndexCommandDUnitTest.java
@@ -86,7 +86,7 @@ public class ListIndexCommandDUnitTest extends CliCommandTestBase {
   }
 
   @Override
-  public final void postSetUp() throws Exception {
+  public final void postSetUpCliCommandTestBase() throws Exception {
     createDefaultSetup(null);
     setupGemFire();
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommandsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommandsDUnitTest.java
index 86f6dc8..2518b7d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommandsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommandsDUnitTest.java
@@ -46,7 +46,7 @@ public class ShellCommandsDUnitTest extends CliCommandTestBase {
   private static final long serialVersionUID = 1L;
 
   @Override
-  public final void postSetUp() throws Exception {
+  public final void postSetUpCliCommandTestBase() throws Exception {
     getDefaultShell();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ed244d56/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/UserCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/UserCommandsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/UserCommandsDUnitTest.java
index 3b4db25..9ab3fb4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/UserCommandsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/UserCommandsDUnitTest.java
@@ -53,7 +53,7 @@ public class UserCommandsDUnitTest extends CliCommandTestBase {
   boolean deleteJarDirectory = false;
 
   @Override
-  public final void postSetUp() throws Exception {
+  public final void postSetUpCliCommandTestBase() throws Exception {
     createUserCommandJarFile();
   }