geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zho...@apache.org
Subject [11/50] [abbrv] geode git commit: GEODE-3231: withLogFile does not imply withWorkingDir anymore
Date Sat, 29 Jul 2017 00:52:22 GMT
GEODE-3231: withLogFile does not imply withWorkingDir anymore


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

Branch: refs/heads/feature/GEM-1483
Commit: 7f86d0cdb7ee50387ae995f57362155cab9eb1bc
Parents: 0675317
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Fri Jul 21 22:40:30 2017 -0700
Committer: Jinmei Liao <jiliao@pivotal.io>
Committed: Tue Jul 25 11:08:36 2017 -0700

----------------------------------------------------------------------
 .../ClassPathLoaderIntegrationTest.java         | 24 +++--
 .../cli/commands/ExportLogsDUnitTest.java       |  3 +-
 .../cli/commands/ExportLogsIntegrationTest.java |  4 +-
 .../ExportLogsOnServerManagerDUnit.java         |  3 +-
 .../cli/commands/ExportLogsStatsDUnitTest.java  |  3 +-
 .../ExportLogsFunctionIntegrationTest.java      | 34 +------
 .../cli/functions/ExportLogsFunctionTest.java   | 40 +++++++-
 .../functions/SizeExportLogsFunctionTest.java   |  4 +-
 .../cli/util/LogExporterIntegrationTest.java    |  2 +-
 .../internal/cli/util/MergeLogsDUnitTest.java   |  3 +-
 .../DiskStoreMXBeanSecurityJUnitTest.java       | 19 ++--
 .../dunit/rules/GfshShellConnectionRule.java    | 22 ++---
 .../dunit/rules/LocatorServerStartupRule.java   | 33 +++----
 .../test/dunit/rules/LocatorStarterRule.java    | 16 +---
 .../test/dunit/rules/MemberStarterRule.java     | 96 ++++++++------------
 .../test/dunit/rules/ServerStarterRule.java     | 19 ----
 .../dunit/rules/test/MemberStarterRuleTest.java | 12 +--
 .../internal/security/LogNoPasswordTest.java    |  2 +-
 18 files changed, 149 insertions(+), 190 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/geode-core/src/test/java/org/apache/geode/internal/ClassPathLoaderIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/ClassPathLoaderIntegrationTest.java
b/geode-core/src/test/java/org/apache/geode/internal/ClassPathLoaderIntegrationTest.java
index 721e502..34d8a23 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/ClassPathLoaderIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/ClassPathLoaderIntegrationTest.java
@@ -16,7 +16,10 @@ package org.apache.geode.internal;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.io.BufferedInputStream;
 import java.io.File;
@@ -33,13 +36,6 @@ import org.apache.bcel.Constants;
 import org.apache.bcel.classfile.JavaClass;
 import org.apache.bcel.generic.ClassGen;
 import org.apache.commons.io.FileUtils;
-import org.apache.geode.cache.execute.Execution;
-import org.apache.geode.cache.execute.FunctionService;
-import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.test.junit.rules.RestoreTCCLRule;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -47,7 +43,14 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.TemporaryFolder;
 
+import org.apache.geode.cache.execute.Execution;
+import org.apache.geode.cache.execute.FunctionService;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.rules.RestoreTCCLRule;
 
 /**
  * Integration tests for {@link ClassPathLoader}.
@@ -238,7 +241,8 @@ public class ClassPathLoaderIntegrationTest {
     outStream.write(jarBytes);
     outStream.close();
 
-    ServerStarterRule serverStarterRule = new ServerStarterRule(temporaryFolder.getRoot());
+    ServerStarterRule serverStarterRule =
+        new ServerStarterRule().withWorkingDir(temporaryFolder.getRoot());
     serverStarterRule.startServer();
 
     GemFireCacheImpl gemFireCache = GemFireCacheImpl.getInstance();
@@ -257,7 +261,7 @@ public class ClassPathLoaderIntegrationTest {
     File jarVersion1 = createVersionOfJar("Version1", "MyFunction", "MyJar.jar");
     File jarVersion2 = createVersionOfJar("Version2", "MyFunction", "MyJar.jar");
 
-    ServerStarterRule serverStarterRule = new ServerStarterRule(temporaryFolder.getRoot());
+    ServerStarterRule serverStarterRule = new ServerStarterRule();
     serverStarterRule.startServer();
 
     GemFireCacheImpl gemFireCache = GemFireCacheImpl.getInstance();

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 492e304..0e31de6 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
@@ -65,7 +65,8 @@ public class ExportLogsDUnitTest {
   private static final String ERROR_LOG_PREFIX = "[IGNORE]";
 
   @Rule
-  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule().withLogFile();
+  public LocatorServerStartupRule lsRule =
+      new LocatorServerStartupRule().withTempWorkingDir().withLogFile();
 
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 6726ede..a145b27 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
@@ -33,9 +33,9 @@ import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
 public class ExportLogsIntegrationTest {
-
   @ClassRule
-  public static LocatorStarterRule locator = new LocatorStarterRule().withLogFile().withAutoStart();
+  public static LocatorStarterRule locator =
+      new LocatorStarterRule().withWorkingDir().withLogFile().withAutoStart();
 
   @Rule
   public GfshShellConnectionRule gfsh = new GfshShellConnectionRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 557fae7..6a7a864 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
@@ -38,7 +38,8 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 public class ExportLogsOnServerManagerDUnit {
 
   @Rule
-  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule().withLogFile();
+  public LocatorServerStartupRule lsRule =
+      new LocatorServerStartupRule().withTempWorkingDir().withLogFile();
 
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 a1dff25..e2214f5 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
@@ -53,7 +53,8 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 @Category(DistributedTest.class)
 public class ExportLogsStatsDUnitTest {
   @ClassRule
-  public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule().withLogFile();
+  public static LocatorServerStartupRule lsRule =
+      new LocatorServerStartupRule().withTempWorkingDir().withLogFile();
 
   @ClassRule
   public static GfshShellConnectionRule connector = new GfshShellConnectionRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 9669669..0c1be05 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
@@ -23,7 +23,6 @@ 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;
@@ -42,7 +41,7 @@ public class ExportLogsFunctionIntegrationTest {
 
   @Rule
   public ServerStarterRule serverStarterRule =
-      new ServerStarterRule().withLogFile().withAutoStart();
+      new ServerStarterRule().withWorkingDir().withAutoStart();
   private File serverWorkingDir;
 
   @Before
@@ -99,37 +98,6 @@ public class ExportLogsFunctionIntegrationTest {
     assertThat(cache.getRegion(ExportLogsFunction.EXPORT_LOGS_REGION)).isNull();
   }
 
-
-  @Test
-  public void argsCorrectlyBuildALogLevelFilter() {
-    ExportLogsFunction.Args args =
-        new ExportLogsFunction.Args(null, null, "info", false, false, false);
-    assertThat(args.getLogLevel().toString()).isEqualTo("INFO");
-    assertThat(args.isThisLogLevelOnly()).isFalse();
-    assertThat(args.isIncludeLogs()).isTrue();
-    assertThat(args.isIncludeStats()).isTrue();
-  }
-
-  @Test
-  public void argsCorrectlyBuilt() {
-    ExportLogsFunction.Args args =
-        new ExportLogsFunction.Args(null, null, "error", true, true, false);
-    assertThat(args.getLogLevel()).isEqualTo(Level.ERROR);
-    assertThat(args.isThisLogLevelOnly()).isTrue();
-    assertThat(args.isIncludeLogs()).isTrue();
-    assertThat(args.isIncludeStats()).isFalse();
-  }
-
-  @Test
-  public void argsCorrectlyBuiltWithGeodeLevel() {
-    ExportLogsFunction.Args args =
-        new ExportLogsFunction.Args(null, null, "fine", true, true, false);
-    assertThat(args.getLogLevel()).isEqualTo(Level.DEBUG);
-    assertThat(args.isThisLogLevelOnly()).isTrue();
-    assertThat(args.isIncludeLogs()).isTrue();
-    assertThat(args.isIncludeStats()).isFalse();
-  }
-
   private static class CapturingResultSender implements ResultSender {
     private Throwable t;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionTest.java
index 4e72444..c57852d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionTest.java
@@ -16,15 +16,17 @@
 
 package org.apache.geode.management.internal.cli.functions;
 
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.geode.management.internal.cli.commands.ExportLogsCommand;
 import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Test;
-import org.apache.logging.log4j.Level;
-import org.junit.experimental.categories.Category;
 
 @Category(UnitTest.class)
 public class ExportLogsFunctionTest {
@@ -42,4 +44,34 @@ public class ExportLogsFunctionTest {
     assertEquals(args2.getLogLevel(), Level.ALL);
   }
 
+  @Test
+  public void argsCorrectlyBuildALogLevelFilter() {
+    ExportLogsFunction.Args args =
+        new ExportLogsFunction.Args(null, null, "info", false, false, false);
+    assertThat(args.getLogLevel().toString()).isEqualTo("INFO");
+    assertThat(args.isThisLogLevelOnly()).isFalse();
+    assertThat(args.isIncludeLogs()).isTrue();
+    assertThat(args.isIncludeStats()).isTrue();
+  }
+
+  @Test
+  public void argsCorrectlyBuilt() {
+    ExportLogsFunction.Args args =
+        new ExportLogsFunction.Args(null, null, "error", true, true, false);
+    assertThat(args.getLogLevel()).isEqualTo(Level.ERROR);
+    assertThat(args.isThisLogLevelOnly()).isTrue();
+    assertThat(args.isIncludeLogs()).isTrue();
+    assertThat(args.isIncludeStats()).isFalse();
+  }
+
+  @Test
+  public void argsCorrectlyBuiltWithGeodeLevel() {
+    ExportLogsFunction.Args args =
+        new ExportLogsFunction.Args(null, null, "fine", true, true, false);
+    assertThat(args.getLogLevel()).isEqualTo(Level.DEBUG);
+    assertThat(args.isThisLogLevelOnly()).isTrue();
+    assertThat(args.isIncludeLogs()).isTrue();
+    assertThat(args.isIncludeStats()).isFalse();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 12410c7..f9772c8 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
@@ -62,7 +62,7 @@ public class SizeExportLogsFunctionTest {
   public TestName testName = new TestName();
 
   @Rule
-  public ServerStarterRule server = new ServerStarterRule().withLogFile();
+  public ServerStarterRule server = new ServerStarterRule();
 
   @Before
   public void before() throws Throwable {
@@ -121,6 +121,8 @@ public class SizeExportLogsFunctionTest {
 
   @Test
   public void sizeGreaterThanDiskAvailable_sendsErrorResult() throws Throwable {
+    config.setProperty(LOG_FILE, logFile.getAbsolutePath());
+    config.setProperty(STATISTIC_ARCHIVE_FILE, statFile.getAbsolutePath());
     server.withProperties(config).startServer();
 
     FunctionContext context =

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 0cd6d5a..5ea3ac0 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
@@ -42,7 +42,7 @@ import org.apache.geode.test.junit.categories.IntegrationTest;
 public class LogExporterIntegrationTest {
 
   @Rule
-  public ServerStarterRule server = new ServerStarterRule().withLogFile();
+  public ServerStarterRule server = new ServerStarterRule().withWorkingDir();
 
   private LogExporter logExporter;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 35d65a0..f297018 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
@@ -40,7 +40,8 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 @Category(DistributedTest.class)
 public class MergeLogsDUnitTest {
   @Rule
-  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule().withLogFile();
+  public LocatorServerStartupRule lsRule =
+      new LocatorServerStartupRule().withTempWorkingDir().withLogFile();
   private MemberVM locator;
 
   private static final String MESSAGE_1 = "MergeLogsMessage1";

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
index 4d101e7..7c9981e 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
@@ -14,16 +14,14 @@
  */
 package org.apache.geode.management.internal.security;
 
-import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.assertj.core.api.SoftAssertions;
 import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.rules.RuleChain;
 
 import org.apache.geode.management.DiskStoreMXBean;
 import org.apache.geode.security.SimpleTestSecurityManager;
@@ -37,21 +35,18 @@ import org.apache.geode.test.junit.categories.SecurityTest;
 public class DiskStoreMXBeanSecurityJUnitTest {
   private DiskStoreMXBean bean;
 
-  @ClassRule
-  public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
-      .withProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName()).withAutoStart();
+  public ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withSecurityManager(SimpleTestSecurityManager.class).withAutoStart();
 
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    server.getCache().createDiskStoreFactory().create("diskstore");
-  }
-
-  @Rule
   public MBeanServerConnectionRule connectionRule =
       new MBeanServerConnectionRule(server::getJmxPort);
 
+  @Rule
+  public RuleChain ruleChain = RuleChain.outerRule(server).around(connectionRule);
+
   @Before
   public void setUp() throws Exception {
+    server.getCache().createDiskStoreFactory().create("diskstore");
     bean = connectionRule.getProxyMBean(DiskStoreMXBean.class);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index 872553e..df371d2 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -17,7 +17,13 @@ package org.apache.geode.test.dunit.rules;
 import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.util.function.Supplier;
+
 import org.apache.commons.lang.StringUtils;
+import org.json.JSONArray;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.Description;
+
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.HeadlessGfsh;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
@@ -25,11 +31,6 @@ import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.junit.rules.DescribedExternalResource;
-import org.json.JSONArray;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.Description;
-
-import java.util.function.Supplier;
 
 /**
  * Class which eases the connection to the locator/jmxManager in Gfsh shell and execute gfsh
@@ -88,15 +89,14 @@ public class GfshShellConnectionRule extends DescribedExternalResource
{
       return;
     }
 
-    // do not auto connect if it's not used with ConnectionConfiguration
     ConnectionConfiguration config = description.getAnnotation(ConnectionConfiguration.class);
     if (config == null) {
-      return;
+      connectAndVerify(portSupplier.get(), portType);
+    } else {
+      // when config is not null, developer may deliberately pass in a wrong
+      // password so that the test will verify the connection itself. So do not verify here.
+      secureConnect(portSupplier.get(), portType, config.user(), config.password());
     }
-
-    connect(portSupplier.get(), portType, CliStrings.CONNECT__USERNAME, config.user(),
-        CliStrings.CONNECT__PASSWORD, config.password());
-
   }
 
   public void connect(Member locator, String... options) throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 d8753cf..a455aff 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
@@ -67,8 +67,8 @@ public class LocatorServerStartupRule extends ExternalResource implements
Serial
   }
 
   /**
-   * 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.
+   * This 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
@@ -85,11 +85,9 @@ public class LocatorServerStartupRule extends ExternalResource implements
Serial
   }
 
   /**
-   * 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.
+   * this will allow all the logs go into log files instead of going into the console output
    */
   public LocatorServerStartupRule withLogFile() {
-    withTempWorkingDir();
     this.logFile = true;
     return this;
   }
@@ -126,14 +124,13 @@ public class LocatorServerStartupRule extends ExternalResource implements
Serial
     properties.setProperty(NAME, name);
     VM locatorVM = getHost(0).getVM(index);
     Locator locator = locatorVM.invoke(() -> {
+      locatorStarter = new LocatorStarterRule();
       if (useTempWorkingDir()) {
         File workingDirFile = createWorkingDirForMember(name);
-        locatorStarter = new LocatorStarterRule(workingDirFile);
-      } else {
-        locatorStarter = new LocatorStarterRule();
+        locatorStarter.withWorkingDir(workingDirFile);
       }
-
-      locatorStarter.withLogFile(logFile);
+      if (logFile)
+        locatorStarter.withLogFile();
       locatorStarter.withProperties(properties).withAutoStart();
       locatorStarter.before();
       return locatorStarter;
@@ -163,13 +160,13 @@ public class LocatorServerStartupRule extends ExternalResource implements
Serial
     properties.setProperty(NAME, name);
     VM serverVM = getHost(0).getVM(index);
     Server server = serverVM.invoke(() -> {
+      serverStarter = new ServerStarterRule();
       if (useTempWorkingDir()) {
         File workingDirFile = createWorkingDirForMember(name);
-        serverStarter = new ServerStarterRule(workingDirFile);
-      } else {
-        serverStarter = new ServerStarterRule();
+        serverStarter.withWorkingDir(workingDirFile);
       }
-      serverStarter.withLogFile(logFile);
+      if (logFile)
+        serverStarter.withLogFile();
       serverStarter.withProperties(properties).withConnectionToLocator(locatorPort).withAutoStart();
       serverStarter.before();
       return serverStarter;
@@ -192,13 +189,13 @@ public class LocatorServerStartupRule extends ExternalResource implements
Serial
 
     VM serverVM = getHost(0).getVM(index);
     Server server = serverVM.invoke(() -> {
+      serverStarter = new ServerStarterRule();
       if (useTempWorkingDir()) {
         File workingDirFile = createWorkingDirForMember(name);
-        serverStarter = new ServerStarterRule(workingDirFile);
-      } else {
-        serverStarter = new ServerStarterRule();
+        serverStarter.withWorkingDir(workingDirFile);
       }
-      serverStarter.withLogFile(logFile);
+      if (logFile)
+        serverStarter.withLogFile();
       serverStarter.withEmbeddedLocator().withName(name).withJMXManager().withAutoStart();
       serverStarter.before();
       return serverStarter;

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
index e1c14ce..7f787b2 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
@@ -18,14 +18,14 @@ package org.apache.geode.test.dunit.rules;
 import static org.apache.geode.distributed.Locator.startLocatorAndDS;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.InternalLocator;
-import org.awaitility.Awaitility;
-
-import java.io.File;
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
 
+import org.awaitility.Awaitility;
+
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.InternalLocator;
+
 /**
  * This is a rule to start up a locator in your current VM. It's useful for your Integration
Tests.
  *
@@ -46,12 +46,6 @@ public class LocatorStarterRule extends MemberStarterRule<LocatorStarterRule>
im
 
   private transient InternalLocator locator;
 
-  public LocatorStarterRule() {}
-
-  public LocatorStarterRule(File workingDir) {
-    super(workingDir);
-  }
-
   public InternalLocator getLocator() {
     return locator;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 156236b..a832a25 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
@@ -44,9 +44,9 @@ import org.apache.geode.security.SecurityManager;
  * duplication.
  */
 public abstract class MemberStarterRule<T> extends ExternalResource implements Member
{
-  protected transient TemporaryFolder temporaryFolder;
   protected String oldUserDir;
 
+  protected transient TemporaryFolder temporaryFolder;
   protected File workingDir;
   protected int memberPort = -1;
   protected int jmxPort = -1;
@@ -59,21 +59,45 @@ public abstract class MemberStarterRule<T> extends ExternalResource
implements M
   protected boolean autoStart = false;
 
   public MemberStarterRule() {
-    this(null);
-  }
-
-  // Not meant to be public, only used by LocatorServerStartupRule
-  MemberStarterRule(File workDir) {
     oldUserDir = System.getProperty("user.dir");
-    workingDir = workDir;
-    if (workDir != null) {
-      withWorkingDir();
-    }
+
     // initial values
     properties.setProperty(MCAST_PORT, "0");
     properties.setProperty(LOCATORS, "");
   }
 
+  public T withWorkingDir(File workingDir) {
+    this.workingDir = workingDir;
+    if (workingDir != null) {
+      System.setProperty("user.dir", workingDir.toString());
+    }
+    return (T) this;
+  }
+
+  /**
+   * create a working dir using temporaryFolder. Use with caution, this sets "user.dir" system
+   * property that not approved by JDK
+   */
+  public T withWorkingDir() {
+    temporaryFolder = new TemporaryFolder();
+    try {
+      temporaryFolder.create();
+    } catch (IOException e) {
+      throw new RuntimeException(e.getMessage(), e);
+    }
+    withWorkingDir(temporaryFolder.getRoot().getAbsoluteFile());
+    return (T) this;
+  }
+
+  /**
+   * All the logs are written in the logfile instead on the console. this is usually used
with
+   * withWorkingDir so that logs are accessible and will be cleaned up afterwards.
+   */
+  public T withLogFile() {
+    this.logFile = true;
+    return (T) this;
+  }
+
   @Override
   public void after() {
     // invoke stopMember() first and then ds.disconnect
@@ -84,15 +108,15 @@ public abstract class MemberStarterRule<T> extends ExternalResource
implements M
       ds.disconnect();
     }
 
+    if (temporaryFolder != null) {
+      temporaryFolder.delete();
+    }
+
     if (oldUserDir == null) {
       System.clearProperty("user.dir");
     } else {
       System.setProperty("user.dir", oldUserDir);
     }
-
-    if (temporaryFolder != null) {
-      temporaryFolder.delete();
-    }
   }
 
   public T withProperty(String key, String value) {
@@ -123,44 +147,6 @@ public abstract class MemberStarterRule<T> extends ExternalResource
implements M
     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;
-  }
-
   public T withConnectionToLocator(int locatorPort) {
     if (locatorPort > 0) {
       properties.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
@@ -221,12 +207,8 @@ public abstract class MemberStarterRule<T> extends ExternalResource
implements M
     }
 
     // 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
+    // do it here since only here, we can guarantee 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());
     }
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 0fd0e77..a645ce7 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,7 +18,6 @@ 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;
@@ -57,24 +56,6 @@ public class ServerStarterRule extends MemberStarterRule<ServerStarterRule>
impl
 
   private Map<String, RegionShortcut> regions = new HashMap<>();
 
-  /**
-   * Default constructor, if used, the rule will create a temporary folder as the server's
working
-   * dir, and will delete it when the test is done.
-   */
-  public ServerStarterRule() {
-    // nothing
-  }
-
-  /**
-   * if constructed this way, the rule won't be deleting the workingDir after the test is
done. It's
-   * the caller's responsibility to delete it.
-   * 
-   * @param workingDir: the working dir this server should be writing the artifacts to.
-   */
-  public ServerStarterRule(File workingDir) {
-    super(workingDir);
-  }
-
   public InternalCache getCache() {
     return cache;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/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 4970cb5..f1686d9 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
@@ -90,19 +90,19 @@ public class MemberStarterRuleTest {
   }
 
   @Test
-  public void userDirSetToWorkingDirWhenCreatedWithIt() throws Exception {
-    locator = new LocatorStarterRule().withWorkingDir();
+  public void logFileDoesNotCreatesWorkingDir() throws Exception {
+    locator = new LocatorStarterRule().withLogFile();
     locator.before();
 
-    assertThat(System.getProperty("user.dir")).isEqualTo(locator.getWorkingDir().toString());
+    assertThat(locator.getName()).isNotNull();
+    assertThat(locator.getWorkingDir()).isNull();
   }
 
   @Test
-  public void logInFileCreatesWorkingDir() throws Exception {
-    locator = new LocatorStarterRule().withLogFile();
+  public void workDirCreatesWorkDir() throws Exception {
+    locator = new LocatorStarterRule().withWorkingDir();
     locator.before();
 
-    assertThat(locator.getName()).isNotNull();
     assertThat(locator.getWorkingDir()).isNotNull();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/7f86d0cd/geode-web/src/test/java/org/apache/geode/management/internal/security/LogNoPasswordTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/security/LogNoPasswordTest.java
b/geode-web/src/test/java/org/apache/geode/management/internal/security/LogNoPasswordTest.java
index 368d64d..20359a9 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/security/LogNoPasswordTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/security/LogNoPasswordTest.java
@@ -38,7 +38,7 @@ public class LogNoPasswordTest {
   private static String PASSWORD = "abcdefghijklmn";
   @Rule
   public LocatorStarterRule locator = new LocatorStarterRule().withProperty(LOG_LEVEL, "DEBUG")
-      .withLogFile().withSecurityManager(MySecurityManager.class);
+      .withWorkingDir().withLogFile().withSecurityManager(MySecurityManager.class);
 
   @Rule
   public GfshShellConnectionRule gfsh = new GfshShellConnectionRule();


Mime
View raw message