geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [6/9] incubator-geode git commit: Reorganization of dunit
Date Fri, 21 Aug 2015 20:29:33 GMT
Reorganization of dunit


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

Branch: refs/heads/feature/GEODE-217
Commit: fcd214227656a79edc08fecbf655c9ae98114523
Parents: 49b2913
Author: Kirk Lund <klund@pivotal.io>
Authored: Fri Aug 21 13:14:16 2015 -0700
Committer: Kirk Lund <klund@pivotal.io>
Committed: Fri Aug 21 13:14:16 2015 -0700

----------------------------------------------------------------------
 build.gradle                                    |   5 +-
 .../distributed/DistributedMemberDUnitTest.java |   2 +-
 .../distributed/HostedLocatorsDUnitTest.java    |   4 +-
 .../gemfire/internal/cache/BackupDUnitTest.java |  15 +-
 .../offheap/OutOfOffHeapMemoryDUnitTest.java    |   4 +-
 .../internal/process/PidFileJUnitTest.java      |   4 +-
 .../catchexception/CatchExceptionDUnitTest.java |  63 --
 .../catchexception/CatchExceptionJUnitTest.java |  95 ---
 .../gemstone/gemfire/test/dunit/DUnitEnv.java   | 100 +++
 .../gemfire/test/dunit/DistributedTestCase.java | 687 +++++++++----------
 .../com/gemstone/gemfire/test/dunit/Invoke.java |   1 -
 .../com/gemstone/gemfire/test/dunit/Jitter.java |   2 +-
 .../test/dunit/SerializableRunnable.java        |   4 +-
 .../com/gemstone/gemfire/test/dunit/Wait.java   |   3 +
 .../gemfire/test/dunit/cache/CacheTestCase.java |   4 +-
 .../test/dunit/tests/BasicDUnitTest.java        |   9 +-
 .../dunit/tests/DUnitFrameworkTestSuite.java    |  16 -
 .../gemfire/test/dunit/tests/VMDUnitTest.java   |   3 +
 .../golden/GoldenTestFrameworkTestSuite.java    |  27 -
 .../test/junit/rules/ExpectedTimeout.java       | 164 -----
 .../junit/rules/ExpectedTimeoutJUnitTest.java   | 188 -----
 21 files changed, 462 insertions(+), 938 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 0311206..b98cdf0 100755
--- a/build.gradle
+++ b/build.gradle
@@ -282,13 +282,12 @@ subprojects {
     testCompile 'eu.codearte.catch-exception:catch-throwable:1.4.4'
     testCompile 'junit:junit:4.12'
     testCompile 'org.assertj:assertj-core:2.1.0'
-    testCompile 'org.easytesting:fest-test:2.1.0'
-    testCompile 'org.mockito:mockito-core:1.10.19'
+    testCompile 'org.easetech:easytest-core:1.3.2'
     testCompile 'org.hamcrest:hamcrest-all:1.3'
     testCompile 'org.jmock:jmock:2.8.1'
     testCompile 'org.jmock:jmock-junit4:2.8.1'
     testCompile 'org.jmock:jmock-legacy:2.8.1'
-    testCompile 'org.unitils:unitils:3.4.2'
+    testCompile 'org.mockito:mockito-core:1.10.19'
     testCompile 'pl.pragmatists:JUnitParams:1.0.4'
 
     testRuntime 'cglib:cglib:3.1'

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedMemberDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedMemberDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedMemberDUnitTest.java
index e45b02d..1f6edab 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedMemberDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedMemberDUnitTest.java
@@ -281,7 +281,7 @@ public class DistributedMemberDUnitTest extends DistributedTestCase {
         public void run() {
           InternalDistributedSystem sys = getSystem();
           final String expectedMyGroup = makeGroupsString(vm);
-          assertEquals(expectedMyGroup, sys.getConfig().getGroups());
+          assertEquals("vm-"+vm, expectedMyGroup, sys.getConfig().getGroups());
           
           DM dm = sys.getDistributionManager();
           DistributedMember self = sys.getDistributedMember();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
index e74e12f..f77f50d 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
@@ -37,7 +37,7 @@ import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import com.gemstone.gemfire.test.junit.categories.MembershipTest;
-import com.gemstone.gemfire.test.junit.rules.Retry;
+import com.gemstone.gemfire.test.junit.rules.RetryRule;
 
 /**
  * Extracted from LocatorLauncherLocalJUnitTest.
@@ -61,7 +61,7 @@ public class HostedLocatorsDUnitTest extends DistributedTestCase {
   public final transient Timeout globalTimeout = Timeout.seconds(2 * 60 * 1000);
   
   @Rule
-  public final transient Retry retry = new Retry(2);
+  public final transient RetryRule retry = new RetryRule(2);
   
   @Before
   public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/BackupDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/BackupDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/BackupDUnitTest.java
index 5829451..e7b9261 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/BackupDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/BackupDUnitTest.java
@@ -41,9 +41,10 @@ import com.gemstone.gemfire.distributed.internal.DistributionMessageObserver;
 import com.gemstone.gemfire.distributed.internal.ReplyMessage;
 import com.gemstone.gemfire.internal.FileUtil;
 import com.gemstone.gemfire.internal.cache.partitioned.PersistentPartitionedRegionTestBase;
+import com.gemstone.gemfire.internal.process.PidUnavailableException;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
 
 import dunit.AsyncInvocation;
-import dunit.DUnitEnv;
 import dunit.Host;
 import dunit.SerializableCallable;
 import dunit.SerializableRunnable;
@@ -533,10 +534,18 @@ public class BackupDUnitTest extends PersistentPartitionedRegionTestBase {
     vm.invoke(validateUserFileBackup);
   }
 
+  private int identifyPid() {
+    try {
+      return ProcessUtils.identifyPid();
+    } catch (PidUnavailableException e) {
+      throw new AssertionError(e.getMessage(), e);
+    }
+  }
+  
   protected long setBackupFiles(final VM vm) {
     SerializableCallable setUserBackups = new SerializableCallable("set user backups") {
       public Object call() {
-        final int pid = DUnitEnv.get().getPid();
+        final int pid = identifyPid();
         File vmdir = new File("userbackup_"+pid);
         File test1 = new File(vmdir, "test1");
         File test2 = new File(test1, "test2");
@@ -568,7 +577,7 @@ public class BackupDUnitTest extends PersistentPartitionedRegionTestBase {
   protected void verifyUserFileRestored(VM vm, final long lm) {
     vm.invoke(new SerializableRunnable() {
       public void run() {
-        final int pid = DUnitEnv.get().getPid();
+        final int pid = identifyPid();
         File vmdir = new File("userbackup_"+pid);
         File mytext = new File(vmdir, "test1/test2/my.txt");
         assertTrue(mytext.exists());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
index 644d82c..72b64e6 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
@@ -56,7 +56,7 @@ public class OutOfOffHeapMemoryDUnitTest extends CacheTestCase {
   }
   
   @Override
-  public void tearDown2() throws Exception {
+  public void tearDownBefore() throws Exception {
     final SerializableRunnable checkOrphans = new SerializableRunnable() {
       @Override
       public void run() {
@@ -70,7 +70,7 @@ public class OutOfOffHeapMemoryDUnitTest extends CacheTestCase {
       checkOrphans.run();
     } finally {
       invokeInEveryVM(getClass(), "cleanup");
-      super.tearDown2();
+      super.tearDownBefore();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
index e1ad29b..836712b 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
@@ -26,7 +26,7 @@ import org.junit.rules.TemporaryFolder;
 
 import com.gemstone.gemfire.internal.util.StopWatch;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.gemstone.gemfire.test.junit.rules.ExpectedTimeout;
+import com.gemstone.gemfire.test.junit.rules.ExpectedTimeoutRule;
 
 /**
  * Unit tests the PidFile class.
@@ -44,7 +44,7 @@ public class PidFileJUnitTest {
   public ExpectedException thrown = ExpectedException.none();
   
   @Rule
-  public ExpectedTimeout timeout = ExpectedTimeout.none();
+  public ExpectedTimeoutRule timeout = ExpectedTimeoutRule.none();
   
   protected Mockery mockContext;
   private ExecutorService futures;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/catchexception/CatchExceptionDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/catchexception/CatchExceptionDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/catchexception/CatchExceptionDUnitTest.java
deleted file mode 100755
index a3fc1f1..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/catchexception/CatchExceptionDUnitTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.gemstone.gemfire.test.catchexception;
-
-import static com.googlecode.catchexception.CatchException.*;
-import static com.googlecode.catchexception.apis.BDDCatchException.when;
-import static com.googlecode.catchexception.apis.CatchExceptionHamcrestMatchers.*;
-import static org.assertj.core.api.BDDAssertions.*;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.RMIException;
-import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.VM;
-
-/**
- * Using Catch-Exception works well for remote exceptions and asserting details
- * about root cause of RMIExceptions in DUnit tests.
- */
-public class CatchExceptionDUnitTest extends DistributedTestCase {
-  private static final long serialVersionUID = 1L;
-
-  private static final String REMOTE_THROW_EXCEPTION_MESSAGE = "Throwing remoteThrowException";
-
-  @Test
-  public void testRemoteInvocationWithException() {
-    Host host = Host.getHost(0);
-    VM vm = host.getVM(0);
-
-    when(vm).invoke(new ThrowBasicTestException());
-
-    then(caughtException())
-        .isInstanceOf(RMIException.class)
-        .hasCause(new BasicTestException(REMOTE_THROW_EXCEPTION_MESSAGE));
-  }
-  
-  protected static class ThrowBasicTestException extends SerializableCallable<Object> {
-    private static final long serialVersionUID = 1L;
-    
-    @Override
-    public Object call() throws Exception {
-      throw new BasicTestException(REMOTE_THROW_EXCEPTION_MESSAGE);
-    }
-  }
-  
-  protected static class BasicTestException extends RuntimeException {
-    private static final long serialVersionUID = 1L;
-
-    public BasicTestException() {
-      super();
-    }
-    
-    public BasicTestException(String message) {
-      super(message);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/catchexception/CatchExceptionJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/catchexception/CatchExceptionJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/catchexception/CatchExceptionJUnitTest.java
deleted file mode 100755
index d197745..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/catchexception/CatchExceptionJUnitTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package com.gemstone.gemfire.test.catchexception;
-
-import static com.googlecode.catchexception.CatchException.*;
-import static com.googlecode.catchexception.apis.BDDCatchException.when;
-import static com.googlecode.catchexception.apis.CatchExceptionHamcrestMatchers.*;
-import static org.assertj.core.api.BDDAssertions.*;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-/**
- * Simple unit tests exercising Catch-Exception with AssertJ, Hamcrest and JUnit.
- */
-public class CatchExceptionJUnitTest {
-
-  @Test
-  public void catchExceptionShouldCatchException() {
-    List<?> myList = new ArrayList<Object>();
-
-    // when: we try to get the first element of the list
-    // then: catch the exception if any is thrown
-    catchException(myList).get(1);
-    
-    // then: we expect an IndexOutOfBoundsException
-    assertThat(caughtException(), is(instanceOf(IndexOutOfBoundsException.class)));
-  }
-  
-  @Test
-  public void verifyExceptionShouldCatchException() {
-    List<?> myList = new ArrayList<Object>();
-
-    // when: we try to get the first element of the list
-    // then: catch the exception if any is thrown
-    // then: we expect an IndexOutOfBoundsException
-    verifyException(myList, IndexOutOfBoundsException.class).get(1);
-  }
-  
-  @Test
-  public void whenShouldCatchExceptionAndUseAssertJAssertion() {
-    // given: an empty list
-    List<?> myList = new ArrayList<Object>();
-
-    // when: we try to get the first element of the list
-    when(myList).get(1);
-
-    // then: we expect an IndexOutOfBoundsException
-    then(caughtException())
-            .isInstanceOf(IndexOutOfBoundsException.class)
-            .hasMessage("Index: 1, Size: 0")
-            .hasNoCause();
-  }
-  
-  @Test
-  public void catchExceptionShouldCatchExceptionAndUseHamcrestAssertion() {
-    // given: an empty list
-    List<?> myList = new ArrayList<Object>();
-
-    // when: we try to get the first element of the list
-    catchException(myList).get(1);
-
-    // then: we expect an IndexOutOfBoundsException with message "Index: 1, Size: 0"
-    assertThat(caughtException(),
-      allOf(
-        instanceOf(IndexOutOfBoundsException.class),
-        hasMessage("Index: 1, Size: 0"),
-        hasNoCause()
-      )
-    );
-  }
-  
-  @Test
-  public void shouldCatchFromThrowException() throws Exception {
-    String message = "error message";
-    
-    catchException(this).throwException(message);
-    
-    assertThat(caughtException(), is(instanceOf(Exception.class)));
-  }
-  
-  @Test
-  public void shouldVerifyFromThrowException() throws Exception {
-    String message = "error message";
-
-    verifyException(this).throwException(message);
-  }
-  
-  // fails if private
-  protected void throwException(final String message) throws Exception {
-    throw new Exception(message);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitEnv.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitEnv.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitEnv.java
index 96ebd7d..944ad2e 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitEnv.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitEnv.java
@@ -12,8 +12,16 @@ package com.gemstone.gemfire.test.dunit;
 
 import java.io.File;
 import java.rmi.RemoteException;
+import java.util.Iterator;
+import java.util.Map;
 import java.util.Properties;
 
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
+import com.gemstone.gemfire.internal.logging.LogWriterFactory;
+import com.gemstone.gemfire.internal.logging.ManagerLogWriter;
+
 /**
  * This class provides an abstraction over the environment
  * that is used to run dunit. This will delegate to the hydra
@@ -64,5 +72,97 @@ public abstract class DUnitEnv {
   public abstract BounceResult bounce(int pid) throws RemoteException;
 
   public abstract File getWorkingDirectory(int pid);
+
+  //---------------------------------------------------------------------------
+  // static methods
+  //---------------------------------------------------------------------------
   
+  public static final Properties getAllDistributedSystemProperties(Properties props) { // TODO: delete
+    Properties p = DUnitEnv.get().getDistributedSystemProperties();
+    
+    // our tests do not expect auto-reconnect to be on by default
+    if (!p.contains(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME)) {
+      p.put(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true");
+    }
+        
+    for (Iterator iter = props.entrySet().iterator();
+    iter.hasNext(); ) {
+      Map.Entry entry = (Map.Entry) iter.next();
+      String key = (String) entry.getKey();
+      Object value = entry.getValue();
+      p.put(key, value);
+    }
+    return p;
+  }
+
+  /**
+   * This finds the log level configured for the test run.  It should be used
+   * when creating a new distributed system if you want to specify a log level.
+   * 
+   * @return the dunit log-level setting
+   */
+  public static String getDUnitLogLevel() { // TODO: delete
+    Properties p = DUnitEnv.get().getDistributedSystemProperties();
+    String result = p.getProperty(DistributionConfig.LOG_LEVEL_NAME);
+    if (result == null) {
+      result = ManagerLogWriter.levelToString(DistributionConfig.DEFAULT_LOG_LEVEL);
+    }
+    return result;
+  }
+
+  /**
+   * Get the port that the standard dunit locator is listening on.
+   * @return
+   */
+  public static int getDUnitLocatorPort() {
+    return DUnitEnv.get().getLocatorPort();
+  }
+    
+  /**
+   * Creates a new LogWriter and adds it to the config properties. The config
+   * can then be used to connect to DistributedSystem, thus providing early
+   * access to the LogWriter before connecting. This call does not connect
+   * to the DistributedSystem. It simply creates and returns the LogWriter
+   * that will eventually be used by the DistributedSystem that connects using
+   * config.
+   * 
+   * @param config the DistributedSystem config properties to add LogWriter to
+   * @return early access to the DistributedSystem LogWriter
+   */
+  protected static LogWriter createLogWriter(Properties config) {
+    Properties nonDefault = config;
+    if (nonDefault == null) {
+      nonDefault = new Properties();
+    }
+    addHydraProperties(nonDefault);
+    
+    DistributionConfig dc = new DistributionConfigImpl(nonDefault);
+    LogWriter logger = LogWriterFactory.createLogWriterLogger(
+        false/*isLoner*/, false/*isSecurityLog*/, dc, 
+        false);        
+    
+    // if config was non-null, then these will be added to it...
+    nonDefault.put(DistributionConfig.LOG_WRITER_NAME, logger);
+    
+    return logger;
+  }
+
+  /**
+   * Fetches the GemFireDescription for this test and adds its 
+   * DistributedSystem properties to the provided props parameter.
+   * 
+   * @param config the properties to add hydra's test properties to
+   */
+  private static void addHydraProperties(Properties config) {
+    Properties p = DUnitEnv.get().getDistributedSystemProperties();
+    for (Iterator iter = p.entrySet().iterator();
+        iter.hasNext(); ) {
+      Map.Entry entry = (Map.Entry) iter.next();
+      String key = (String) entry.getKey();
+      String value = (String) entry.getValue();
+      if (config.getProperty(key) == null) {
+        config.setProperty(key, value);
+      }
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
index 5eb3b0b..abb0a95 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
@@ -1,11 +1,9 @@
 package com.gemstone.gemfire.test.dunit;
 
+import static com.gemstone.gemfire.test.dunit.DUnitEnv.*;
 import static com.gemstone.gemfire.test.dunit.Invoke.*;
-import static com.gemstone.gemfire.test.dunit.Wait.*;
 import static org.junit.Assert.*;
 
-import java.io.File;
-import java.net.UnknownHostException;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
@@ -28,7 +26,6 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.DistributionMessageObserver;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.CreationStackGenerator;
-import com.gemstone.gemfire.distributed.internal.membership.jgroup.MembershipManagerHelper;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.InternalDataSerializer;
 import com.gemstone.gemfire.internal.InternalInstantiator;
@@ -42,11 +39,8 @@ import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID;
 import com.gemstone.gemfire.internal.cache.tier.sockets.DataSerializerPropogationDUnitTest;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.logging.ManagerLogWriter;
 import com.gemstone.gemfire.internal.logging.log4j.LogWriterLogger;
 import com.gemstone.gemfire.management.internal.cli.LogWrapper;
-import com.gemstone.org.jgroups.Event;
-import com.gemstone.org.jgroups.JChannel;
 import com.gemstone.org.jgroups.stack.IpAddress;
 import com.gemstone.org.jgroups.stack.Protocol;
 import com.gemstone.org.jgroups.util.GemFireTracer;
@@ -58,20 +52,22 @@ import com.gemstone.gemfire.test.dunit.standalone.DUnitLauncher;
  *
  * @author David Whitlock
  */
-@SuppressWarnings({ "deprecation", "serial", "rawtypes" })
+@SuppressWarnings({ "deprecation", "rawtypes" })
 public abstract class DistributedTestCase implements java.io.Serializable {
+  private static final long serialVersionUID = 1L;
   private static final Logger logger = LogService.getLogger();
   private static final LogWriterLogger oldLogger = LogWriterLogger.create(logger);
 
   @Rule
   public transient TestName testNameRule = new TestName();
+  private static volatile String previousTestName;
+  private static volatile String testName;
   
-  public static InternalDistributedSystem system;
-  private static Class lastSystemCreatedInTest;
-  private static Properties lastSystemProperties;
-  public static volatile String testName;
+  private static InternalDistributedSystem system;
+  private static Class previousSystemCreatedInTestClass;
+  private static Properties previousProperties;
   
-  public static final boolean logPerTest = Boolean.getBoolean("dunitLogPerTest");
+  private final boolean logPerTest = Boolean.getBoolean("dunitLogPerTest");
 
   /**
    * Creates a new <code>DistributedTestCase</code> test.
@@ -80,85 +76,137 @@ public abstract class DistributedTestCase implements java.io.Serializable {
     DUnitLauncher.launchIfNeeded();
   }
 
-  private static void setUpCreationStackGenerator() {
-    // the following is moved from InternalDistributedSystem to fix #51058
-    InternalDistributedSystem.TEST_CREATION_STACK_GENERATOR.set(
-    new CreationStackGenerator() {
+  //---------------------------------------------------------------------------
+  // setUp methods
+  //---------------------------------------------------------------------------
+  
+  @Before
+  public final void setUpDistributedTestCase() throws Exception {
+    setUpCreationStackGenerator();
+    testName = getMethodName();
+    
+    System.setProperty(HoplogConfig.ALLOW_LOCAL_HDFS_PROP, "true");
+    GemFireCacheImpl.setDefaultDiskStoreName(getDefaultDiskStoreName()); // TODO: not thread safe
+    
+    for (int h = 0; h < Host.getHostCount(); h++) {
+      Host host = Host.getHost(h);
+      for (int v = 0; v < host.getVMCount(); v++) {
+        VM vm = host.getVM(v);
+        final String vmDefaultDiskStoreName = "DiskStore-" + h + "-" + v + "-" + getClass().getSimpleName() + "." + testName;
+        setUpInVM(vm, testName, vmDefaultDiskStoreName);
+      }
+    }
+    //System.out.println("\n\n[setup] START TEST " + getClass().getSimpleName()+"."+testName+"\n\n");
+  }
+
+  private void setUpInVM(final VM vm, final String testNameToUse, final String diskStoreNameToUse) {
+    vm.invoke(new SerializableRunnable() {
+      private static final long serialVersionUID = 1L;
+
       @Override
-      public Throwable generateCreationStack(final DistributionConfig config) {
-        final StringBuilder sb = new StringBuilder();
-        final String[] validAttributeNames = config.getAttributeNames();
-        for (int i = 0; i < validAttributeNames.length; i++) {
-          final String attName = validAttributeNames[i];
-          final Object actualAtt = config.getAttributeObject(attName);
-          String actualAttStr = actualAtt.toString();
-          sb.append("  ");
-          sb.append(attName);
-          sb.append("=\"");
-          if (actualAtt.getClass().isArray()) {
-            actualAttStr = InternalDistributedSystem.arrayToString(actualAtt);
-          }
-          sb.append(actualAttStr);
-          sb.append("\"");
-          sb.append("\n");
-        }
-        return new Throwable("Creating distributed system with the following configuration:\n" + sb.toString());
+      public void run() {
+        setUpCreationStackGenerator();
+        testName = testNameToUse;
+        System.setProperty(HoplogConfig.ALLOW_LOCAL_HDFS_PROP, "true");    
+        GemFireCacheImpl.setDefaultDiskStoreName(diskStoreNameToUse); // TODO: not thread safe
       }
     });
   }
   
-  private static void tearDownCreationStackGenerator() {
-    InternalDistributedSystem.TEST_CREATION_STACK_GENERATOR.set(InternalDistributedSystem.DEFAULT_CREATION_STACK_GENERATOR);
+  //---------------------------------------------------------------------------
+  // tearDown methods
+  //---------------------------------------------------------------------------
+  
+  /**
+   * For logPerTest to work, we have to disconnect from the DS, but all
+   * subclasses do not call super.tearDown(). To prevent this scenario
+   * this method has been declared final. Subclasses must now override
+   * {@link #tearDownBefore()} instead.
+   * @throws Exception
+   */
+  @After
+  public final void tearDownDistributedTestCase() throws Exception {
+    tearDownBefore();
+    realTearDown();
+    tearDownAfter();
+    
+    tearDownCreationStackGenerator();
+    previousTestName = testName;
+    testName = null;
+
+    tearDownInEveryVM();
+  }
+
+  private void tearDownInEveryVM() {
+    invokeInEveryVM(new SerializableRunnable() {
+      private static final long serialVersionUID = 1L;
+
+      @Override
+      public void run() {    
+        tearDownCreationStackGenerator();
+        previousTestName = testName;
+        testName = null;
+      }
+    });
   }
   
-  private Class getTestClass() {
-    Class clazz = getClass();
-    while (clazz.getDeclaringClass() != null) {
-      clazz = clazz.getDeclaringClass();
+  protected void realTearDown() throws Exception {
+    if (logPerTest) {
+      disconnectFromDS();
+      invokeInEveryVM(DistributedTestCase.class, "disconnectFromDS");
     }
-    return clazz;
+    cleanupAllVms();
   }
   
   /**
-   * This finds the log level configured for the test run.  It should be used
-   * when creating a new distributed system if you want to specify a log level.
-   * 
-   * @return the dunit log-level setting
+   * Tears down the test. This method is called by the final {@link #tearDown()} method and should be overridden to
+   * perform actual test cleanup and release resources used by the test.  The tasks executed by this method are
+   * performed before the DUnit test framework using Hydra cleans up the client VMs.
+   * <p/>
+   * @throws Exception if the tear down process and test cleanup fails.
+   * @see #tearDown
+   * @see #tearDownAfter()
    */
-  public static String getDUnitLogLevel() { // TODO: delete
-    Properties p = DUnitEnv.get().getDistributedSystemProperties();
-    String result = p.getProperty(DistributionConfig.LOG_LEVEL_NAME);
-    if (result == null) {
-      result = ManagerLogWriter.levelToString(DistributionConfig.DEFAULT_LOG_LEVEL);
-    }
-    return result;
+  protected void tearDownBefore() throws Exception {
   }
 
-  public final static Properties getAllDistributedSystemProperties(Properties props) { // TODO: delete
-    Properties p = DUnitEnv.get().getDistributedSystemProperties();
-    
-    // our tests do not expect auto-reconnect to be on by default
-    if (!p.contains(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME)) {
-      p.put(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true");
-    }
-        
-    for (Iterator iter = props.entrySet().iterator();
-    iter.hasNext(); ) {
-      Map.Entry entry = (Map.Entry) iter.next();
-      String key = (String) entry.getKey();
-      Object value = entry.getValue();
-      p.put(key, value);
-    }
-    return p;
+  /**
+   * Tears down the test.  Performs additional tear down tasks after the DUnit tests framework using Hydra cleans up
+   * the client VMs.  This method is called by the final {@link #tearDown()} method and should be overridden to perform
+   * post tear down activities.
+   * <p/>
+   * @throws Exception if the test tear down process fails.
+   * @see #tearDown()
+   * @see #tearDownBefore()
+   */
+  protected void tearDownAfter() throws Exception {
   }
 
-  public void setSystem(Properties props, DistributedSystem ds) { // TODO: delete
-    system = (InternalDistributedSystem)ds;
-    lastSystemProperties = props;
-    lastSystemCreatedInTest = getTestClass();
+  //---------------------------------------------------------------------------
+  // test name methods
+  //---------------------------------------------------------------------------
+  
+  public final String getMethodName() {
+    return this.testNameRule.getMethodName();
   }
   
   /**
+   * Returns a unique name for this test method.  It is based on the
+   * name of the class as well as the name of the method.
+   */
+  public final String getUniqueName() { // TODO: consider using FQCN
+    return getClass().getSimpleName() + "_" + getTestName();
+  }
+
+  protected static String getTestName() {
+    return testName;
+  }
+
+  //---------------------------------------------------------------------------
+  // public final methods
+  //---------------------------------------------------------------------------
+  
+  /**
    * Returns this VM's connection to the distributed system.  If
    * necessary, the connection will be lazily created using the given
    * <code>Properties</code>.  Note that this method uses hydra's
@@ -169,125 +217,127 @@ public abstract class DistributedTestCase implements java.io.Serializable {
    * @see hydra.DistributedConnectionMgr#connect
    * @since 3.0
    */
-  public final InternalDistributedSystem getSystem(Properties props) {
-    // Setting the default disk store name is now done in setUp
+  public final InternalDistributedSystem getSystem(Properties properties) {
     if (system == null) {
       system = InternalDistributedSystem.getAnyInstance();
     }
+    
     if (system == null || !system.isConnected()) {
-      // Figure out our distributed system properties
-      Properties p = getAllDistributedSystemProperties(props);
-      lastSystemCreatedInTest = getTestClass();
+      // there is no previous system yet
+      final Properties newProperties = getAllDistributedSystemProperties(properties);
+      previousSystemCreatedInTestClass = getTestClass();
       if (logPerTest) {
-        String testMethod = getTestName();
-        String testName = lastSystemCreatedInTest.getName() + '-' + testMethod;
-        String oldLogFile = p.getProperty(DistributionConfig.LOG_FILE_NAME);
-        p.put(DistributionConfig.LOG_FILE_NAME, 
-            oldLogFile.replace("system.log", testName+".log"));
-        String oldStatFile = p.getProperty(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME);
-        p.put(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME, 
-            oldStatFile.replace("statArchive.gfs", testName+".gfs"));
+        newProperties.put(DistributionConfig.LOG_FILE_NAME, getUniqueName() + ".log");
+        newProperties.put(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME, getUniqueName() + ".gfs");
       }
-      system = (InternalDistributedSystem)DistributedSystem.connect(p);
-      lastSystemProperties = p;
+      system = (InternalDistributedSystem)DistributedSystem.connect(newProperties);
+      previousProperties = newProperties;
+      
     } else {
+      // there is a previous system
       boolean needNewSystem = false;
-      if(!getTestClass().equals(lastSystemCreatedInTest)) {
-        Properties newProps = getAllDistributedSystemProperties(props);
-        needNewSystem = !newProps.equals(lastSystemProperties);
-        if(needNewSystem) {
-          getLogWriter().info(
+      //if (!getUniqueName().equals(previousTestName)) {
+      if (!getTestClass().equals(previousSystemCreatedInTestClass)) {
+        // previous system was created in a previous test class
+        final Properties newProperties = getAllDistributedSystemProperties(properties);
+        if (logPerTest) {
+          newProperties.put(DistributionConfig.LOG_FILE_NAME, getUniqueName() + ".log");
+          newProperties.put(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME, getUniqueName() + ".gfs");
+        }
+        needNewSystem = !newProperties.equals(previousProperties);
+        if (needNewSystem) {
+          logger.info(
               "Test class has changed and the new DS properties are not an exact match. "
                   + "Forcing DS disconnect. Old props = "
-                  + lastSystemProperties + "new props=" + newProps);
+                  + previousProperties + "new props=" + newProperties);
         }
+        
       } else {
-        Properties activeProps = system.getProperties();
-        for (Iterator iter = props.entrySet().iterator();
-        iter.hasNext(); ) {
-          Map.Entry entry = (Map.Entry) iter.next();
-          String key = (String) entry.getKey();
-          String value = (String) entry.getValue();
-          if (!value.equals(activeProps.getProperty(key))) {
+        // previous system was created in this test class
+        final Properties currentProperties = system.getProperties();
+        for (Iterator iter = properties.entrySet().iterator(); iter.hasNext(); ) {
+          final Map.Entry entry = (Map.Entry) iter.next();
+          final String key = (String) entry.getKey();
+          final String value = (String) entry.getValue();
+          if (!value.equals(currentProperties.getProperty(key))) {
             needNewSystem = true;
-            getLogWriter().info("Forcing DS disconnect. For property " + key
-                                + " old value = " + activeProps.getProperty(key)
+            logger.info("Forcing DS disconnect. For property " + key
+                                + " old value = " + currentProperties.getProperty(key)
                                 + " new value = " + value);
             break;
           }
         }
       }
-      if(needNewSystem) {
+      
+      if (needNewSystem) {
         // the current system does not meet our needs to disconnect and
         // call recursively to get a new system.
-        getLogWriter().info("Disconnecting from current DS in order to make a new one");
+        logger.info("Disconnecting from current DS in order to make a new one");
         disconnectFromDS();
-        getSystem(props);
+        getSystem(properties);
       }
     }
     return system;
   }
-
-  /**
-   * Crash the cache in the given VM in such a way that it immediately stops communicating with
-   * peers.  This forces the VM's membership manager to throw a ForcedDisconnectException by
-   * forcibly terminating the JGroups protocol stack with a fake EXIT event.<p>
-   * 
-   * NOTE: if you use this method be sure that you clean up the VM before the end of your
-   * test with disconnectFromDS() or disconnectAllFromDS().
-   */
-  public static boolean crashDistributedSystem(VM vm) { // TODO: move
-    return (Boolean)vm.invoke(new SerializableCallable("crash distributed system") {
-      public Object call() throws Exception {
-        DistributedSystem msys = InternalDistributedSystem.getAnyInstance();
-        crashDistributedSystem(msys);
-        return true;
-      }
-    });
-  }
   
-  /**
-   * Crash the cache in the given VM in such a way that it immediately stops communicating with
-   * peers.  This forces the VM's membership manager to throw a ForcedDisconnectException by
-   * forcibly terminating the JGroups protocol stack with a fake EXIT event.<p>
-   * 
-   * NOTE: if you use this method be sure that you clean up the VM before the end of your
-   * test with disconnectFromDS() or disconnectAllFromDS().
-   */
-  public static void crashDistributedSystem(final DistributedSystem msys) { // TODO: move
-    MembershipManagerHelper.inhibitForcedDisconnectLogging(true);
-    MembershipManagerHelper.playDead(msys);
-    JChannel c = MembershipManagerHelper.getJChannel(msys);
-    Protocol udp = c.getProtocolStack().findProtocol("UDP");
-    udp.stop();
-    udp.passUp(new Event(Event.EXIT, new RuntimeException("killing member's ds")));
-    try {
-      MembershipManagerHelper.getJChannel(msys).waitForClose();
-    }
-    catch (InterruptedException ie) {
-      Thread.currentThread().interrupt();
-      // attempt rest of work with interrupt bit set
-    }
-    MembershipManagerHelper.inhibitForcedDisconnectLogging(false);
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        return !msys.isConnected();
-      }
-      public String description() {
-        return "waiting for distributed system to finish disconnecting: " + msys;
-      }
-    };
-//    try {
-      waitForCriterion(wc, 10000, 1000, true);
-//    } finally {
-//      dumpMyThreads(getLogWriter());
+//  public /*final*/ InternalDistributedSystem getSystem(Properties props) {
+//    // Setting the default disk store name is now done in setUp
+//    if (system == null) {
+//      system = InternalDistributedSystem.getAnyInstance();
 //    }
-  }
-
-  private String getDefaultDiskStoreName() { // TODO: move
-    String vmid = System.getProperty("vmid");
-    return "DiskStore-"  + vmid + "-"+ getTestClass().getCanonicalName() + "." + getTestName();
-  }
+//    if (system == null || !system.isConnected()) {
+//      // Figure out our distributed system properties
+//      Properties p = getAllDistributedSystemProperties(props);
+//      lastSystemCreatedInTest = getTestClass();
+//      if (logPerTest) {
+//        String testMethod = getTestName();
+//        String testName = lastSystemCreatedInTest.getName() + '-' + testMethod;
+//        String oldLogFile = p.getProperty(DistributionConfig.LOG_FILE_NAME);
+//        p.put(DistributionConfig.LOG_FILE_NAME, 
+//            oldLogFile.replace("system.log", testName+".log"));
+//        String oldStatFile = p.getProperty(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME);
+//        p.put(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME, 
+//            oldStatFile.replace("statArchive.gfs", testName+".gfs"));
+//      }
+//      system = (InternalDistributedSystem)DistributedSystem.connect(p);
+//      previousProperties = p;
+//    } else {
+//      boolean needNewSystem = false;
+//      if(!getTestClass().equals(lastSystemCreatedInTest)) {
+//        Properties newProps = getAllDistributedSystemProperties(props);
+//        needNewSystem = !newProps.equals(previousProperties);
+//        if(needNewSystem) {
+//          getLogWriter().info(
+//              "Test class has changed and the new DS properties are not an exact match. "
+//                  + "Forcing DS disconnect. Old props = "
+//                  + previousProperties + "new props=" + newProps);
+//        }
+//      } else {
+//        Properties activeProps = system.getProperties();
+//        for (Iterator iter = props.entrySet().iterator();
+//        iter.hasNext(); ) {
+//          Map.Entry entry = (Map.Entry) iter.next();
+//          String key = (String) entry.getKey();
+//          String value = (String) entry.getValue();
+//          if (!value.equals(activeProps.getProperty(key))) {
+//            needNewSystem = true;
+//            getLogWriter().info("Forcing DS disconnect. For property " + key
+//                                + " old value = " + activeProps.getProperty(key)
+//                                + " new value = " + value);
+//            break;
+//          }
+//        }
+//      }
+//      if(needNewSystem) {
+//        // the current system does not meet our needs to disconnect and
+//        // call recursively to get a new system.
+//        getLogWriter().info("Disconnecting from current DS in order to make a new one");
+//        disconnectFromDS();
+//        getSystem(props);
+//      }
+//    }
+//    return system;
+//  }
 
   /**
    * Returns this VM's connection to the distributed system.  If
@@ -363,6 +413,10 @@ public abstract class DistributedTestCase implements java.io.Serializable {
     return system != null && system.isConnected();
   }
 
+  //---------------------------------------------------------------------------
+  // public methods
+  //---------------------------------------------------------------------------
+  
   /**
    * Returns a <code>Properties</code> object used to configure a
    * connection to a {@link
@@ -376,97 +430,92 @@ public abstract class DistributedTestCase implements java.io.Serializable {
     return new Properties();
   }
 
-  /**
-   * Sets up the test (noop).
-   */
-  @Before
-  public final void setUpDistributedTestCase() throws Exception {
-    setUpCreationStackGenerator();
-    testName = getName();
-    System.setProperty(HoplogConfig.ALLOW_LOCAL_HDFS_PROP, "true");
-    
-    if (testName != null) {
-      GemFireCacheImpl.setDefaultDiskStoreName(getDefaultDiskStoreName());
-      String baseDefaultDiskStoreName = getTestClass().getCanonicalName() + "." + getTestName();
-      for (int h = 0; h < Host.getHostCount(); h++) {
-        Host host = Host.getHost(h);
-        for (int v = 0; v < host.getVMCount(); v++) {
-          VM vm = host.getVM(v);
-          String vmDefaultDiskStoreName = "DiskStore-" + h + "-" + v + "-" + baseDefaultDiskStoreName;
-          vm.invoke(DistributedTestCase.class, "perVMSetUp", new Object[] {testName, vmDefaultDiskStoreName});
-        }
-      }
-    }
-    System.out.println("\n\n[setup] START TEST " + getClass().getSimpleName()+"."+testName+"\n\n");
-  }
+  //---------------------------------------------------------------------------
+  // delete
+  //---------------------------------------------------------------------------
 
-  public static void perVMSetUp(String name, String defaultDiskStoreName) { // TODO: move
-    setTestName(name);
-    GemFireCacheImpl.setDefaultDiskStoreName(defaultDiskStoreName);
-    System.setProperty(HoplogConfig.ALLOW_LOCAL_HDFS_PROP, "true");    
+  public void setSystem(Properties props, DistributedSystem ds) { // TODO: delete
+    system = (InternalDistributedSystem)ds;
+    previousProperties = props;
+    previousSystemCreatedInTestClass = getTestClass();
   }
   
-  public static void setTestName(String name) {
-    testName = name;
+  //---------------------------------------------------------------------------
+  // private
+  //---------------------------------------------------------------------------
+
+  private Class getTestClass() {
+    Class clazz = getClass();
+    while (clazz.getDeclaringClass() != null) {
+      clazz = clazz.getDeclaringClass();
+    }
+    return clazz;
   }
   
-  public static String getTestName() {
-    return testName;
-  }
-
-  /**
-   * For logPerTest to work, we have to disconnect from the DS, but all
-   * subclasses do not call super.tearDown(). To prevent this scenario
-   * this method has been declared final. Subclasses must now override
-   * {@link #tearDown2()} instead.
-   * @throws Exception
-   */
-  @After
-  public final void tearDownDistributedTestCase() throws Exception {
-    tearDownCreationStackGenerator();
-    tearDown2();
-    realTearDown();
-    tearDownAfter();
+  private String getDefaultDiskStoreName() { // TODO: move
+    String vmid = System.getProperty("vmid");
+    return "DiskStore-"  + vmid + "-"+ getTestClass().getCanonicalName() + "." + getTestName();
   }
 
+  //---------------------------------------------------------------------------
+  // deprecated static methods
+  //---------------------------------------------------------------------------
+  
   /**
-   * Tears down the test. This method is called by the final {@link #tearDown()} method and should be overridden to
-   * perform actual test cleanup and release resources used by the test.  The tasks executed by this method are
-   * performed before the DUnit test framework using Hydra cleans up the client VMs.
-   * <p/>
-   * @throws Exception if the tear down process and test cleanup fails.
-   * @see #tearDown
-   * @see #tearDownAfter()
+   * Returns a <code>LogWriter</code> for logging information
+   * @deprecated Use a static logger from the log4j2 LogService.getLogger instead.
    */
-  // TODO rename this method to tearDownBefore and change the access modifier to protected!
-  public void tearDown2() throws Exception { // TODO: rename
+  @Deprecated
+  public static InternalLogWriter getLogWriter() { // TODO: delete
+    return oldLogger;
   }
 
-  protected void realTearDown() throws Exception {
-    if (logPerTest) {
-      disconnectFromDS();
-      invokeInEveryVM(DistributedTestCase.class, "disconnectFromDS");
-    }
-    cleanupAllVms();
+  //---------------------------------------------------------------------------
+  // private static methods
+  //---------------------------------------------------------------------------
+  
+  private static void setUpCreationStackGenerator() {
+    // the following is moved from InternalDistributedSystem to fix #51058
+    InternalDistributedSystem.TEST_CREATION_STACK_GENERATOR.set(
+    new CreationStackGenerator() {
+      @Override
+      public Throwable generateCreationStack(final DistributionConfig config) {
+        final StringBuilder sb = new StringBuilder();
+        final String[] validAttributeNames = config.getAttributeNames();
+        for (int i = 0; i < validAttributeNames.length; i++) {
+          final String attName = validAttributeNames[i];
+          final Object actualAtt = config.getAttributeObject(attName);
+          String actualAttStr = actualAtt.toString();
+          sb.append("  ");
+          sb.append(attName);
+          sb.append("=\"");
+          if (actualAtt.getClass().isArray()) {
+            actualAttStr = InternalDistributedSystem.arrayToString(actualAtt);
+          }
+          sb.append(actualAttStr);
+          sb.append("\"");
+          sb.append("\n");
+        }
+        return new Throwable("Creating distributed system with the following configuration:\n" + sb.toString());
+      }
+    });
   }
   
-  /**
-   * Tears down the test.  Performs additional tear down tasks after the DUnit tests framework using Hydra cleans up
-   * the client VMs.  This method is called by the final {@link #tearDown()} method and should be overridden to perform
-   * post tear down activities.
-   * <p/>
-   * @throws Exception if the test tear down process fails.
-   * @see #tearDown()
-   * @see #tearDown2()
-   */
-  protected void tearDownAfter() throws Exception {
+  private static void tearDownCreationStackGenerator() {
+    InternalDistributedSystem.TEST_CREATION_STACK_GENERATOR.set(InternalDistributedSystem.DEFAULT_CREATION_STACK_GENERATOR);
   }
-
-  public static void cleanupAllVms()
-  {
+  
+  //---------------------------------------------------------------------------
+  // tearDown methods
+  //---------------------------------------------------------------------------
+  
+  public static void cleanupAllVms() {
     cleanupThisVM();
     invokeInEveryVM(DistributedTestCase.class, "cleanupThisVM");
     invokeInLocator(new SerializableRunnable() {
+      private static final long serialVersionUID = 1L;
+
+      @Override
       public void run() {
         DistributionMessageObserver.setInstance(null);
         unregisterInstantiatorsInThisVM();
@@ -475,58 +524,33 @@ public abstract class DistributedTestCase implements java.io.Serializable {
     DUnitLauncher.closeAndCheckForSuspects();
   }
 
-
-  private static void cleanupThisVM() {
-    IpAddress.resolve_dns = true;
-    SocketCreator.resolve_dns = true;
-    InitialImageOperation.slowImageProcessing = 0;
-    DistributionMessageObserver.setInstance(null);
-    QueryTestUtils.setCache(null);
-    CacheServerTestUtil.clearCacheReference();
-    RegionTestCase.preSnapshotRegion = null;
-    GlobalLockingDUnitTest.region_testBug32356 = null;
-    LogWrapper.close();
-    ClientProxyMembershipID.system = null;
-    MultiVMRegionTestCase.CCRegion = null;
-    InternalBridgeMembership.unregisterAllListeners();
-    ClientStatsManager.cleanupForTests();
-    unregisterInstantiatorsInThisVM();
-    GemFireTracer.DEBUG = Boolean.getBoolean("DistributionManager.DEBUG_JAVAGROUPS");
-    Protocol.trace = GemFireTracer.DEBUG;
-    DistributionMessageObserver.setInstance(null);
-    QueryObserverHolder.reset();
-    if (InternalDistributedSystem.systemAttemptingReconnect != null) {
-      InternalDistributedSystem.systemAttemptingReconnect.stopReconnecting();
-    }
-    ExpectedExceptionString ex;
-    while((ex = ExpectedExceptionString.poll()) != null) {
-      ex.remove();
-    }
-  }
-  
-  public static void unregisterAllDataSerializersFromAllVms() // TODO: move
-  {
+  public static void unregisterAllDataSerializersFromAllVms() {
     unregisterDataSerializerInThisVM();
     invokeInEveryVM(new SerializableRunnable() {
+      private static final long serialVersionUID = 1L;
+
+      @Override
       public void run() {
         unregisterDataSerializerInThisVM();
       }
     });
     invokeInLocator(new SerializableRunnable() {
+      private static final long serialVersionUID = 1L;
+
+      @Override
       public void run() {
         unregisterDataSerializerInThisVM();
       }
     });
   }
 
-  public static void unregisterInstantiatorsInThisVM() { // TODO: move
+  public static void unregisterInstantiatorsInThisVM() {
     // unregister all the instantiators
     InternalInstantiator.reinitialize();
     assertEquals(0, InternalInstantiator.getInstantiators().length);
   }
   
-  public static void unregisterDataSerializerInThisVM() // TODO: move
-  {
+  public static void unregisterDataSerializerInThisVM() {
     DataSerializerPropogationDUnitTest.successfullyLoadedTestDataSerializer = false;
     // unregister all the Dataserializers
     InternalDataSerializer.reinitialize();
@@ -534,18 +558,15 @@ public abstract class DistributedTestCase implements java.io.Serializable {
     assertEquals(0, InternalDataSerializer.getSerializers().length);
   }
 
-
   protected static void disconnectAllFromDS() {
     disconnectFromDS();
-    invokeInEveryVM(DistributedTestCase.class,
-                    "disconnectFromDS");
+    invokeInEveryVM(DistributedTestCase.class, "disconnectFromDS");
   }
 
   /**
    * Disconnects this VM from the distributed system
    */
   public static void disconnectFromDS() {
-    testName = null;
     GemFireCacheImpl.testCacheXml = null;
     if (system != null) {
       system.disconnect();
@@ -565,95 +586,37 @@ public abstract class DistributedTestCase implements java.io.Serializable {
       }
     }
     
-    {
-      AdminDistributedSystemImpl ads = 
-          AdminDistributedSystemImpl.getConnectedInstance();
-      if (ads != null) {// && ads.isConnected()) {
-        ads.disconnect();
-      }
+    AdminDistributedSystemImpl ads = AdminDistributedSystemImpl.getConnectedInstance();
+    if (ads != null) {// && ads.isConnected()) {
+      ads.disconnect();
     }
   }
 
-  /**
-   * Strip the package off and gives just the class name.
-   * Needed because of Windows file name limits.
-   */
-  private String getShortClassName() {
-    String result = this.getClass().getName();
-    int idx = result.lastIndexOf('.');
-    if (idx != -1) {
-      result = result.substring(idx+1);
-    }
-    return result;
-  }
-  
-  /** get the host name to use for a server cache in client/server dunit
-   * testing
-   * @param host
-   * @return the host name
-   */
-  public static String getServerHostName(Host host) { // TODO: move
-    return System.getProperty("gemfire.server-bind-address") != null?
-        System.getProperty("gemfire.server-bind-address")
-        : host.getHostName();
-  }
-
-  /** get the IP literal name for the current host, use this instead of  
-   * "localhost" to avoid IPv6 name resolution bugs in the JDK/machine config.
-   * @return an ip literal, this method honors java.net.preferIPvAddresses
-   */
-  public static String getIPLiteral() { // TODO: move
-    try {
-      return SocketCreator.getLocalHost().getHostAddress();
-    } catch (UnknownHostException e) {
-      throw new Error("problem determining host IP address", e);
+  private static void cleanupThisVM() {
+    IpAddress.resolve_dns = true;
+    SocketCreator.resolve_dns = true;
+    InitialImageOperation.slowImageProcessing = 0;
+    DistributionMessageObserver.setInstance(null);
+    QueryTestUtils.setCache(null);
+    CacheServerTestUtil.clearCacheReference();
+    RegionTestCase.preSnapshotRegion = null;
+    GlobalLockingDUnitTest.region_testBug32356 = null;
+    LogWrapper.close();
+    ClientProxyMembershipID.system = null;
+    MultiVMRegionTestCase.CCRegion = null;
+    InternalBridgeMembership.unregisterAllListeners();
+    ClientStatsManager.cleanupForTests();
+    unregisterInstantiatorsInThisVM();
+    GemFireTracer.DEBUG = Boolean.getBoolean("DistributionManager.DEBUG_JAVAGROUPS");
+    Protocol.trace = GemFireTracer.DEBUG;
+    DistributionMessageObserver.setInstance(null);
+    QueryObserverHolder.reset();
+    if (InternalDistributedSystem.systemAttemptingReconnect != null) {
+      InternalDistributedSystem.systemAttemptingReconnect.stopReconnecting();
     }
-  }
- 
- 
-  /**
-   * Get the port that the standard dunit locator is listening on.
-   * @return
-   */
-  public static int getDUnitLocatorPort() { // TODO: move
-    return DUnitEnv.get().getLocatorPort();
-  }
-    
-  public String getName() {
-    return this.testNameRule.getMethodName();
-  }
-  
-  /**
-   * Returns a unique name for this test method.  It is based on the
-   * name of the class as well as the name of the method.
-   */
-  public String getUniqueName() {
-    return getClass().getSimpleName() + "_" + getName();
-  }
-
-  /**
-   * Returns a <code>LogWriter</code> for logging information
-   * @deprecated Use a static logger from the log4j2 LogService.getLogger instead.
-   */
-  @Deprecated
-  public static InternalLogWriter getLogWriter() { // TODO: delete
-    return oldLogger;
-  }
-
-  /** 
-   * Delete locator state files.  Use this after getting a random port
-   * to ensure that an old locator state file isn't picked up by the
-   * new locator you're starting.
-   * 
-   * @param ports
-   */
-  public static void deleteLocatorStateFile(final int... ports) { // TODO: move
-    for (int i=0; i<ports.length; i++) {
-      final File stateFile = new File("locator"+ports[i]+"state.dat");
-      if (stateFile.exists()) {
-        stateFile.delete();
-      }
+    ExpectedExceptionString ex;
+    while((ex = ExpectedExceptionString.poll()) != null) {
+      ex.remove();
     }
   }
-  
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Invoke.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Invoke.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Invoke.java
index bd9eaf6..4ccf972 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Invoke.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Invoke.java
@@ -36,7 +36,6 @@ public class Invoke {
   public static void invokeInEveryVM(final SerializableRunnable work) {
     for (int h = 0; h < Host.getHostCount(); h++) {
       Host host = Host.getHost(h);
-
       for (int v = 0; v < host.getVMCount(); v++) {
         VM vm = host.getVM(v);
         vm.invoke(work);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Jitter.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Jitter.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Jitter.java
index 446b4bf..698d055 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Jitter.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Jitter.java
@@ -5,7 +5,7 @@ import java.util.Random;
 /**
  * Extracted from DistributedTestCase
  */
-public class Jitter {
+class Jitter {
 
   /**
    * If true, we randomize the amount of time we wait

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnable.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnable.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnable.java
index 28eabc3..df3a429 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnable.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnable.java
@@ -37,9 +37,7 @@ import java.io.Serializable;
  *  }
  * </PRE>
  */
-public abstract class SerializableRunnable
-  implements Serializable, Runnable {
-
+public abstract class SerializableRunnable implements Serializable, Runnable {
   private static final long serialVersionUID = 7584289978241650456L;
   
   private String name;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java
index 9653a76..fa9b591 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java
@@ -10,6 +10,9 @@ import com.gemstone.gemfire.internal.cache.LocalRegion;
  */
 public class Wait {
 
+  protected Wait() {
+  }
+  
   /**
    * Wait until given criterion is met
    * 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/CacheTestCase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/CacheTestCase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/CacheTestCase.java
index 8535d85..0dbda35 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/CacheTestCase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/CacheTestCase.java
@@ -420,7 +420,7 @@ public abstract class CacheTestCase extends DistributedTestCase {
   }
 
   @Override
-  public void tearDown2() throws Exception {
+  public void tearDownBefore() throws Exception {
     // locally destroy all root regions and close the cache
     remoteTearDown();
     // Now invoke it in every VM
@@ -431,7 +431,7 @@ public abstract class CacheTestCase extends DistributedTestCase {
         vm.invoke(CacheTestCase.class, "remoteTearDown");
       }
     }
-    super.tearDown2(); 
+    super.tearDownBefore(); 
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
index d0b1710..f15fe23 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/BasicDUnitTest.java
@@ -14,17 +14,20 @@ import java.util.Properties;
 
 import org.junit.Ignore;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.test.dunit.AsyncInvocation;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.RMIException;
 import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 /**
  * This class tests the basic functionality of the distributed unit
  * test framework.
  */
+@Category(DistributedTest.class)
 public class BasicDUnitTest extends DistributedTestCase {
   private static final long serialVersionUID = 1L;
 
@@ -58,7 +61,7 @@ public class BasicDUnitTest extends DistributedTestCase {
   }
   
   @Test
-  public void testRemoteInvokeAsync() throws InterruptedException {
+  public void testRemoteInvokeAsync() throws Exception {
     Host host = Host.getHost(0);
     VM vm = host.getVM(0);
     String name = this.getUniqueName();
@@ -78,7 +81,7 @@ public class BasicDUnitTest extends DistributedTestCase {
   }
 
   @Test
-  public void testRemoteInvokeAsyncWithException() throws InterruptedException {
+  public void testRemoteInvokeAsyncWithException() throws Exception {
     Host host = Host.getHost(0);
     VM vm = host.getVM(0);
 
@@ -93,7 +96,7 @@ public class BasicDUnitTest extends DistributedTestCase {
   @Ignore("not implemented")
   public void testRemoteInvocationBoolean() {
   }
-
+  
   /**
    * Accessed via reflection.  DO NOT REMOVE
    */

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/DUnitFrameworkTestSuite.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/DUnitFrameworkTestSuite.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/DUnitFrameworkTestSuite.java
deleted file mode 100755
index 82664b2..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/DUnitFrameworkTestSuite.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.gemstone.gemfire.test.dunit.tests;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-  BasicDUnitTest.class,
-  VMDUnitTest.class,
-})
-/**
- * Suite of tests for the test.dunit DUnit Test framework.
- */
-public class DUnitFrameworkTestSuite {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/VMDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/VMDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/VMDUnitTest.java
index 12faffe..904da4f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/VMDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/VMDUnitTest.java
@@ -15,16 +15,19 @@ import java.io.Serializable;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.test.dunit.AsyncInvocation;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.RMIException;
 import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 /**
  * This class tests the functionality of the {@link VM} class.
  */
+@Category(DistributedTest.class)
 public class VMDUnitTest extends DistributedTestCase {
   private static final long serialVersionUID = 1L;
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-core/src/test/java/com/gemstone/gemfire/test/golden/GoldenTestFrameworkTestSuite.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/golden/GoldenTestFrameworkTestSuite.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/golden/GoldenTestFrameworkTestSuite.java
deleted file mode 100755
index ed540be..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/golden/GoldenTestFrameworkTestSuite.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.gemstone.gemfire.test.golden;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-  FailWithErrorInOutputJUnitTest.class,
-  FailWithExtraLineInOutputJUnitTest.class,
-  FailWithLineMissingFromEndOfOutputJUnitTest.class,
-  FailWithLineMissingFromMiddleOfOutputJUnitTest.class,
-  FailWithLoggerErrorInOutputJUnitTest.class,
-  FailWithLoggerFatalInOutputJUnitTest.class,
-  FailWithLoggerWarnInOutputJUnitTest.class,
-  FailWithSevereInOutputJUnitTest.class,
-  FailWithTimeoutOfWaitForOutputToMatchJUnitTest.class,
-  FailWithWarningInOutputJUnitTest.class,
-  PassJUnitTest.class,
-  PassWithExpectedErrorJUnitTest.class,
-  PassWithExpectedSevereJUnitTest.class,
-  PassWithExpectedWarningJUnitTest.class,
-})
-/**
- * Suite of tests for the test.golden Golden Test framework classes.
- */
-public class GoldenTestFrameworkTestSuite {
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeout.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeout.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeout.java
deleted file mode 100755
index 9d4040a..0000000
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeout.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package com.gemstone.gemfire.test.junit.rules;
-
-import static org.junit.Assert.assertThat;
-
-import java.util.concurrent.TimeUnit;
-
-import org.hamcrest.Matcher;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-/**
- * Expect an Exception within a specified timeout.
- * 
- * @author Kirk Lund
- * @since 8.2
- */
-public class ExpectedTimeout implements TestRule {
-
-  /**
-   * @return a Rule that expects no timeout (identical to behavior without this Rule)
-   */
-  public static ExpectedTimeout none() {
-    return new ExpectedTimeout();
-  }
-  
-  private ExpectedException delegate;
-  private boolean expectsThrowable;
-  private long minDuration;
-  private long maxDuration;
-  private TimeUnit timeUnit;
-  
-  private ExpectedTimeout() {
-    this.delegate = ExpectedException.none();
-  }
-
-  public ExpectedTimeout expectMinimumDuration(final long minDuration) {
-    this.minDuration = minDuration;
-    return this;
-  }
-  public ExpectedTimeout expectMaximumDuration(final long maxDuration) {
-    this.maxDuration = maxDuration;
-    return this;
-  }
-  public ExpectedTimeout expectTimeUnit(final TimeUnit timeUnit) {
-    this.timeUnit = timeUnit;
-    return this;
-  }
-
-  public ExpectedTimeout handleAssertionErrors() {
-    this.delegate.handleAssertionErrors();
-    return this;
-  }
-  
-  public ExpectedTimeout handleAssumptionViolatedExceptions() {
-    this.delegate.handleAssumptionViolatedExceptions();
-    return this;
-  }
-  
-  /**
-   * Adds {@code matcher} to the list of requirements for any thrown
-   * exception.
-   */
-  public void expect(final Matcher<?> matcher) {
-    this.delegate.expect(matcher);
-  }
-
-  /**
-   * Adds to the list of requirements for any thrown exception that it should
-   * be an instance of {@code type}
-   */
-  public void expect(final Class<? extends Throwable> type) {
-    this.delegate.expect(type);
-    this.expectsThrowable = true;
-  }
-
-  /**
-   * Adds to the list of requirements for any thrown exception that it should
-   * <em>contain</em> string {@code substring}
-   */
-  public void expectMessage(final String substring) {
-    this.delegate.expectMessage(substring);
-  }
-
-  /**
-   * Adds {@code matcher} to the list of requirements for the message returned
-   * from any thrown exception.
-   */
-  public void expectMessage(final Matcher<String> matcher) {
-    this.delegate.expectMessage(matcher);
-  }
-
-  /**
-   * Adds {@code matcher} to the list of requirements for the cause of
-   * any thrown exception.
-   */
-  public void expectCause(final Matcher<? extends Throwable> expectedCause) {
-    this.delegate.expectCause(expectedCause);
-  }
-
-  public boolean expectsTimeout() {
-    return minDuration > 0 || maxDuration > 0;
-  }
-  
-  public boolean expectsThrowable() {
-    return expectsThrowable = true;
-  }
-  
-  @Override
-  public Statement apply(final Statement base, final Description description) {
-    Statement next = delegate.apply(base, description);
-    return new ExpectedTimeoutStatement(next);
-  }
-  
-  private void handleTime(final Long duration) {
-    if (expectsTimeout()) {
-      assertThat(timeUnit.convert(duration, TimeUnit.NANOSECONDS), new TimeMatcher(timeUnit, minDuration, maxDuration));
-    }
-  }
-  
-  private static class TimeMatcher extends org.hamcrest.TypeSafeMatcher<Long> {
-    
-    private final TimeUnit timeUnit;
-    private final long minDuration;
-    private final long maxDuration;
- 
-    public TimeMatcher(final TimeUnit timeUnit, final long minDuration, final long maxDuration) {
-      this.timeUnit = timeUnit;
-      this.minDuration = minDuration;
-      this.maxDuration = maxDuration;
-    }
- 
-    @Override
-    public boolean matchesSafely(final Long duration) {
-      return duration >= this.minDuration && duration <= this.maxDuration;
-    }
-
-    @Override
-    public void describeTo(final org.hamcrest.Description description) {
-      description.appendText("expects duration to be greater than or equal to ")
-          .appendValue(this.minDuration)
-          .appendText(" and less than or equal to ")
-          .appendValue(this.maxDuration)
-          .appendText(" ")
-          .appendValue(this.timeUnit);
-    }
-  }
-  
-  private class ExpectedTimeoutStatement extends Statement {
-    private final Statement next;
-
-    public ExpectedTimeoutStatement(final Statement base) {
-      next = base;
-    }
-
-    @Override
-    public void evaluate() throws Throwable {
-      long start = System.nanoTime();
-      next.evaluate();
-      handleTime(System.nanoTime() - start);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fcd21422/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutJUnitTest.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutJUnitTest.java
deleted file mode 100755
index fe11586..0000000
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutJUnitTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package com.gemstone.gemfire.test.junit.rules;
-
-import static org.hamcrest.core.StringContains.*;
-import static org.hamcrest.core.Is.*;
-import static org.hamcrest.core.IsInstanceOf.*;
-import static org.junit.Assert.*;
-
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Request;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-/**
- * Unit tests for ExpectedTimeout JUnit Rule.
- * 
- * @author Kirk Lund
- * @since 8.2
- */
-@Category(UnitTest.class)
-public class ExpectedTimeoutJUnitTest {
-
-  @Test
-  public void passesUnused() {
-    Result result = runTest(PassesUnused.class);
-    assertTrue(result.wasSuccessful());
-  }
-  
-  @Test
-  public void failsWithoutExpectedException() {
-    Result result = runTest(FailsWithoutExpectedException.class);
-    assertFalse(result.wasSuccessful());
-    List<Failure> failures = result.getFailures();
-    assertEquals(1, failures.size());
-    Failure failure = failures.get(0);
-    assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
-    assertThat(failure.getException().getMessage(), containsString("Expected test to throw an instance of " + TimeoutException.class.getName()));
-  }
-  
-  @Test
-  public void failsWithoutExpectedTimeoutException() {
-    Result result = runTest(FailsWithoutExpectedTimeoutException.class);
-    assertFalse(result.wasSuccessful());
-    List<Failure> failures = result.getFailures();
-    assertEquals(1, failures.size());
-    Failure failure = failures.get(0);
-    assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
-    assertThat(failure.getException().getMessage(), containsString("Expected test to throw (an instance of " + TimeoutException.class.getName() + " and exception with message a string containing \"" + FailsWithoutExpectedTimeoutException.message + "\")"));
-  }
-  
-  @Test
-  public void failsWithExpectedTimeoutButWrongError() {
-    Result result = runTest(FailsWithExpectedTimeoutButWrongError.class);
-    assertFalse(result.wasSuccessful());
-    List<Failure> failures = result.getFailures();
-    assertEquals(1, failures.size());
-    Failure failure = failures.get(0);
-    assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
-    assertThat(failure.getException().getMessage(), containsString(NullPointerException.class.getName()));
-  }
-  
-  @Test
-  public void passesWithExpectedTimeoutAndTimeoutException() {
-    Result result = runTest(PassesWithExpectedTimeoutAndTimeoutException.class);
-    assertTrue(result.wasSuccessful());
-  }
-  
-  @Test
-  public void failsWhenTimeoutIsEarly() {
-    Result result = runTest(FailsWhenTimeoutIsEarly.class);
-    assertFalse(result.wasSuccessful());
-    List<Failure> failures = result.getFailures();
-    assertEquals(1, failures.size());
-    Failure failure = failures.get(0);
-    assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
-    assertThat(failure.getException().getMessage(), containsString("Expected test to throw (an instance of " + TimeoutException.class.getName() + " and exception with message a string containing \"" + FailsWhenTimeoutIsEarly.message + "\")"));
-  }
-  
-  @Test
-  public void failsWhenTimeoutIsLate() {
-    Result result = runTest(FailsWhenTimeoutIsLate.class);
-    assertFalse(result.wasSuccessful());
-    List<Failure> failures = result.getFailures();
-    assertEquals(1, failures.size());
-    Failure failure = failures.get(0);
-    assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
-    assertThat(failure.getException().getMessage(), containsString("Expected test to throw (an instance of " + TimeoutException.class.getName() + " and exception with message a string containing \"" + FailsWhenTimeoutIsLate.message + "\")"));
-  }
-  
-  private static Result runTest(Class<?> test) {
-    JUnitCore junitCore = new JUnitCore();
-    return junitCore.run(Request.aClass(test).getRunner());
-  }
-  
-  public static class AbstractExpectedTimeoutTest {
-    @Rule
-    public ExpectedTimeout timeout = ExpectedTimeout.none();
-  }
-  
-  public static class PassesUnused extends AbstractExpectedTimeoutTest {
-    @Test
-    public void passesUnused() throws Exception {
-    }
-  }
-  
-  public static class FailsWithoutExpectedException extends AbstractExpectedTimeoutTest {
-    @Test
-    public void failsWithoutExpectedException() throws Exception {
-      timeout.expect(TimeoutException.class);
-    }
-  }
-  
-  public static class FailsWithoutExpectedTimeoutException extends AbstractExpectedTimeoutTest {
-    public static final String message = "this is a message for FailsWithoutExpectedTimeoutException";
-    @Test
-    public void failsWithoutExpectedTimeoutAndTimeoutException() throws Exception {
-      timeout.expect(TimeoutException.class);
-      timeout.expectMessage(message);
-      timeout.expectMinimumDuration(10);
-      timeout.expectMaximumDuration(1000);
-      timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
-      Thread.sleep(100);
-    }
-  }
-  
-  public static class FailsWithExpectedTimeoutButWrongError extends AbstractExpectedTimeoutTest {
-    public static final String message = "this is a message for FailsWithExpectedTimeoutButWrongError";
-    @Test
-    public void failsWithExpectedTimeoutButWrongError() throws Exception {
-      timeout.expect(TimeoutException.class);
-      timeout.expectMessage(message);
-      timeout.expectMinimumDuration(10);
-      timeout.expectMaximumDuration(1000);
-      timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
-      Thread.sleep(100);
-      throw new NullPointerException();
-    }
-  }
-
-  public static class PassesWithExpectedTimeoutAndTimeoutException extends AbstractExpectedTimeoutTest {
-    public static final String message = "this is a message for PassesWithExpectedTimeoutAndTimeoutException";
-    public static final Class<TimeoutException> exceptionClass = TimeoutException.class;
-    @Test
-    public void passesWithExpectedTimeoutAndTimeoutException() throws Exception {
-      timeout.expect(exceptionClass);
-      timeout.expectMessage(message);
-      timeout.expectMinimumDuration(10);
-      timeout.expectMaximumDuration(1000);
-      timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
-      Thread.sleep(100);
-      throw new TimeoutException(message);
-    }
-  }
-
-  public static class FailsWhenTimeoutIsEarly extends AbstractExpectedTimeoutTest {
-    public static final String message = "this is a message for FailsWhenTimeoutIsEarly";
-    @Test
-    public void failsWhenTimeoutIsEarly() throws Exception {
-      timeout.expect(TimeoutException.class);
-      timeout.expectMessage(message);
-      timeout.expectMinimumDuration(1000);
-      timeout.expectMaximumDuration(2000);
-      timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
-      Thread.sleep(10);
-    }
-  }
-
-  public static class FailsWhenTimeoutIsLate extends AbstractExpectedTimeoutTest {
-    public static final String message = "this is a message for FailsWhenTimeoutIsLate";
-    @Test
-    public void failsWhenTimeoutIsLate() throws Exception {
-      timeout.expect(TimeoutException.class);
-      timeout.expectMessage(message);
-      timeout.expectMinimumDuration(10);
-      timeout.expectMaximumDuration(20);
-      timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
-      Thread.sleep(100);
-    }
-  }
-}


Mime
View raw message