geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zho...@apache.org
Subject [4/5] geode git commit: GEODE-3231: do not use temporary folder as workingdir or log to file by default when using the member starter rules
Date Fri, 21 Jul 2017 21:00:29 GMT
GEODE-3231: do not use temporary folder as workingdir or log to file by default when using the member starter rules

* do not create a workingDir and sets the user.dir by default for Locator/ServerStarterRule
* do not use a temp folder for all vms workingDir by default when using LocatorServerStarterRule.
* only bounce the vm when changing the workingdir of vms, otherwise, just cleanup the persisted files after each test.


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

Branch: refs/heads/feature/GEM-1483
Commit: 0ea489ea52bb8f04e50c396cb5a8c0629f82f075
Parents: 5551b3f
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Mon Jul 17 16:05:54 2017 -0700
Committer: Jinmei Liao <jiliao@pivotal.io>
Committed: Fri Jul 21 13:16:22 2017 -0700

----------------------------------------------------------------------
 .../DeployCommandRedeployDUnitTest.java         |  42 +++---
 .../cli/commands/DeployCommandsDUnitTest.java   |  31 +++--
 .../cli/commands/ExportLogsDUnitTest.java       |  45 +++----
 .../cli/commands/ExportLogsIntegrationTest.java |  14 +-
 .../ExportLogsOnServerManagerDUnit.java         |  18 +--
 .../cli/commands/ExportLogsStatsDUnitTest.java  |  34 ++---
 .../ExportLogsWithMemberGroupDUnitTest.java     |  34 ++---
 .../ShowMissingDiskStoresDUnitTest.java         |  40 ++----
 .../ExportLogsFunctionIntegrationTest.java      |  20 +--
 .../functions/SizeExportLogsFunctionTest.java   |  34 ++---
 .../cli/util/LogExporterIntegrationTest.java    |  22 ++--
 .../internal/cli/util/MergeLogsDUnitTest.java   |  33 ++---
 .../ClusterConfigDeployJarDUnitTest.java        |  13 +-
 .../ClusterConfigDistributionDUnitTest.java     |  25 ++--
 .../ClusterConfigImportDUnitTest.java           |  31 +++--
 .../ClusterConfigStartMemberDUnitTest.java      |  13 +-
 .../configuration/ClusterConfigTestBase.java    |  23 ++--
 .../ClusterConfigWithSecurityDUnitTest.java     |  25 ++--
 .../ImportClusterConfigDistributedTest.java     |  22 ++--
 .../security/MemberMBeanSecurityJUnitTest.java  |   4 +-
 .../ClusterConfigWithoutSecurityDUnitTest.java  |  15 ++-
 .../security/PDXPostProcessorDUnitTest.java     |  41 +++---
 .../security/PeerAuthenticatorDUnitTest.java    |  13 +-
 .../dunit/rules/LocatorServerStartupRule.java   | 129 +++++++++++++------
 .../test/dunit/rules/MemberStarterRule.java     |  68 ++++++++--
 .../apache/geode/test/dunit/rules/MemberVM.java |  43 ++++---
 .../test/dunit/rules/ServerStarterRule.java     |  24 +---
 .../dunit/rules/test/MemberStarterRuleTest.java |  48 ++++++-
 .../LuceneClusterConfigurationDUnitTest.java    |  21 +--
 ...nfigurationIndexWithFromClauseDUnitTest.java |  39 ++----
 .../internal/security/LogNoPasswordTest.java    |   2 +-
 31 files changed, 545 insertions(+), 421 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandRedeployDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandRedeployDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandRedeployDUnitTest.java
index e494bcd..40c1bd8 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandRedeployDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandRedeployDUnitTest.java
@@ -15,9 +15,25 @@
 package org.apache.geode.management.internal.cli.commands;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.commons.io.FileUtils;
+import org.awaitility.Awaitility;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.distributed.DistributedSystem;
@@ -28,22 +44,7 @@ import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 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.awaitility.Awaitility;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 
 @Category(DistributedTest.class)
 public class DeployCommandRedeployDUnitTest implements Serializable {
@@ -66,6 +67,9 @@ public class DeployCommandRedeployDUnitTest implements Serializable {
   private MemberVM server;
 
   @Rule
+  public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
+
+  @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
 
   @Rule
@@ -139,7 +143,7 @@ public class DeployCommandRedeployDUnitTest implements Serializable {
     classContents = classContents.replaceAll("FUNCTION_A", FUNCTION_A);
     classContents = classContents.replaceAll("VERSION", version);
 
-    File jar = new File(lsRule.getTempFolder().newFolder(JAR_NAME_A + version), this.JAR_NAME_A);
+    File jar = new File(temporaryFolder.newFolder(JAR_NAME_A + version), this.JAR_NAME_A);
     ClassBuilder functionClassBuilder = new ClassBuilder();
     functionClassBuilder.writeJarFromContent(FUNCTION_A, classContents, jar);
 
@@ -156,7 +160,7 @@ public class DeployCommandRedeployDUnitTest implements Serializable {
     classContents = classContents.replaceAll("FUNCTION_B", FUNCTION_B);
     classContents = classContents.replaceAll("VERSION", version);
 
-    File jar = new File(lsRule.getTempFolder().newFolder(JAR_NAME_B + version), this.JAR_NAME_B);
+    File jar = new File(temporaryFolder.newFolder(JAR_NAME_B + version), this.JAR_NAME_B);
     ClassBuilder functionClassBuilder = new ClassBuilder();
     functionClassBuilder.writeJarFromContent("jddunit/function/" + FUNCTION_B, classContents, jar);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
index 846a8d9..89148d7 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandsDUnitTest.java
@@ -15,25 +15,25 @@
 package org.apache.geode.management.internal.cli.commands;
 
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
-import static org.apache.geode.test.dunit.Host.getHost;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
+import java.io.File;
+import java.io.Serializable;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.internal.ClassBuilder;
 import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 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.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.Serializable;
-import java.util.Properties;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 
 /**
  * Unit tests for the DeployCommands class
@@ -67,6 +67,9 @@ public class DeployCommandsDUnitTest implements Serializable {
   private MemberVM server2;
 
   @Rule
+  public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
+
+  @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
 
   @Rule
@@ -74,11 +77,8 @@ public class DeployCommandsDUnitTest implements Serializable {
 
   @Before
   public void setup() throws Exception {
-    getHost(0).getVM(1).bounce();
-    getHost(0).getVM(2).bounce();
-
     ClassBuilder classBuilder = new ClassBuilder();
-    File jarsDir = lsRule.getTempFolder().newFolder();
+    File jarsDir = temporaryFolder.newFolder();
     jar1 = new File(jarsDir, jarName1);
     jar2 = new File(jarsDir, jarName2);
 
@@ -107,8 +107,7 @@ public class DeployCommandsDUnitTest implements Serializable {
   @Test
   public void deployJarToOneGroup() throws Exception {
     // Deploy a jar to a single group
-    CommandResult cmdResult =
-        gfshConnector.executeAndVerifyCommand("deploy --jar=" + jar2 + " --group=" + GROUP1);
+    gfshConnector.executeAndVerifyCommand("deploy --jar=" + jar2 + " --group=" + GROUP1);
     String resultString = gfshConnector.getGfshOutput();
 
     assertThat(resultString).contains(server1.getName());

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
index 045e13e..492e304 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
@@ -23,26 +23,6 @@ import static org.apache.geode.management.internal.cli.commands.ExportLogsComman
 import static org.apache.geode.management.internal.cli.commands.ExportLogsCommand.ONLY_DATE_FORMAT;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.commons.io.FileUtils;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.management.internal.cli.functions.ExportLogsFunction;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.apache.geode.management.internal.configuration.utils.ZipUtils;
-import org.apache.geode.test.dunit.IgnoredException;
-import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Member;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.logging.log4j.Logger;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
 import java.io.File;
 import java.io.IOException;
 import java.io.Serializable;
@@ -59,12 +39,33 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.stream.Stream;
 
+import org.apache.commons.io.FileUtils;
+import org.apache.logging.log4j.Logger;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.internal.cli.functions.ExportLogsFunction;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.Member;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+
 @Category(DistributedTest.class)
 public class ExportLogsDUnitTest {
   private static final String ERROR_LOG_PREFIX = "[IGNORE]";
 
   @Rule
-  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule().withLogFile();
 
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
@@ -280,7 +281,7 @@ public class ExportLogsDUnitTest {
         .describedAs(filesInDir.stream().map(File::getAbsolutePath).collect(joining(",")))
         .hasSize(1);
 
-    File unzippedLogFileDir = lsRule.getTempFolder().newFolder("unzippedLogs");
+    File unzippedLogFileDir = lsRule.getTempWorkingDir().newFolder("unzippedLogs");
     ZipUtils.unzip(zipFilesInDir.get(0).getCanonicalPath(), unzippedLogFileDir.getCanonicalPath());
     return unzippedLogFileDir;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsIntegrationTest.java
index 4ca625a..6726ede 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsIntegrationTest.java
@@ -17,25 +17,25 @@ package org.apache.geode.management.internal.cli.commands;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.io.File;
+import java.nio.file.Path;
+
 import org.apache.commons.io.FileUtils;
-import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.LocatorStarterRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.io.File;
-import java.nio.file.Path;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.LocatorStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
 public class ExportLogsIntegrationTest {
 
   @ClassRule
-  public static LocatorStarterRule locator =
-      new LocatorStarterRule().withJMXManager().withProperty("groups", "g1,g2").withAutoStart();
+  public static LocatorStarterRule locator = new LocatorStarterRule().withLogFile().withAutoStart();
 
   @Rule
   public GfshShellConnectionRule gfsh = new GfshShellConnectionRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
index a78b26f..557fae7 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
@@ -17,28 +17,28 @@ package org.apache.geode.management.internal.cli.commands;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
 import com.google.common.collect.Sets;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.Server;
 import org.apache.geode.test.junit.categories.DistributedTest;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
 
 
 @Category(DistributedTest.class)
 public class ExportLogsOnServerManagerDUnit {
 
   @Rule
-  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule().withLogFile();
 
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
index 33439e6..a1dff25 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
@@ -22,22 +22,6 @@ import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARC
 import static org.apache.geode.management.internal.cli.commands.ExportLogsCommand.ONLY_DATE_FORMAT;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import com.google.common.collect.Sets;
-
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-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.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
 import java.io.IOException;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
@@ -50,10 +34,26 @@ import java.util.stream.Collectors;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
+import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+
 @Category(DistributedTest.class)
 public class ExportLogsStatsDUnitTest {
   @ClassRule
-  public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+  public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule().withLogFile();
 
   @ClassRule
   public static GfshShellConnectionRule connector = new GfshShellConnectionRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsWithMemberGroupDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsWithMemberGroupDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsWithMemberGroupDUnitTest.java
index e5cca27..ef62269 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsWithMemberGroupDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsWithMemberGroupDUnitTest.java
@@ -19,42 +19,34 @@ import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
 import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
-import static org.apache.geode.management.internal.cli.commands.ExportLogsCommand.ONLY_DATE_FORMAT;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
 import com.google.common.collect.Sets;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
-import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 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.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.IOException;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
 
 @Category(DistributedTest.class)
 public class ExportLogsWithMemberGroupDUnitTest {
   @ClassRule
-  public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+  public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule().withLogFile();
 
   @ClassRule
   public static GfshShellConnectionRule connector = new GfshShellConnectionRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoresDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoresDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoresDUnitTest.java
index 766f25a..3e9227e 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoresDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoresDUnitTest.java
@@ -14,22 +14,22 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_CONFIGURATION_DIR;
-import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
-import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.DiskStoreFactory;
-import org.apache.geode.cache.Region;
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+
+import org.awaitility.Awaitility;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
 import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.distributed.ServerLauncher;
-import org.apache.geode.internal.cache.DiskStoreAttributes;
-import org.apache.geode.internal.cache.DiskStoreFactoryImpl;
-import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
@@ -38,24 +38,6 @@ import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 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.awaitility.Awaitility;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-import org.springframework.shell.support.util.FileUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
 
 @Category(DistributedTest.class)
 public class ShowMissingDiskStoresDUnitTest {

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
index d986418..9669669 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
@@ -19,7 +19,16 @@ package org.apache.geode.management.internal.cli.functions;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.io.File;
+import java.io.IOException;
+
 import org.apache.commons.io.FileUtils;
+import org.apache.logging.log4j.Level;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.ResultSender;
@@ -27,20 +36,13 @@ import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.execute.FunctionContextImpl;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.logging.log4j.Level;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
 
 @Category(IntegrationTest.class)
 public class ExportLogsFunctionIntegrationTest {
 
   @Rule
-  public ServerStarterRule serverStarterRule = new ServerStarterRule().withAutoStart();
+  public ServerStarterRule serverStarterRule =
+      new ServerStarterRule().withLogFile().withAutoStart();
   private File serverWorkingDir;
 
   @Before

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunctionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunctionTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunctionTest.java
index 510a4e7..12410c7 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunctionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/SizeExportLogsFunctionTest.java
@@ -14,19 +14,21 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
-import static org.assertj.core.api.Assertions.*;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 
+import java.io.File;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
 import org.apache.commons.io.FileUtils;
-import org.apache.geode.cache.execute.FunctionContext;
-import org.apache.geode.cache.execute.ResultSender;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.cache.execute.FunctionContextImpl;
-import org.apache.geode.management.ManagementException;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -35,11 +37,13 @@ import org.junit.rules.TemporaryFolder;
 import org.junit.rules.TestName;
 import org.mockito.Matchers;
 
-import java.io.File;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.ResultSender;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.internal.cache.execute.FunctionContextImpl;
+import org.apache.geode.management.ManagementException;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
 public class SizeExportLogsFunctionTest {
@@ -58,7 +62,7 @@ public class SizeExportLogsFunctionTest {
   public TestName testName = new TestName();
 
   @Rule
-  public ServerStarterRule server = new ServerStarterRule();
+  public ServerStarterRule server = new ServerStarterRule().withLogFile();
 
   @Before
   public void before() throws Throwable {

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
index a8b498d..0cd6d5a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogExporterIntegrationTest.java
@@ -19,11 +19,14 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import com.google.common.collect.Sets;
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
 
-import org.apache.geode.management.internal.cli.functions.ExportLogsFunctionIntegrationTest;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
+import com.google.common.collect.Sets;
 import org.apache.logging.log4j.Level;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -31,18 +34,15 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
+import org.apache.geode.management.internal.cli.functions.ExportLogsFunctionIntegrationTest;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
 public class LogExporterIntegrationTest {
 
   @Rule
-  public ServerStarterRule server = new ServerStarterRule();
+  public ServerStarterRule server = new ServerStarterRule().withLogFile();
 
   private LogExporter logExporter;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
index 9166642..35d65a0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
@@ -19,27 +19,28 @@ package org.apache.geode.management.internal.cli.util;
 import static java.util.stream.Collectors.joining;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.Properties;
+
 import org.apache.commons.io.FileUtils;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.logging.LogService;
-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.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.Properties;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 public class MergeLogsDUnitTest {
   @Rule
-  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule().withLogFile();
   private MemberVM locator;
 
   private static final String MESSAGE_1 = "MergeLogsMessage1";
@@ -72,18 +73,18 @@ public class MergeLogsDUnitTest {
 
   @Test
   public void testExportInProcess() throws Exception {
-    assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3);
+    assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempWorkingDir().getRoot())).hasSize(3);
 
-    File result = MergeLogs.mergeLogFile(lsRule.getTempFolder().getRoot().getCanonicalPath());
+    File result = MergeLogs.mergeLogFile(lsRule.getTempWorkingDir().getRoot().getCanonicalPath());
     assertOnLogContents(result);
   }
 
   @Test
   public void testExportInNewProcess() throws Throwable {
-    assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempFolder().getRoot())).hasSize(3);
+    assertThat(MergeLogs.findLogFilesToMerge(lsRule.getTempWorkingDir().getRoot())).hasSize(3);
 
-    MergeLogs.mergeLogsInNewProcess(lsRule.getTempFolder().getRoot().toPath());
-    File result = Arrays.stream(lsRule.getTempFolder().getRoot().listFiles())
+    MergeLogs.mergeLogsInNewProcess(lsRule.getTempWorkingDir().getRoot().toPath());
+    File result = Arrays.stream(lsRule.getTempWorkingDir().getRoot().listFiles())
         .filter((File f) -> f.getName().startsWith("merge")).findFirst().orElseThrow(() -> {
           throw new AssertionError("No merged log file found");
         });

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
index 3b105a4..f840af3 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
@@ -19,14 +19,15 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+
 @Category(DistributedTest.class)
 public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
 
@@ -39,9 +40,9 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
 
   @Before
   public void before() throws Exception {
-    clusterJar = createJarFileWithClass("Cluster", "cluster.jar", lsRule.getTempFolder().getRoot());
-    group1Jar = createJarFileWithClass("Group1", "group1.jar", lsRule.getTempFolder().getRoot());
-    group2Jar = createJarFileWithClass("Group2", "group2.jar", lsRule.getTempFolder().getRoot());
+    clusterJar = createJarFileWithClass("Cluster", "cluster.jar", temporaryFolder.getRoot());
+    group1Jar = createJarFileWithClass("Group1", "group1.jar", temporaryFolder.getRoot());
+    group2Jar = createJarFileWithClass("Group2", "group2.jar", temporaryFolder.getRoot());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
index 4b003a8..ff9427b 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
@@ -21,6 +21,15 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
@@ -32,14 +41,7 @@ import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 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.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 
 @Category(DistributedTest.class)
 public class ClusterConfigDistributionDUnitTest {
@@ -53,6 +55,9 @@ public class ClusterConfigDistributionDUnitTest {
   private MemberVM locator;
 
   @Rule
+  public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
+
+  @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
@@ -137,8 +142,8 @@ public class ClusterConfigDistributionDUnitTest {
   }
 
   private String createAsyncEventQueueJar() throws IOException {
-    String queueCommandsJarName = this.lsRule.getTempFolder().getRoot().getCanonicalPath()
-        + File.separator + "testEndToEndSC-QueueCommands.jar";
+    String queueCommandsJarName = temporaryFolder.getRoot().getCanonicalPath() + File.separator
+        + "testEndToEndSC-QueueCommands.jar";
     final File jarFile = new File(queueCommandsJarName);
 
     ClassBuilder classBuilder = new ClassBuilder();

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
index 066f882..1d00895 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
@@ -19,6 +19,20 @@ import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.io.File;
+import java.nio.file.Path;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.management.cli.Result;
@@ -27,18 +41,6 @@ import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 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.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.nio.file.Path;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
 
 @Category(DistributedTest.class)
 public class ClusterConfigImportDUnitTest extends ClusterConfigTestBase {
@@ -143,14 +145,15 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigTestBase {
   @Test
   public void testExportWithAbsolutePath() throws Exception {
     Path exportedZipPath =
-        lsRule.getTempFolder().getRoot().toPath().resolve("exportedCC.zip").toAbsolutePath();
+        temporaryFolder.getRoot().toPath().resolve("exportedCC.zip").toAbsolutePath();
 
     testExportClusterConfig(exportedZipPath.toString());
   }
 
   @Test
   public void testExportWithRelativePath() throws Exception {
-    testExportClusterConfig("tmp/exportedCC.zip");
+    testExportClusterConfig("mytemp/exportedCC.zip");
+    FileUtils.deleteQuietly(new File("mytemp"));
   }
 
   public void testExportClusterConfig(String zipFilePath) throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
index c84a7c1..5b93fc1 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
@@ -21,15 +21,16 @@ import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOAD_CLUSTER_CONFIGURATION_FROM_DIR;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 
-import org.apache.geode.management.internal.configuration.utils.ZipUtils;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.categories.DistributedTest;
+import java.io.File;
+import java.util.Properties;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import java.io.File;
-import java.util.Properties;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 public class ClusterConfigStartMemberDUnitTest extends ClusterConfigTestBase {
@@ -78,7 +79,7 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigTestBase {
   }
 
   private MemberVM startLocatorWithLoadCCFromDir() throws Exception {
-    File locatorDir = lsRule.getTempFolder().newFolder("locator-0");
+    File locatorDir = new File(lsRule.getWorkingDirRoot(), "vm0");
     File configDir = new File(locatorDir, "cluster_config");
 
     // The unzip should yield a cluster config directory structure like:

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigTestBase.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigTestBase.java
index fd8fb46..0ad2e3a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigTestBase.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigTestBase.java
@@ -18,19 +18,19 @@ package org.apache.geode.management.internal.configuration;
 
 import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
 import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
-import static org.apache.geode.test.dunit.Host.getHost;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.geode.internal.ClassBuilder;
-import org.apache.geode.management.internal.configuration.utils.ZipUtils;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.junit.Before;
 import org.junit.Rule;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
+import org.apache.geode.internal.ClassBuilder;
+import org.apache.geode.management.internal.configuration.utils.ZipUtils;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 
 public abstract class ClusterConfigTestBase {
   public String clusterConfigZipPath;
@@ -53,6 +53,9 @@ public abstract class ClusterConfigTestBase {
           .regions("regionForGroup2"));
 
   @Rule
+  public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
+
+  @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
 
   protected Properties locatorProps;
@@ -70,7 +73,7 @@ public abstract class ClusterConfigTestBase {
   }
 
   private String buildClusterZipFile() throws Exception {
-    File clusterConfigDir = this.lsRule.getTempFolder().newFolder("cluster_config");
+    File clusterConfigDir = temporaryFolder.newFolder("cluster_config");
 
     File clusterDir = new File(clusterConfigDir, "cluster");
     String clusterXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
@@ -104,7 +107,7 @@ public abstract class ClusterConfigTestBase {
     createJarFileWithClass("Group2", "group2.jar", group2Dir);
 
 
-    File clusterConfigZip = new File(lsRule.getTempFolder().newFolder(), "cluster_config.zip");
+    File clusterConfigZip = new File(temporaryFolder.newFolder(), "cluster_config.zip");
     ZipUtils.zipDirectory(clusterConfigDir.getCanonicalPath(), clusterConfigZip.getCanonicalPath());
 
     FileUtils.deleteDirectory(clusterConfigDir);

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
index bb45b0d..9adba37 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
@@ -20,7 +20,16 @@ import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.io.File;
+import java.util.Properties;
+
 import org.apache.commons.io.FileUtils;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.cache.InternalCache;
@@ -32,14 +41,7 @@ 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.categories.SecurityTest;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.util.Properties;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 
 @Category({DistributedTest.class, SecurityTest.class})
 public class ClusterConfigWithSecurityDUnitTest {
@@ -49,6 +51,9 @@ public class ClusterConfigWithSecurityDUnitTest {
   private Properties locatorProps;
 
   @Rule
+  public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
+
+  @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
 
   @Rule
@@ -123,13 +128,13 @@ public class ClusterConfigWithSecurityDUnitTest {
   }
 
   private String buildSecureClusterConfigZip() throws Exception {
-    File clusterDir = lsRule.getTempFolder().newFolder("cluster");
+    File clusterDir = temporaryFolder.newFolder("cluster");
     File clusterSubDir = new File(clusterDir, "cluster");
 
     String clusterProperties = "mcast-port=0\n" + "log-file-size-limit=8000\n"
         + "security-manager=org.apache.geode.example.security.ExampleSecurityManager";
     FileUtils.writeStringToFile(new File(clusterSubDir, "cluster.properties"), clusterProperties);
-    File clusterZip = new File(lsRule.getTempFolder().getRoot(), "cluster_config_security.zip");
+    File clusterZip = new File(temporaryFolder.getRoot(), "cluster_config_security.zip");
     ZipUtils.zipDirectory(clusterDir.getCanonicalPath(), clusterZip.getCanonicalPath());
     FileUtils.deleteDirectory(clusterDir);
     return clusterZip.getCanonicalPath();

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java
index 4274d67..31c5817 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java
@@ -19,6 +19,14 @@ import static org.apache.geode.cache.DataPolicy.PARTITION;
 import static org.apache.geode.cache.DataPolicy.REPLICATE;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.io.File;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
@@ -26,12 +34,6 @@ import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 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.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
 
 @Category(DistributedTest.class)
 public class ImportClusterConfigDistributedTest {
@@ -42,6 +44,9 @@ public class ImportClusterConfigDistributedTest {
   private MemberVM locator, server;
 
   @Rule
+  public TemporaryFolder tempFolder = new TemporaryFolder();
+
+  @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
 
   @Rule
@@ -60,9 +65,8 @@ public class ImportClusterConfigDistributedTest {
 
     server.invoke(ImportClusterConfigDistributedTest::validateServerIsUsingClusterConfig);
 
-    this.exportedClusterConfig =
-        new File(lsRule.getTempFolder().getRoot(), EXPORTED_CLUSTER_CONFIG_ZIP_NAME);
-
+    // do not create the file yet
+    this.exportedClusterConfig = new File(tempFolder.getRoot(), EXPORTED_CLUSTER_CONFIG_ZIP_NAME);
 
     gfsh.executeAndVerifyCommand(
         "export cluster-configuration --zip-file-name=" + exportedClusterConfig.getCanonicalPath());

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/management/internal/security/MemberMBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/MemberMBeanSecurityJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/MemberMBeanSecurityJUnitTest.java
index e6b50d2..7131060 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/MemberMBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/MemberMBeanSecurityJUnitTest.java
@@ -41,8 +41,8 @@ public class MemberMBeanSecurityJUnitTest {
   public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
 
   @Rule // do not use a ClassRule since some test will do a shutdownMember
-  public ServerStarterRule server = ServerStarterRule.createWithoutTemporaryWorkingDir()
-      .withJMXManager().withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+  public ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
       .withProperty(TestSecurityManager.SECURITY_JSON,
           "org/apache/geode/management/internal/security/cacheServer.json")
       .withAutoStart();

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
index e90bc0a..b638248 100644
--- a/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
@@ -20,6 +20,14 @@ import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_C
 import static org.assertj.core.api.Java6Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
 
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.GemFireConfigException;
 import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.internal.i18n.LocalizedStrings;
@@ -28,13 +36,6 @@ import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.Properties;
 
 @Category({DistributedTest.class, SecurityTest.class})
 public class ClusterConfigWithoutSecurityDUnitTest {

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
index c4a2547..2f5bb78 100644
--- a/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
@@ -18,7 +18,20 @@ import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANA
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_POST_PROCESSOR;
 import static org.apache.geode.security.SecurityTestUtil.createClientCache;
 import static org.apache.geode.security.SecurityTestUtil.createProxyRegion;
-import static org.assertj.core.api.Assertions.*;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
+
+import org.awaitility.Awaitility;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
 import org.apache.geode.cache.EntryEvent;
 import org.apache.geode.cache.Region;
@@ -40,18 +53,6 @@ import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory;
-import org.awaitility.Awaitility;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.TimeUnit;
 
 @Category({DistributedTest.class, SecurityTest.class})
 @RunWith(Parameterized.class)
@@ -84,13 +85,13 @@ public class PDXPostProcessorDUnitTest extends JUnit4DistributedTestCase {
   }
 
   @Rule
-  public ServerStarterRule server = ServerStarterRule.createWithoutTemporaryWorkingDir()
-      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
-      .withProperty(TestSecurityManager.SECURITY_JSON,
-          "org/apache/geode/management/internal/security/clientServer.json")
-      .withProperty(SECURITY_POST_PROCESSOR, PDXPostProcessor.class.getName())
-      .withProperty("security-pdx", this.pdxPersistent + "").withJMXManager()
-      .withRegion(RegionShortcut.REPLICATE, REGION_NAME);
+  public ServerStarterRule server =
+      new ServerStarterRule().withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+          .withProperty(TestSecurityManager.SECURITY_JSON,
+              "org/apache/geode/management/internal/security/clientServer.json")
+          .withProperty(SECURITY_POST_PROCESSOR, PDXPostProcessor.class.getName())
+          .withProperty("security-pdx", this.pdxPersistent + "").withJMXManager()
+          .withRegion(RegionShortcut.REPLICATE, REGION_NAME);
 
   @Test
   public void testRegionGet() {

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
index b977b50..0d56f62 100644
--- a/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/PeerAuthenticatorDUnitTest.java
@@ -19,18 +19,19 @@ import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER
 import static org.apache.geode.test.dunit.Host.getHost;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.security.templates.DummyAuthenticator;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.Properties;
 
 @Category({DistributedTest.class, SecurityTest.class})
 public class PeerAuthenticatorDUnitTest {

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index 62ae2e2..d8753cf 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -57,26 +57,58 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
   private DistributedRestoreSystemProperties restoreSystemProperties =
       new DistributedRestoreSystemProperties();
 
-  private TemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
+  private TemporaryFolder tempWorkingDir;
   private MemberVM[] members;
 
+  private boolean logFile = false;
+
   public LocatorServerStartupRule() {
     DUnitLauncher.launchIfNeeded();
   }
 
+  /**
+   * This rule will use a temporary folder to hold all the vm directories instead of using dunit
+   * folder. It will set each VM's working dir to its respective sub-directories.
+   *
+   * use this if you want to examine each member's file system without worrying about it's being
+   * contaminated with DUnitLauncher's log files that exists in each dunit/vm folder such as
+   * locator0View.dat and locator0views.log and other random log files. This will cause the VMs to
+   * be bounced after test is done, because it dynamically changes the user.dir system property.
+   */
+  public LocatorServerStartupRule withTempWorkingDir() {
+    tempWorkingDir = new SerializableTemporaryFolder();
+    return this;
+  }
+
+  public boolean useTempWorkingDir() {
+    return tempWorkingDir != null;
+  }
+
+  /**
+   * all the logs will go into the file. If this is called, a temp directory is used for this rule
+   * instead of dunit folder. It's the same effect as calling .withTempWorkingDir() and withLogFile.
+   */
+  public LocatorServerStartupRule withLogFile() {
+    withTempWorkingDir();
+    this.logFile = true;
+    return this;
+  }
+
   @Override
   protected void before() throws Throwable {
     restoreSystemProperties.before();
-    temporaryFolder.create();
+    if (useTempWorkingDir())
+      tempWorkingDir.create();
     members = new MemberVM[4];
   }
 
   @Override
   protected void after() {
     DUnitLauncher.closeAndCheckForSuspects();
-    restoreSystemProperties.after();
-    temporaryFolder.delete();
     Arrays.stream(members).filter(Objects::nonNull).forEach(MemberVM::stopMember);
+    if (useTempWorkingDir())
+      tempWorkingDir.delete();
+    restoreSystemProperties.after();
   }
 
   public MemberVM<Locator> startLocatorVM(int index) throws Exception {
@@ -92,19 +124,24 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
   public MemberVM<Locator> startLocatorVM(int index, Properties properties) throws Exception {
     String name = "locator-" + index;
     properties.setProperty(NAME, name);
-    File workingDir = createWorkingDirForMember(name);
     VM locatorVM = getHost(0).getVM(index);
     Locator locator = locatorVM.invoke(() -> {
-      locatorStarter = new LocatorStarterRule(workingDir);
+      if (useTempWorkingDir()) {
+        File workingDirFile = createWorkingDirForMember(name);
+        locatorStarter = new LocatorStarterRule(workingDirFile);
+      } else {
+        locatorStarter = new LocatorStarterRule();
+      }
+
+      locatorStarter.withLogFile(logFile);
       locatorStarter.withProperties(properties).withAutoStart();
       locatorStarter.before();
       return locatorStarter;
     });
-    members[index] = new MemberVM(locator, locatorVM);
+    members[index] = new MemberVM(locator, locatorVM, useTempWorkingDir());
     return members[index];
   }
 
-
   public MemberVM startServerVM(int index) throws IOException {
     return startServerVM(index, new Properties(), -1);
   }
@@ -117,9 +154,32 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     return startServerVM(index, properties, -1);
   }
 
+  /**
+   * Starts a cache server with given properties
+   */
+  public MemberVM startServerVM(int index, Properties properties, int locatorPort)
+      throws IOException {
+    String name = "server-" + index;
+    properties.setProperty(NAME, name);
+    VM serverVM = getHost(0).getVM(index);
+    Server server = serverVM.invoke(() -> {
+      if (useTempWorkingDir()) {
+        File workingDirFile = createWorkingDirForMember(name);
+        serverStarter = new ServerStarterRule(workingDirFile);
+      } else {
+        serverStarter = new ServerStarterRule();
+      }
+      serverStarter.withLogFile(logFile);
+      serverStarter.withProperties(properties).withConnectionToLocator(locatorPort).withAutoStart();
+      serverStarter.before();
+      return serverStarter;
+    });
+    members[index] = new MemberVM(server, serverVM, useTempWorkingDir());
+    return members[index];
+  }
+
   public MemberVM startServerAsJmxManager(int index) throws IOException {
-    Properties properties = new Properties();
-    return startServerAsJmxManager(index, properties);
+    return startServerAsJmxManager(index, new Properties());
   }
 
   public MemberVM startServerAsJmxManager(int index, Properties properties) throws IOException {
@@ -129,15 +189,21 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
 
   public MemberVM startServerAsEmbededLocator(int index) throws IOException {
     String name = "server-" + index;
-    File workingDir = createWorkingDirForMember(name);
+
     VM serverVM = getHost(0).getVM(index);
     Server server = serverVM.invoke(() -> {
-      serverStarter = new ServerStarterRule(workingDir);
+      if (useTempWorkingDir()) {
+        File workingDirFile = createWorkingDirForMember(name);
+        serverStarter = new ServerStarterRule(workingDirFile);
+      } else {
+        serverStarter = new ServerStarterRule();
+      }
+      serverStarter.withLogFile(logFile);
       serverStarter.withEmbeddedLocator().withName(name).withJMXManager().withAutoStart();
       serverStarter.before();
       return serverStarter;
     });
-    members[index] = new MemberVM(server, serverVM);
+    members[index] = new MemberVM(server, serverVM, useTempWorkingDir());
     return members[index];
   }
 
@@ -147,27 +213,6 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
   }
 
   /**
-   * Starts a cache server with given properties
-   */
-  public MemberVM startServerVM(int index, Properties properties, int locatorPort)
-      throws IOException {
-    String name = "server-" + index;
-    properties.setProperty(NAME, name);
-
-    File workingDir = createWorkingDirForMember(name);
-    VM serverVM = getHost(0).getVM(index);
-    Server server = serverVM.invoke(() -> {
-      serverStarter = new ServerStarterRule(workingDir);
-      serverStarter.withProperties(properties).withConnectionToLocator(locatorPort).withAutoStart();
-      serverStarter.before();
-      return serverStarter;
-    });
-    members[index] = new MemberVM(server, serverVM);
-    return members[index];
-  }
-
-
-  /**
    * Returns the {@link Member} running inside the VM with the specified {@code index}
    */
   public MemberVM getMember(int index) {
@@ -178,8 +223,16 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     return getHost(0).getVM(index);
   }
 
-  public TemporaryFolder getTempFolder() {
-    return temporaryFolder;
+  public TemporaryFolder getTempWorkingDir() {
+    return tempWorkingDir;
+  }
+
+  public File getWorkingDirRoot() {
+    if (useTempWorkingDir())
+      return tempWorkingDir.getRoot();
+
+    // return the dunit folder
+    return new File(DUnitLauncher.DUNIT_DIR);
   }
 
   public static void stopMemberInThisVM() {
@@ -194,9 +247,9 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
   }
 
   private File createWorkingDirForMember(String dirName) throws IOException {
-    File workingDir = new File(temporaryFolder.getRoot(), dirName).getAbsoluteFile();
+    File workingDir = new File(tempWorkingDir.getRoot(), dirName).getAbsoluteFile();
     if (!workingDir.exists()) {
-      temporaryFolder.newFolder(dirName);
+      tempWorkingDir.newFolder(dirName);
     }
 
     return workingDir;

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
index 226fd6c..156236b 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
@@ -53,6 +53,7 @@ public abstract class MemberStarterRule<T> extends ExternalResource implements M
   protected int httpPort = -1;
 
   protected String name;
+  protected boolean logFile = false;
   protected Properties properties = new Properties();
 
   protected boolean autoStart = false;
@@ -61,20 +62,13 @@ public abstract class MemberStarterRule<T> extends ExternalResource implements M
     this(null);
   }
 
-  public MemberStarterRule(File workDir) {
-    workingDir = workDir;
+  // Not meant to be public, only used by LocatorServerStartupRule
+  MemberStarterRule(File workDir) {
     oldUserDir = System.getProperty("user.dir");
-    if (workingDir == null) {
-      temporaryFolder = new TemporaryFolder();
-      try {
-        temporaryFolder.create();
-      } catch (IOException e) {
-        throw new RuntimeException(e.getMessage(), e);
-      }
-      workingDir = temporaryFolder.getRoot().getAbsoluteFile();
+    workingDir = workDir;
+    if (workDir != null) {
+      withWorkingDir();
     }
-
-    System.setProperty("user.dir", workingDir.toString());
     // initial values
     properties.setProperty(MCAST_PORT, "0");
     properties.setProperty(LOCATORS, "");
@@ -126,8 +120,44 @@ public abstract class MemberStarterRule<T> extends ExternalResource implements M
   public T withName(String name) {
     this.name = name;
     properties.setProperty(NAME, name);
-    // if log-file is not already set
-    properties.putIfAbsent(LOG_FILE, new File(name + ".log").getAbsolutePath());
+    return (T) this;
+  }
+
+  /**
+   * this will make the logging to into a log file instead of on the console.
+   *
+   * Use with caution, the logs files are created in a temp working directory. this is achieved by
+   * dynamically changing the "user.dir" system property.
+   * 
+   * @return
+   */
+  public T withLogFile() {
+    this.logFile = true;
+    return (T) this;
+  }
+
+  // Not meant to be public, only used by LocatorServerStartupRule
+  T withLogFile(boolean logFile) {
+    this.logFile = logFile;
+    return (T) this;
+  }
+
+  /**
+   * create the working dir using temporaryFolder. Use with caution, this sets "user.dir" system
+   * property that not approved by JDK
+   */
+  public T withWorkingDir() {
+    if (workingDir == null) {
+      temporaryFolder = new TemporaryFolder();
+      try {
+        temporaryFolder.create();
+      } catch (IOException e) {
+        throw new RuntimeException(e.getMessage(), e);
+      }
+      workingDir = temporaryFolder.getRoot().getAbsoluteFile();
+    }
+
+    System.setProperty("user.dir", workingDir.toString());
     return (T) this;
   }
 
@@ -189,6 +219,16 @@ public abstract class MemberStarterRule<T> extends ExternalResource implements M
       // the existing properties
       withJMXManager(false);
     }
+
+    // if caller wants the logs being put into a file instead of in console output
+    // do it here since only here, we can gurantee the name is present
+    if (logFile) {
+      // if working dir is not created yet, creates it.
+      if (workingDir == null) {
+        withWorkingDir();
+      }
+      properties.putIfAbsent(LOG_FILE, new File(name + ".log").getAbsolutePath());
+    }
   }
 
   abstract void stopMember();

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
index 7e5ce1f..14ccb6a 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
@@ -15,20 +15,28 @@
 
 package org.apache.geode.test.dunit.rules;
 
+import java.io.File;
+import java.util.Arrays;
+
+import org.apache.commons.io.FileUtils;
+
 import org.apache.geode.test.dunit.AsyncInvocation;
 import org.apache.geode.test.dunit.SerializableRunnableIF;
 import org.apache.geode.test.dunit.VM;
 
-import java.io.File;
-import java.nio.file.Paths;
-
 public class MemberVM<T extends Member> implements Member {
   private T member;
   private VM vm;
+  private boolean tempWorkingDir;
 
   public MemberVM(T member, VM vm) {
+    this(member, vm, false);
+  }
+
+  public MemberVM(T member, VM vm, boolean tempWorkingDir) {
     this.member = member;
     this.vm = vm;
+    this.tempWorkingDir = tempWorkingDir;
   }
 
   public boolean isLocator() {
@@ -53,7 +61,9 @@ public class MemberVM<T extends Member> implements Member {
 
   @Override
   public File getWorkingDir() {
-    return member.getWorkingDir();
+    if (tempWorkingDir)
+      return member.getWorkingDir();
+    return vm.getWorkingDirectory();
   }
 
   @Override
@@ -77,17 +87,20 @@ public class MemberVM<T extends Member> implements Member {
   }
 
   public void stopMember() {
-
     this.invoke(LocatorServerStartupRule::stopMemberInThisVM);
-    /**
-     * The LocatorServerStarterRule may dynamically change the "user.dir" system property to point
-     * to a temporary folder. The Path API caches the first value of "user.dir" that it sees, and
-     * this can result in a stale cached value of "user.dir" which points to a directory that no
-     * longer exists.
-     */
-    boolean vmIsClean = this.getVM().invoke(() -> Paths.get("").toAbsolutePath().toFile().exists());
-    if (!vmIsClean) {
-      this.getVM().bounce();
-    }
+    if (tempWorkingDir) {
+      /*
+       * this temporary workingDir will dynamically change the "user.dir". system property to point
+       * to a temporary folder. The Path API caches the first value of "user.dir" that it sees, and
+       * this can result in a stale cached value of "user.dir" which points to a directory that no
+       * longer exists.
+       */
+      vm.bounce();
+    } else
+      // if using the dunit/vm dir as the preset working dir, need to cleanup dir except
+      // the locator0view* file, so that regions/indexes won't get persisted across tests
+      Arrays.stream(getWorkingDir().listFiles((dir, name) -> {
+        return !name.startsWith("locator0view");
+      })).forEach(FileUtils::deleteQuietly);
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
index 6ea2d03..0fd0e77 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
@@ -18,22 +18,21 @@ import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_
 import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.server.CacheServer;
-import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalCache;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
 /**
  * This is a rule to start up a server in your current VM. It's useful for your Integration Tests.
  *
@@ -95,17 +94,6 @@ public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> impl
     }
   }
 
-  /**
-   * By default, the ServerStartRule dynamically changes the "user.dir" system property to point to
-   * a temporary folder. The Path API caches the first value of "user.dir" that it sees, and this
-   * can result in a stale cached value of "user.dir" which points to a directory that no longer
-   * exists, causing later tests to fail. By passing in the real value of "user.dir", we avoid these
-   * problems.
-   */
-  public static ServerStarterRule createWithoutTemporaryWorkingDir() {
-    return new ServerStarterRule(new File(System.getProperty("user.dir")));
-  }
-
   @Override
   public void stopMember() {
     // stop CacheServer and then close cache -- cache.close() will stop any running CacheServers

http://git-wip-us.apache.org/repos/asf/geode/blob/0ea489ea/geode-core/src/test/java/org/apache/geode/test/dunit/rules/test/MemberStarterRuleTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/test/MemberStarterRuleTest.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/test/MemberStarterRuleTest.java
index 7dada04..4970cb5 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/test/MemberStarterRuleTest.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/test/MemberStarterRuleTest.java
@@ -18,18 +18,28 @@ package org.apache.geode.test.dunit.rules.test;
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_PORT;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.geode.test.dunit.rules.LocatorStarterRule;
-import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.After;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import org.apache.geode.test.dunit.rules.LocatorStarterRule;
+import org.apache.geode.test.junit.categories.UnitTest;
+
 @Category(UnitTest.class)
 public class MemberStarterRuleTest {
 
+  private LocatorStarterRule locator;
+
+  @After
+  public void after() {
+    if (locator != null)
+      locator.after();
+  }
+
   @Test
   public void testSetJMXPortWithProperty() {
     int port = 2000;
-    LocatorStarterRule locator = new LocatorStarterRule().withProperty(JMX_MANAGER_PORT, port + "");
+    locator = new LocatorStarterRule().withProperty(JMX_MANAGER_PORT, port + "");
     locator.before();
     assertThat(locator.getJmxPort()).isEqualTo(port);
   }
@@ -37,7 +47,7 @@ public class MemberStarterRuleTest {
   @Test
   public void testSetJMXPortWithPropertyThenAPI() {
     int port = 2000;
-    LocatorStarterRule locator = new LocatorStarterRule().withProperty(JMX_MANAGER_PORT, port + "");
+    locator = new LocatorStarterRule().withProperty(JMX_MANAGER_PORT, port + "");
 
     // user call withJMXManager again
     locator.withJMXManager();
@@ -49,7 +59,7 @@ public class MemberStarterRuleTest {
   @Test
   public void testSetJMXPortWithAPIThenProperty() {
     // this first one wins
-    LocatorStarterRule locator = new LocatorStarterRule().withJMXManager();
+    locator = new LocatorStarterRule().withJMXManager();
     int port = locator.getJmxPort();
 
     locator.withProperty(JMX_MANAGER_PORT, "9999");
@@ -60,7 +70,7 @@ public class MemberStarterRuleTest {
 
   @Test
   public void testUseRandomPortByDefault() {
-    LocatorStarterRule locator = new LocatorStarterRule();
+    locator = new LocatorStarterRule();
     locator.before();
 
     assertThat(locator.getJmxPort()).isNotEqualTo(1099);
@@ -69,4 +79,30 @@ public class MemberStarterRuleTest {
     assertThat(locator.getHttpPort()).isNotEqualTo(7070);
     assertThat(locator.getHttpPort()).isNotEqualTo(-1);
   }
+
+  @Test
+  public void workingDirNotCreatedByDefault() throws Exception {
+    String userDir = System.getProperty("user.dir");
+    locator = new LocatorStarterRule();
+    locator.before();
+    assertThat(System.getProperty("user.dir")).isSameAs(userDir);
+    assertThat(locator.getWorkingDir()).isNull();
+  }
+
+  @Test
+  public void userDirSetToWorkingDirWhenCreatedWithIt() throws Exception {
+    locator = new LocatorStarterRule().withWorkingDir();
+    locator.before();
+
+    assertThat(System.getProperty("user.dir")).isEqualTo(locator.getWorkingDir().toString());
+  }
+
+  @Test
+  public void logInFileCreatesWorkingDir() throws Exception {
+    locator = new LocatorStarterRule().withLogFile();
+    locator.before();
+
+    assertThat(locator.getName()).isNotNull();
+    assertThat(locator.getWorkingDir()).isNotNull();
+  }
 }


Mime
View raw message