geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [25/32] incubator-geode git commit: GEODE-1162: convert all CLI command DUnit tests to JUnit 4
Date Fri, 15 Apr 2016 03:07:54 GMT
GEODE-1162: convert all CLI command DUnit tests to JUnit 4

* GEODE-1161: cleanup VM and AsyncInvocation in DUnit
* define FlakyTest JUnit category
* define SecurityTest JUnit category and apply to all security tests (probably missed a few)
* create category test to discover JUnit behavior


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

Branch: refs/heads/feature/GEODE-17-2
Commit: f2d5969efb410011e760399765a02d07dbe17ed7
Parents: 7b3c8cb
Author: Kirk Lund <klund@apache.org>
Authored: Thu Apr 14 13:45:26 2016 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Thu Apr 14 13:45:26 2016 -0700

----------------------------------------------------------------------
 .../LauncherLifecycleCommandsDUnitTest.java     | 149 ++++--
 .../SharedConfigurationEndToEndDUnitTest.java   |  18 +-
 .../gemfire/internal/lang/ThrowableUtils.java   | 101 ++++
 .../query/dunit/SelectStarQueryDUnitTest.java   | 216 ++++----
 .../gemfire/cache30/MultiVMRegionTestCase.java  |  13 +-
 .../cache/partitioned/ShutdownAllDUnitTest.java |  10 +-
 .../PersistentRecoveryOrderDUnitTest.java       |   6 +-
 .../internal/lang/ThrowableUtilsTest.java       | 242 +++++++++
 .../AbstractCommandsSupportJUnitTest.java       |  16 +-
 .../cli/commands/CliCommandTestBase.java        |  57 +-
 .../cli/commands/ConfigCommandsDUnitTest.java   |  85 +--
 ...eateAlterDestroyRegionCommandsDUnitTest.java | 121 +++--
 .../cli/commands/DeployCommandsDUnitTest.java   |  33 +-
 .../commands/DiskStoreCommandsDUnitTest.java    |  83 +--
 .../commands/DiskStoreCommandsJUnitTest.java    |  19 +-
 .../cli/commands/FunctionCommandsDUnitTest.java |  97 ++--
 .../commands/GemfireDataCommandsDUnitTest.java  | 267 +++++-----
 ...WithCacheLoaderDuringCacheMissDUnitTest.java |  20 +-
 .../HTTPServiceSSLSupportJUnitTest.java         |  12 +-
 .../cli/commands/IndexCommandsDUnitTest.java    |  31 +-
 .../cli/commands/IndexCommandsJUnitTest.java    |  18 +-
 ...stAndDescribeDiskStoreCommandsDUnitTest.java |  23 +-
 .../ListAndDescribeRegionDUnitTest.java         |  50 +-
 .../cli/commands/ListIndexCommandDUnitTest.java |  29 +-
 .../cli/commands/MemberCommandsDUnitTest.java   |  60 ++-
 .../MiscellaneousCommandsDUnitTest.java         |  84 +--
 ...laneousCommandsExportLogsPart1DUnitTest.java |  37 +-
 ...laneousCommandsExportLogsPart2DUnitTest.java |  38 +-
 ...laneousCommandsExportLogsPart3DUnitTest.java |  39 +-
 ...laneousCommandsExportLogsPart4DUnitTest.java |  36 +-
 .../cli/commands/QueueCommandsDUnitTest.java    |  41 +-
 .../SharedConfigurationCommandsDUnitTest.java   |  55 +-
 .../cli/commands/ShellCommandsDUnitTest.java    |  47 +-
 .../cli/commands/ShowDeadlockDUnitTest.java     |  56 +-
 .../cli/commands/ShowMetricsDUnitTest.java      |  71 +--
 .../cli/commands/ShowStackTraceDUnitTest.java   |  43 +-
 .../cli/commands/UserCommandsDUnitTest.java     |  24 +-
 .../security/ClientAuthenticationDUnitTest.java |   6 +-
 .../ClientAuthenticationPart2DUnitTest.java     |   6 +-
 .../security/ClientAuthenticationTestCase.java  |   3 +
 .../security/ClientAuthorizationDUnitTest.java  |  10 +-
 .../security/ClientAuthorizationTestCase.java   |   2 +-
 .../security/ClientMultiUserAuthzDUnitTest.java |  10 +-
 .../DeltaClientAuthorizationDUnitTest.java      |  10 +-
 .../DeltaClientPostAuthorizationDUnitTest.java  |   8 +-
 .../security/GemFireSecurityExceptionTest.java  |   6 +-
 .../security/NotAuthorizedExceptionTest.java    |   6 +-
 .../security/P2PAuthenticationDUnitTest.java    |  10 +-
 .../gemfire/security/SecurityTestUtils.java     |  13 +-
 .../generator/AuthzCredentialGenerator.java     |  15 +-
 .../security/generator/CredentialGenerator.java |   3 +-
 .../generator/DummyCredentialGenerator.java     |   6 +-
 .../generator/LdapUserCredentialGenerator.java  |  15 +-
 .../generator/PKCSCredentialGenerator.java      |   8 +-
 .../generator/SSLCredentialGenerator.java       |   9 +-
 .../UserPasswordWithExtraPropsAuthInit.java     |   6 +-
 .../generator/XmlAuthzCredentialGenerator.java  |  10 +-
 .../security/templates/DummyAuthorization.java  |   8 +-
 .../templates/LdapUserAuthenticator.java        |   3 +-
 .../security/templates/PKCSAuthInit.java        |   3 +-
 .../security/templates/PKCSAuthenticator.java   |   3 +-
 .../security/templates/PKCSPrincipalTest.java   |   9 +-
 .../templates/UserPasswordAuthInit.java         |   4 +-
 .../templates/UsernamePrincipalTest.java        |   9 +-
 .../security/templates/XmlAuthorization.java    |  19 +-
 .../security/templates/XmlErrorHandler.java     |   5 +-
 .../gemfire/test/dunit/AsyncInvocation.java     | 511 +++++++++++++-----
 .../gemfire/test/dunit/DistributedTestCase.java |   8 +-
 .../test/dunit/DistributedTestUtils.java        |   2 +-
 .../gemfire/test/dunit/ThreadUtils.java         |  13 +-
 .../com/gemstone/gemfire/test/dunit/VM.java     | 521 +++++++++----------
 .../com/gemstone/gemfire/test/dunit/Wait.java   |   2 +-
 .../cache/internal/JUnit4CacheTestCase.java     |   4 +-
 .../internal/JUnit3DistributedTestCase.java     |   9 +-
 .../internal/JUnit4DistributedTestCase.java     |  17 +-
 .../internal/tests/JUnit3BasicDUnitTest.java    | 189 -------
 .../JUnit3GetDefaultDiskStoreNameDUnitTest.java |  66 ---
 .../tests/JUnit3GetTestMethodNameDUnitTest.java |  53 --
 .../dunit/internal/tests/JUnit3VMDUnitTest.java | 192 -------
 .../internal/tests/JUnit4BasicDUnitTest.java    | 202 -------
 .../JUnit4GetDefaultDiskStoreNameDUnitTest.java |  65 ---
 .../tests/JUnit4GetTestMethodNameDUnitTest.java |  52 --
 .../dunit/internal/tests/JUnit4VMDUnitTest.java | 200 -------
 .../DistributedRestoreSystemProperties.java     |   3 +-
 .../gemfire/test/dunit/rules/RemoteInvoker.java |   3 +-
 .../gemfire/test/dunit/standalone/ChildVM.java  |   5 +-
 .../test/dunit/standalone/DUnitLauncher.java    |  10 +-
 .../test/dunit/standalone/RemoteDUnitVM.java    |   5 +-
 .../test/dunit/standalone/RemoteDUnitVMIF.java  |   4 +-
 .../test/dunit/tests/BasicDUnitTest.java        | 218 ++++----
 .../test/dunit/tests/JUnit4BasicDUnitTest.java  | 234 +++++++++
 .../JUnit4GetDefaultDiskStoreNameDUnitTest.java |  66 +++
 .../tests/JUnit4GetTestMethodNameDUnitTest.java |  53 ++
 ...ingGetPropertiesDisconnectsAllDUnitTest.java |  57 ++
 .../test/dunit/tests/JUnit4VMDUnitTest.java     | 201 +++++++
 .../cli/commands/ClientCommandsDUnitTest.java   | 199 +++----
 .../DurableClientCommandsDUnitTest.java         |  53 +-
 .../ClientAuthorizationTwoDUnitTest.java        |   8 +-
 .../security/ClientAuthzObjectModDUnitTest.java |   8 +-
 .../ClientCQPostAuthorizationDUnitTest.java     |   8 +-
 .../ClientPostAuthorizationDUnitTest.java       |  14 +-
 .../gemfire/security/MultiUserAPIDUnitTest.java |   8 +-
 .../MultiUserDurableCQAuthzDUnitTest.java       |   8 +-
 .../test/junit/categories/FlakyTest.java        |  24 +
 .../test/junit/categories/SecurityTest.java     |  23 +
 .../gemfire/test/junit/rules/RetryRule.java     |   2 +-
 .../test/junit/categories/CategoryOne.java      |  20 +
 .../test/junit/categories/CategoryTest.java     | 169 ++++++
 .../test/junit/categories/CategoryTwo.java      |  20 +
 .../wan/wancommand/WANCommandTestBase.java      |  35 +-
 ...anCommandCreateGatewayReceiverDUnitTest.java |  45 +-
 .../WanCommandCreateGatewaySenderDUnitTest.java |  45 +-
 ...WanCommandGatewayReceiverStartDUnitTest.java |  39 +-
 .../WanCommandGatewayReceiverStopDUnitTest.java |  37 +-
 .../WanCommandGatewaySenderStartDUnitTest.java  |  44 +-
 .../WanCommandGatewaySenderStopDUnitTest.java   |  39 +-
 .../wan/wancommand/WanCommandListDUnitTest.java |  52 +-
 .../WanCommandPauseResumeDUnitTest.java         | 138 ++---
 .../wancommand/WanCommandStatusDUnitTest.java   |  79 +--
 .../ClusterConfigurationDUnitTest.java          |  64 ++-
 120 files changed, 3731 insertions(+), 2987 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2d5969e/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
index e41e118..4553140 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java
@@ -16,8 +16,43 @@
  */
 package com.gemstone.gemfire.management.internal.cli.commands;
 
+import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.Wait.*;
 
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.nio.charset.Charset;
+import java.text.DateFormat;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.TimeUnit;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.Query;
+import javax.management.QueryExp;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.junit.FixMethodOrder;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.client.ClientCache;
 import com.gemstone.gemfire.cache.client.ClientCacheFactory;
@@ -46,38 +81,7 @@ import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
 import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
 import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
-
-import org.junit.FixMethodOrder;
-import org.junit.Ignore;
-import org.junit.runners.MethodSorters;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.Query;
-import javax.management.QueryExp;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.lang.management.ManagementFactory;
-import java.net.InetAddress;
-import java.nio.charset.Charset;
-import java.text.DateFormat;
-import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedDeque;
-import java.util.concurrent.TimeUnit;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 /**
  * The LauncherLifecycleCommandsDUnitTest class is a test suite of integration tests testing the contract and
@@ -95,6 +99,7 @@ import java.util.concurrent.TimeUnit;
  * @see com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder
  * @since 7.0
  */
+@Category(DistributedTest.class)
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
 
@@ -104,10 +109,6 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
 
   private final Queue<Integer> processIds = new ConcurrentLinkedDeque<>();
 
-  public LauncherLifecycleCommandsDUnitTest(final String testName) {
-    super(testName);
-  }
-
   protected static String getMemberId(final int jmxManagerPort, final String memberName) throws Exception {
     return getMemberId(InetAddress.getLocalHost().getHostName(), jmxManagerPort, memberName);
   }
@@ -296,6 +297,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
     }
   }
 
+  @Test
   public void test000StartLocatorCapturesOutputOnError() throws IOException {
     final int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
 
@@ -356,6 +358,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
     return pid;
   }
 
+  @Test
   public void test001StartLocatorFailsFastOnMissingGemFirePropertiesFile() {
     String gemfirePropertiesPathname = "/path/to/missing/gemfire.properties";
 
@@ -381,6 +384,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
             gemfirePropertiesPathname)));
   }
 
+  @Test
   public void test002StartLocatorFailsFastOnMissingGemFireSecurityPropertiesFile() {
     String gemfireSecurityPropertiesPathname = "/path/to/missing/gemfire-security.properties";
 
@@ -406,6 +410,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
             gemfireSecurityPropertiesPathname)));
   }
 
+  @Test
   public void test003StartServerFailsFastOnMissingCacheXmlFile() {
     String cacheXmlPathname = "/path/to/missing/cache.xml";
 
@@ -425,6 +430,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
         resultString.contains(MessageFormat.format(CliStrings.CACHE_XML_NOT_FOUND_MESSAGE, cacheXmlPathname)));
   }
 
+  @Test
   public void test004StartServerFailsFastOnMissingGemFirePropertiesFile() {
     String gemfirePropertiesFile = "/path/to/missing/gemfire.properties";
 
@@ -445,6 +451,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
             gemfirePropertiesFile)));
   }
 
+  @Test
   public void test005StartServerFailsFastOnMissingGemFireSecurityPropertiesFile() {
     String gemfireSecuritiesPropertiesFile = "/path/to/missing/gemfire-securities.properties";
 
@@ -465,6 +472,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
             gemfireSecuritiesPropertiesFile)));
   }
 
+  @Test
   public void test006StartLocatorInRelativeDirectory() {
     final int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
 
@@ -500,6 +508,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
     }
   }
 
+  @Test
   public void test007StatusLocatorUsingMemberNameIDWhenGfshIsNotConnected() {
     CommandResult result = executeCommand(CliStrings.STATUS_LOCATOR + " --name=" + getTestMethodName());
 
@@ -509,6 +518,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
         StringUtils.trim(toString(result)));
   }
 
+  @Test
   public void test008StatusLocatorUsingMemberName() {
     final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
 
@@ -571,6 +581,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
     }
   }
 
+  @Test
   public void test009StatusLocatorUsingMemberId() throws Exception {
     final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
 
@@ -627,6 +638,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
     }
   }
 
+  @Test
   public void test010StopLocatorUsingMemberNameIDWhenGfshIsNotConnected() {
     CommandResult result = executeCommand(CliStrings.STOP_LOCATOR + " --name=" + getTestMethodName());
 
@@ -636,6 +648,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
         StringUtils.trim(toString(result)));
   }
 
+  @Test
   public void test011StopLocatorUsingMemberName() {
     final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
 
@@ -723,6 +736,7 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
   }
 
   // @see Trac Bug # 46760
+  @Test
   public void test012StopLocatorUsingMemberId() throws Exception {
     final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
 
@@ -799,6 +813,69 @@ public class LauncherLifecycleCommandsDUnitTest extends CliCommandTestBase {
     assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
   }
 
+  @Ignore("Disabled until GEODE-1025, SGF-476 are resolved")
+  @Test
+  public void test013StartServerWithSpring() {
+    String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
+    File workingDirectory = new File(pathname);
+
+    assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
+
+    CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_SERVER);
+
+    command.addOption(CliStrings.START_SERVER__NAME, getClass().getSimpleName().concat("_").concat(getTestMethodName()));
+    command.addOption(CliStrings.START_SERVER__USE_CLUSTER_CONFIGURATION, Boolean.FALSE.toString());
+    command.addOption(CliStrings.START_SERVER__LOG_LEVEL, "config");
+    command.addOption(CliStrings.START_SERVER__INCLUDE_SYSTEM_CLASSPATH);
+    command.addOption(CliStrings.START_SERVER__DISABLE_DEFAULT_SERVER);
+    command.addOption(CliStrings.START_SERVER__DIR, pathname);
+    command.addOption(CliStrings.START_SERVER__SPRING_XML_LOCATION, "spring/spring-gemfire-context.xml");
+
+    CommandResult result = executeCommand(command.toString());
+
+    assertNotNull(result);
+    assertEquals(Result.Status.OK, result.getStatus());
+
+    final ServerLauncher springGemFireServer = new ServerLauncher.Builder().setCommand(
+        ServerLauncher.Command.STATUS).setWorkingDirectory(
+        IOUtils.tryGetCanonicalPathElseGetAbsolutePath(workingDirectory)).build();
+
+    assertNotNull(springGemFireServer);
+
+    ServerState serverState = springGemFireServer.status();
+    
+    assertNotNull(serverState);
+    assertEquals(Status.ONLINE, serverState.getStatus());
+    
+    //Ensure the member name is what is set through spring
+    String logFile = serverState.getLogFile();
+    assertTrue("Log file name was not configured from spring context: " + logFile, logFile.contains("spring_server.log"));
+
+    // Now that the GemFire Server bootstrapped with Spring started up OK, stop it!
+    stopServer(springGemFireServer.getWorkingDirectory());
+
+    WaitCriterion waitCriteria = new WaitCriterion() {
+      @Override
+      public boolean done() {
+        ServerState serverState = springGemFireServer.status();
+        return (serverState != null && Status.NOT_RESPONDING.equals(serverState.getStatus()));
+      }
+
+      @Override
+      public String description() {
+        return "wait for the Locator to stop; the Locator will no longer respond after it stops";
+      }
+    };
+
+    waitForCriterion(waitCriteria, TimeUnit.SECONDS.toMillis(15), TimeUnit.SECONDS.toMillis(5), true);
+
+    serverState = springGemFireServer.status();
+
+    assertNotNull(serverState);
+    assertEquals(Status.NOT_RESPONDING, serverState.getStatus());
+  }
+
+  @Test
   public void test014GemFireServerJvmProcessTerminatesOnOutOfMemoryError() throws Exception {
     int ports[] = AvailablePortHelper.getRandomAvailableTCPPorts(2);
     final int serverPort = ports[0];

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2d5969e/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
index edd056b..e1093a2 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
@@ -16,6 +16,8 @@
  */
 package com.gemstone.gemfire.management.internal.configuration;
 
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 import static com.gemstone.gemfire.test.dunit.Wait.*;
 
 import com.gemstone.gemfire.cache.Cache;
@@ -40,15 +42,16 @@ import com.gemstone.gemfire.management.internal.cli.commands.CliCommandTestBase;
 import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
 import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
 import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.IgnoredException;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import java.io.File;
 import java.io.IOException;
@@ -59,6 +62,7 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 
+@Category(DistributedTest.class)
 public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
   private static final int TIMEOUT = 10000;
   private static final int INTERVAL = 500;
@@ -69,11 +73,6 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
   public static Set<String> serverNames = new HashSet<String>();
   public static Set<String> jarFileNames = new HashSet<String>();
 
-  public SharedConfigurationEndToEndDUnitTest(String name) {
-    super(name);
-    // TODO Auto-generated constructor stub
-  }
-
   private static final long serialVersionUID = -2276690105585944041L;
 
   public Set<String> startServers(HeadlessGfsh gfsh, String locatorString, int numServers, String serverNamePrefix, int startNum) throws ClassNotFoundException, IOException {
@@ -93,6 +92,7 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     return serverNames;
   }
 
+  @Test
   public void testStartServerAndExecuteCommands() throws InterruptedException, ClassNotFoundException, IOException, ExecutionException {
     IgnoredException.addIgnoredException("EntryDestroyedException");
     Object[] result = setup();
@@ -117,7 +117,7 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
 
 
     //shutdown everything
-    LogWriterUtils.getLogWriter().info("Shutting down all the members");
+    getLogWriter().info("Shutting down all the members");
     shutdownAll();
     deleteSavedJarFiles();
   }
@@ -147,7 +147,7 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
 
   protected void executeAndVerifyCommand(String commandString) {
     CommandResult cmdResult = executeCommand(commandString);
-    LogWriterUtils.getLogWriter().info("Command Result : \n" + commandResultToString(cmdResult));
+    getLogWriter().info("Command Result : \n" + commandResultToString(cmdResult));
     assertEquals(Status.OK, cmdResult.getStatus());
     assertFalse(cmdResult.failedToPersist());
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2d5969e/geode-core/src/main/java/com/gemstone/gemfire/internal/lang/ThrowableUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/lang/ThrowableUtils.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/lang/ThrowableUtils.java
new file mode 100644
index 0000000..eb3188b
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/lang/ThrowableUtils.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.internal.lang;
+
+/**
+ * The ThrowableUtils class is an abstract utility class for working with {@code Throwable}s.
+ * <p/>
+ * @see java.lang.Throwable
+ */
+public abstract class ThrowableUtils {
+
+  /**
+   * Get the root cause of a {@link Throwable}. Returns the specified
+   * {@code throwable} if its {@code getCause} returns null.
+   *
+   * @param  throwable the {@code Throwable} to get the root cause of.
+   * @return the root cause of the specified {@code throwable}.
+   *
+   * @throws NullPointerException if {@code throwable} is null
+   */
+  public static Throwable getRootCause(Throwable throwable) {
+    if (throwable.getCause() == null) {
+      return throwable;
+    }
+
+    Throwable cause;
+    while ((cause = throwable.getCause()) != null) {
+      throwable = cause;
+    }
+    return throwable;
+  }
+
+  /**
+   * Returns true if the {@link Throwable} or any of its causes as returned
+   * by {@code getCause()} are an instance of the specified subclass of
+   * {@code Throwable}.
+   *
+   * @param  throwable the {@code Throwable} to check the causes of.
+   * @param  causeClass the subclass of {@code Throwable} to check for.
+   * @return true if any cause of {@code throwable} is an instance of
+   *         {@code causeClass}.
+   *
+   * @throws NullPointerException if {@code throwable} is null
+   */
+  public static boolean hasCauseType(Throwable throwable, Class<? extends Throwable> causeClass) {
+    if (causeClass.isInstance(throwable)) {
+      return true;
+    }
+
+    Throwable cause;
+    while ((cause = throwable.getCause()) != null) {
+      throwable = cause;
+      if (causeClass.isInstance(throwable)) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+  /**
+   * Returns true if the {@link Throwable} or any of its causes contain the
+   * specified {@code message}.
+   *
+   * @param  throwable the {@code Throwable} to check the causes of.
+   * @param  message the {@code Throwable} message to check for.
+   * @return true if any cause of {@code throwable} contains the specified
+   *         {@code message}.
+   *
+   * @throws NullPointerException if {@code throwable} is null
+   */
+  public static boolean hasCauseMessage(Throwable throwable, String message) {
+    if (throwable.getMessage().contains(message)) {
+      return true;
+    }
+
+    Throwable cause;
+    while ((cause = throwable.getCause()) != null) {
+      throwable = cause;
+      if (throwable.getMessage().contains(message)) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2d5969e/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/SelectStarQueryDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/SelectStarQueryDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/SelectStarQueryDUnitTest.java
index b92426a..11b76de 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/SelectStarQueryDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/SelectStarQueryDUnitTest.java
@@ -14,11 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.gemstone.gemfire.cache.query.dunit;
 
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Invoke.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+import static com.gemstone.gemfire.test.dunit.NetworkUtils.*;
+
 import java.io.Serializable;
 
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionShortcut;
 import com.gemstone.gemfire.cache.client.ClientCache;
@@ -35,28 +42,25 @@ import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
 import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
 import com.gemstone.gemfire.cache.query.internal.StructImpl;
 import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.VMCachedDeserializable;
 import com.gemstone.gemfire.pdx.PdxInstance;
-import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
-import com.gemstone.gemfire.test.dunit.NetworkUtils;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 /**
  * Test for #44807 to eliminate unnecessary serialization/deserialization in
  * select * queries
- * 
- * 
  */
-public class SelectStarQueryDUnitTest extends CacheTestCase {
-  public SelectStarQueryDUnitTest(String name) {
-    super(name);
-  }
+@Category(DistributedTest.class)
+public class SelectStarQueryDUnitTest extends JUnit4CacheTestCase {
+
+  /** Used for saving & restoring oldObserver without serialization */
+  private static volatile QueryObserver oldObserver;
 
   private final String regName = "exampleRegion";
   private final String regName2 = "exampleRegion2";
@@ -87,6 +91,12 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
           + regName2 + " q, q.positions.values pos", };
   private final int[] resultSize2 = { 400, 5, 400, 400, 1, 400, 400, 400, 1600 };
 
+  @Override
+  public final void preTearDownCacheTestCase() throws Exception {
+    invokeInEveryVM(() -> oldObserver = null);
+  }
+
+  @Test
   public void testSelectStarQueryForPartitionedRegion() throws Exception {
     final Host host = Host.getHost(0);
     final VM server1 = host.getVM(0);
@@ -103,13 +113,11 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     final int port2 = startPartitionedCacheServer(server2, portfolios);
     final int port3 = startPartitionedCacheServer(server3, portfolios);
 
-    final QueryObserver oldObserver = (QueryObserver) server1
-        .invoke(new SerializableCallable("Set observer") {
+    server1.invoke(new SerializableCallable("Set observer") {
           @Override
           public Object call() throws Exception {
-            QueryObserver observer = QueryObserverHolder
-                .setInstance(new QueryResultTrackingObserver());
-            return observer;
+            oldObserver = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
+            return null;
           }
         });
 
@@ -118,9 +126,9 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
       @Override
       public Object call() throws Exception {
         ClientCacheFactory cf = new ClientCacheFactory();
-        cf.addPoolServer(NetworkUtils.getServerHostName(server1.getHost()), port1);
-        cf.addPoolServer(NetworkUtils.getServerHostName(server2.getHost()), port2);
-        cf.addPoolServer(NetworkUtils.getServerHostName(server3.getHost()), port3);
+        cf.addPoolServer(getServerHostName(server1.getHost()), port1);
+        cf.addPoolServer(getServerHostName(server2.getHost()), port2);
+        cf.addPoolServer(getServerHostName(server3.getHost()), port3);
         ClientCache cache = getClientCache(cf);
         cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
             .create(regName);
@@ -144,14 +152,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     client.invoke(new SerializableCallable("Query") {
       @Override
       public Object call() throws Exception {
-        LogWriterUtils.getLogWriter().info("Querying remotely from client");
+        getLogWriter().info("Querying remotely from client");
         QueryService localQS = null;
         QueryService remoteQS = null;
         try {
           localQS = ((ClientCache) getCache()).getLocalQueryService();
           remoteQS = ((ClientCache) getCache()).getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults[][] sr = new SelectResults[1][2];
         SelectResults res = null;
@@ -163,7 +171,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
             sr[0][1] = res;
             CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -217,14 +225,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
         try {
           qs = getCache().getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         for (int i = 0; i < queries.length; i++) {
           try {
             res = (SelectResults) qs.newQuery(queries[i]).execute();
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -268,6 +276,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     closeCache(server3);
   }
 
+  @Test
   public void testSelectStarQueryForReplicatedRegion() throws Exception {
     final Host host = Host.getHost(0);
     final VM server1 = host.getVM(1);
@@ -275,13 +284,11 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     // create servers and regions
     final int port1 = startReplicatedCacheServer(server1);
 
-    final QueryObserver oldObserver = (QueryObserver) server1
-        .invoke(new SerializableCallable("Set observer") {
+    server1.invoke(new SerializableCallable("Set observer") {
           @Override
           public Object call() throws Exception {
-            QueryObserver observer = QueryObserverHolder
-                .setInstance(new QueryResultTrackingObserver());
-            return observer;
+            oldObserver = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
+            return null;
           }
         });
 
@@ -290,7 +297,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
       @Override
       public Object call() throws Exception {
         ClientCacheFactory cf = new ClientCacheFactory();
-        cf.addPoolServer(NetworkUtils.getServerHostName(server1.getHost()), port1);
+        cf.addPoolServer(getServerHostName(server1.getHost()), port1);
         ClientCache cache = getClientCache(cf);
         cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
             .create(regName);
@@ -318,14 +325,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     client.invoke(new SerializableCallable("Query") {
       @Override
       public Object call() throws Exception {
-        LogWriterUtils.getLogWriter().info("Querying remotely from client");
+        getLogWriter().info("Querying remotely from client");
         QueryService localQS = null;
         QueryService remoteQS = null;
         try {
           localQS = ((ClientCache) getCache()).getLocalQueryService();
           remoteQS = ((ClientCache) getCache()).getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         SelectResults[][] sr = new SelectResults[1][2];
@@ -340,7 +347,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
             sr[0][1] = res;
             CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + multipleRegionQueries[i], e);
+            fail("Error executing query: " + multipleRegionQueries[i], e);
           }
           assertEquals(resultSize2[i], res.size());
           if (i == 4) {
@@ -397,7 +404,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
         try {
           qs = getCache().getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         for (int i = 0; i < multipleRegionQueries.length; i++) {
@@ -405,7 +412,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
             res = (SelectResults) qs.newQuery(multipleRegionQueries[i])
                 .execute();
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + multipleRegionQueries[i], e);
+            fail("Error executing query: " + multipleRegionQueries[i], e);
           }
           assertEquals(resultSize2[i], res.size());
           if (i == 4) {
@@ -450,6 +457,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     closeCache(server1);
   }
 
+  @Test
   public void testByteArrayReplicatedRegion() throws Exception {
     final Host host = Host.getHost(0);
     final VM server1 = host.getVM(0);
@@ -475,13 +483,11 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
       }
     });
 
-    final QueryObserver oldObserver = (QueryObserver) server1
-        .invoke(new SerializableCallable("Set observer") {
+    server1.invoke(new SerializableCallable("Set observer") {
           @Override
           public Object call() throws Exception {
-            QueryObserver observer = QueryObserverHolder
-                .setInstance(new QueryResultTrackingObserver());
-            return observer;
+            oldObserver = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
+            return null;
           }
         });
 
@@ -490,7 +496,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
       @Override
       public Object call() throws Exception {
         ClientCacheFactory cf = new ClientCacheFactory();
-        cf.addPoolServer(NetworkUtils.getServerHostName(server1.getHost()), port);
+        cf.addPoolServer(getServerHostName(server1.getHost()), port);
         ClientCache cache = getClientCache(cf);
         cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
             .create(regName);
@@ -514,14 +520,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     client.invoke(new SerializableCallable("Query") {
       @Override
       public Object call() throws Exception {
-        LogWriterUtils.getLogWriter().info("Querying remotely from client");
+        getLogWriter().info("Querying remotely from client");
         QueryService localQS = null;
         QueryService remoteQS = null;
         try {
           localQS = ((ClientCache) getCache()).getLocalQueryService();
           remoteQS = ((ClientCache) getCache()).getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         SelectResults[][] sr = new SelectResults[1][2];
@@ -534,7 +540,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
             sr[0][1] = res;
             CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -585,14 +591,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
         try {
           qs = getCache().getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         for (int i = 0; i < 6; i++) {
           try {
             res = (SelectResults) qs.newQuery(queries[i]).execute();
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -631,6 +637,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     closeCache(server1);
   }
 
+  @Test
   public void testByteArrayPartitionedRegion() throws Exception {
     final Host host = Host.getHost(0);
     final VM server1 = host.getVM(0);
@@ -648,13 +655,11 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     final int port2 = startPartitionedCacheServer(server2, objs);
     final int port3 = startPartitionedCacheServer(server3, objs);
 
-    final QueryObserver oldObserver = (QueryObserver) server1
-        .invoke(new SerializableCallable("Set observer") {
+    server1.invoke(new SerializableCallable("Set observer") {
           @Override
           public Object call() throws Exception {
-            QueryObserver observer = QueryObserverHolder
-                .setInstance(new QueryResultTrackingObserver());
-            return observer;
+            oldObserver = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
+            return null;
           }
         });
 
@@ -663,9 +668,9 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
       @Override
       public Object call() throws Exception {
         ClientCacheFactory cf = new ClientCacheFactory();
-        cf.addPoolServer(NetworkUtils.getServerHostName(server1.getHost()), port1);
-        cf.addPoolServer(NetworkUtils.getServerHostName(server2.getHost()), port2);
-        cf.addPoolServer(NetworkUtils.getServerHostName(server3.getHost()), port3);
+        cf.addPoolServer(getServerHostName(server1.getHost()), port1);
+        cf.addPoolServer(getServerHostName(server2.getHost()), port2);
+        cf.addPoolServer(getServerHostName(server3.getHost()), port3);
         ClientCache cache = getClientCache(cf);
         cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
             .create(regName);
@@ -689,14 +694,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     client.invoke(new SerializableCallable("Query") {
       @Override
       public Object call() throws Exception {
-        LogWriterUtils.getLogWriter().info("Querying remotely from client");
+        getLogWriter().info("Querying remotely from client");
         QueryService localQS = null;
         QueryService remoteQS = null;
         try {
           localQS = ((ClientCache) getCache()).getLocalQueryService();
           remoteQS = ((ClientCache) getCache()).getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         SelectResults[][] sr = new SelectResults[1][2];
@@ -709,7 +714,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
             sr[0][1] = res;
             CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -760,14 +765,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
         try {
           qs = getCache().getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         for (int i = 0; i < 6; i++) {
           try {
             res = (SelectResults) qs.newQuery(queries[i]).execute();
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -808,6 +813,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
 
   }
 
+  @Test
   public void testSelectStarQueryForIndexes() throws Exception {
     final Host host = Host.getHost(0);
     final VM server1 = host.getVM(0);
@@ -819,7 +825,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
       @Override
       public Object call() throws Exception {
         ClientCacheFactory cf = new ClientCacheFactory();
-        cf.addPoolServer(NetworkUtils.getServerHostName(server1.getHost()), port1);
+        cf.addPoolServer(getServerHostName(server1.getHost()), port1);
         ClientCache cache = getClientCache(cf);
         cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
             .create(regName);
@@ -852,7 +858,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
           qs = getCache().getQueryService();
           qs.createIndex("status", "status", "/" + regName);
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
 
         return null;
@@ -863,14 +869,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     client.invoke(new SerializableCallable("Query") {
       @Override
       public Object call() throws Exception {
-        LogWriterUtils.getLogWriter().info("Querying remotely from client");
+        getLogWriter().info("Querying remotely from client");
         QueryService localQS = null;
         QueryService remoteQS = null;
         try {
           localQS = ((ClientCache) getCache()).getLocalQueryService();
           remoteQS = ((ClientCache) getCache()).getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         SelectResults[][] sr = new SelectResults[1][2];
@@ -885,7 +891,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
             sr[0][1] = res;
             CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + multipleRegionQueries[i], e);
+            fail("Error executing query: " + multipleRegionQueries[i], e);
           }
           assertEquals(resultSize2[i], res.size());
           if (i == 4) {
@@ -928,7 +934,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
           qs = getCache().getQueryService();
           qs.createIndex("status", "status", "/" + regName2);
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
 
         return null;
@@ -939,14 +945,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     client.invoke(new SerializableCallable("Query") {
       @Override
       public Object call() throws Exception {
-        LogWriterUtils.getLogWriter().info("Querying remotely from client");
+        getLogWriter().info("Querying remotely from client");
         QueryService localQS = null;
         QueryService remoteQS = null;
         try {
           localQS = ((ClientCache) getCache()).getLocalQueryService();
           remoteQS = ((ClientCache) getCache()).getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         SelectResults[][] sr = new SelectResults[1][2];
@@ -961,7 +967,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
             sr[0][1] = res;
             CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + multipleRegionQueries[i], e);
+            fail("Error executing query: " + multipleRegionQueries[i], e);
           }
           assertEquals(resultSize2[i], res.size());
           if (i == 4) {
@@ -999,6 +1005,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     closeCache(server1);
   }
 
+  @Test
   public void testSelectStarQueryForPdxObjects() throws Exception {
     final Host host = Host.getHost(0);
     final VM server1 = host.getVM(0);
@@ -1006,13 +1013,11 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     // create servers and regions
     final int port1 = startReplicatedCacheServer(server1);
 
-    final QueryObserver oldObserver = (QueryObserver) server1
-        .invoke(new SerializableCallable("Set observer") {
+    server1.invoke(new SerializableCallable("Set observer") {
           @Override
           public Object call() throws Exception {
-            QueryObserver observer = QueryObserverHolder
-                .setInstance(new QueryResultTrackingObserver());
-            return observer;
+            oldObserver = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
+            return null;
           }
         });
 
@@ -1021,7 +1026,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
       @Override
       public Object call() throws Exception {
         ClientCacheFactory cf = new ClientCacheFactory();
-        cf.addPoolServer(NetworkUtils.getServerHostName(server1.getHost()), port1);
+        cf.addPoolServer(getServerHostName(server1.getHost()), port1);
         ClientCache cache = getClientCache(cf);
         cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
             .create(regName);
@@ -1045,14 +1050,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     client.invoke(new SerializableCallable("Query") {
       @Override
       public Object call() throws Exception {
-        LogWriterUtils.getLogWriter().info("Querying remotely from client");
+        getLogWriter().info("Querying remotely from client");
         QueryService localQS = null;
         QueryService remoteQS = null;
         try {
           localQS = ((ClientCache) getCache()).getLocalQueryService();
           remoteQS = ((ClientCache) getCache()).getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         SelectResults[][] sr = new SelectResults[1][2];
@@ -1065,7 +1070,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
             sr[0][1] = res;
             CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -1120,14 +1125,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
         try {
           qs = getCache().getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         for (int i = 0; i < queries.length; i++) {
           try {
             res = (SelectResults) qs.newQuery(queries[i]).execute();
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -1176,14 +1181,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
         try {
           qs = getCache().getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         for (int i = 0; i < queries.length; i++) {
           try {
             res = (SelectResults) qs.newQuery(queries[i]).execute();
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -1219,6 +1224,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     closeCache(server1);
   }
 
+  @Test
   public void testSelectStarQueryForPdxAndNonPdxObjects() throws Exception {
     final Host host = Host.getHost(0);
     final VM server1 = host.getVM(0);
@@ -1227,13 +1233,11 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     // put domain objects
     final int port1 = startReplicatedCacheServer(server1);
 
-    final QueryObserver oldObserver = (QueryObserver) server1
-        .invoke(new SerializableCallable("Set observer") {
+    server1.invoke(new SerializableCallable("Set observer") {
           @Override
           public Object call() throws Exception {
-            QueryObserver observer = QueryObserverHolder
-                .setInstance(new QueryResultTrackingObserver());
-            return observer;
+            oldObserver = QueryObserverHolder.setInstance(new QueryResultTrackingObserver());
+            return null;
           }
         });
 
@@ -1242,7 +1246,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
       @Override
       public Object call() throws Exception {
         ClientCacheFactory cf = new ClientCacheFactory();
-        cf.addPoolServer(NetworkUtils.getServerHostName(server1.getHost()), port1);
+        cf.addPoolServer(getServerHostName(server1.getHost()), port1);
         ClientCache cache = getClientCache(cf);
         cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
             .create(regName);
@@ -1266,14 +1270,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     client.invoke(new SerializableCallable("Query") {
       @Override
       public Object call() throws Exception {
-        LogWriterUtils.getLogWriter().info("Querying remotely from client");
+        getLogWriter().info("Querying remotely from client");
         QueryService localQS = null;
         QueryService remoteQS = null;
         try {
           localQS = ((ClientCache) getCache()).getLocalQueryService();
           remoteQS = ((ClientCache) getCache()).getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         SelectResults[][] sr = new SelectResults[1][2];
@@ -1286,7 +1290,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
             sr[0][1] = res;
             CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -1343,14 +1347,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
         try {
           qs = getCache().getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         for (int i = 0; i < queries.length; i++) {
           try {
             res = (SelectResults) qs.newQuery(queries[i]).execute();
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -1399,14 +1403,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
         try {
           qs = getCache().getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         for (int i = 0; i < queries.length; i++) {
           try {
             res = (SelectResults) qs.newQuery(queries[i]).execute();
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -1443,8 +1447,8 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     closeCache(server1);
   }
 
-  public void testSelectStarQueryForPdxObjectsReadSerializedTrue()
-      throws Exception {
+  @Test
+  public void testSelectStarQueryForPdxObjectsReadSerializedTrue() throws Exception {
     final Host host = Host.getHost(0);
     final VM server1 = host.getVM(0);
     final VM client = host.getVM(3);
@@ -1469,7 +1473,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
       @Override
       public Object call() throws Exception {
         ClientCacheFactory cf = new ClientCacheFactory();
-        cf.addPoolServer(NetworkUtils.getServerHostName(server1.getHost()), port);
+        cf.addPoolServer(getServerHostName(server1.getHost()), port);
         ClientCache cache = getClientCache(cf);
         cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
             .create(regName);
@@ -1485,14 +1489,14 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     client.invoke(new SerializableCallable("Query") {
       @Override
       public Object call() throws Exception {
-        LogWriterUtils.getLogWriter().info("Querying remotely from client");
+        getLogWriter().info("Querying remotely from client");
         QueryService localQS = null;
         QueryService remoteQS = null;
         try {
           localQS = ((ClientCache) getCache()).getLocalQueryService();
           remoteQS = ((ClientCache) getCache()).getQueryService();
         } catch (Exception e) {
-          Assert.fail("Exception getting query service ", e);
+          fail("Exception getting query service ", e);
         }
         SelectResults res = null;
         SelectResults[][] sr = new SelectResults[1][2];
@@ -1505,7 +1509,7 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
             sr[0][1] = res;
             CacheUtils.compareResultsOfWithAndWithoutIndex(sr);
           } catch (Exception e) {
-            Assert.fail("Error executing query: " + queries[i], e);
+            fail("Error executing query: " + queries[i], e);
           }
           assertEquals(resultSize[i], res.size());
           if (i == 3) {
@@ -1597,17 +1601,17 @@ public class SelectStarQueryDUnitTest extends CacheTestCase {
     });
   }
 
-  public class QueryResultTrackingObserver extends QueryObserverAdapter 
-      implements Serializable{
+  public class QueryResultTrackingObserver extends QueryObserverAdapter implements Serializable {
+
     private boolean isObjectSerialized = false;
+
     @Override
-    public void beforeIterationEvaluation(CompiledValue executer,
-        Object currentObject) {
+    public void beforeIterationEvaluation(CompiledValue executer, Object currentObject) {
       if (currentObject instanceof VMCachedDeserializable) {
-        LogWriterUtils.getLogWriter().fine("currentObject is serialized object");
+        getLogWriter().fine("currentObject is serialized object");
         isObjectSerialized = true;
       } else {
-        LogWriterUtils.getLogWriter().fine("currentObject is deserialized object");
+        getLogWriter().fine("currentObject is deserialized object");
       }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2d5969e/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
index 8f4740c..68e50bd 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
@@ -16,6 +16,8 @@
  */
 package com.gemstone.gemfire.cache30;
 
+import static com.gemstone.gemfire.internal.lang.ThrowableUtils.*;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInput;
@@ -9047,16 +9049,7 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
     try {
       async.getResult();
     } catch (Throwable e) {
-      if (e.getCause() instanceof RMIException) {
-        Throwable e2 = e.getCause();
-        if (e2.getCause() instanceof AssertionFailedError &&
-            e2.getCause().getMessage().equals(expectedError)) {
-          failed=true;
-        }
-      }
-      if (!failed) {
-        com.gemstone.gemfire.test.dunit.Assert.fail("asyncInvocation 0 returned exception", e);
-      }
+      assertTrue(hasCauseMessage(e, expectedError));
     }
     return failed;
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2d5969e/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/ShutdownAllDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/ShutdownAllDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/ShutdownAllDUnitTest.java
index a1ba6d2..426d0ca 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/ShutdownAllDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/partitioned/ShutdownAllDUnitTest.java
@@ -16,6 +16,8 @@
  */
 package com.gemstone.gemfire.internal.cache.partitioned;
 
+import static com.gemstone.gemfire.internal.lang.ThrowableUtils.getRootCause;
+
 import java.io.IOException;
 import java.util.Set;
 import java.util.TreeSet;
@@ -556,12 +558,8 @@ public class ShutdownAllDUnitTest extends CacheTestCase {
     try {
       a0.getResult(MAX_WAIT);
       fail("should have received a cache closed exception");
-    } catch(Exception e) {
-      if(!(e.getCause() instanceof RMIException)) {
-        throw e;
-      }
-      RMIException cause = (RMIException) e.getCause();
-      if(!(cause.getCause() instanceof CacheClosedException)) {
+    } catch(AssertionError e) {
+      if(!CacheClosedException.class.isInstance(getRootCause(e))) {
         throw e;
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2d5969e/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java
index 321fffe..4f0fcca 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/persistence/PersistentRecoveryOrderDUnitTest.java
@@ -16,6 +16,8 @@
  */
 package com.gemstone.gemfire.internal.cache.persistence;
 
+import static com.gemstone.gemfire.internal.lang.ThrowableUtils.*;
+
 import java.io.ByteArrayInputStream;
 import java.io.DataInputStream;
 import java.io.File;
@@ -1317,8 +1319,8 @@ public class PersistentRecoveryOrderDUnitTest extends PersistentReplicatedTestBa
     try {
       async1.getResult();
       fail("Should have seen a CacheClosedException");
-    } catch (Exception e) {
-      if (! (e.getCause().getCause() instanceof CacheClosedException)) {
+    } catch (AssertionError e) {
+      if (!CacheClosedException.class.isInstance(getRootCause(e))) {
         throw e;
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2d5969e/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ThrowableUtilsTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ThrowableUtilsTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ThrowableUtilsTest.java
new file mode 100644
index 0000000..08feb63
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/lang/ThrowableUtilsTest.java
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.internal.lang;
+
+import static org.assertj.core.api.Assertions.*;
+import static com.googlecode.catchexception.CatchException.*;
+import static com.googlecode.catchexception.CatchException.caughtException;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+/**
+ * Unit tests for {@link ThrowableUtils}
+ */
+@Category(UnitTest.class)
+public class ThrowableUtilsTest {
+
+  @Test
+  public void getRootCauseOfNullShouldThrowNullPointerException() {
+    catchException(this).getRootCause(null);
+
+    assertThat((Exception)caughtException()).isExactlyInstanceOf(NullPointerException.class);
+  }
+
+  @Test
+  public void getRootCauseOfLeafExceptionShouldReturnSameInstance() {
+    Throwable exception = new Exception();
+    Throwable rootCause = getRootCause(exception);
+
+    assertThat(rootCause).isSameAs(exception);
+  }
+
+  @Test
+  public void getRootCauseOfExceptionShouldReturnCause() {
+    Throwable cause = new Exception();
+    Throwable rootCause = getRootCause(new Exception(cause));
+
+    assertThat(rootCause).isSameAs(cause);
+  }
+
+  @Test
+  public void getRootCauseOfExceptionTreeShouldReturnCause() {
+    Throwable cause = new Exception();
+    Throwable rootCause = getRootCause(new Exception(new Exception(cause)));
+
+    assertThat(rootCause).isSameAs(cause);
+  }
+
+  @Test
+  public void getRootCauseOfErrorTreeShouldReturnCause() {
+    Throwable cause = new Error();
+    Throwable rootCause = getRootCause(new Error(new Error(cause)));
+
+    assertThat(rootCause).isSameAs(cause);
+  }
+
+  @Test
+  public void hasCauseTypeOfNullClassShouldThrowNullPointerException() {
+    catchException(this).hasCauseType(new Exception(), null);
+
+    assertThat((Exception)caughtException()).isExactlyInstanceOf(NullPointerException.class);
+  }
+
+  @Test
+  public void hasCauseTypeOfNullThrowableShouldThrowNullPointerException() {
+    catchException(this).hasCauseType(null, Exception.class);
+
+    assertThat((Exception)caughtException()).isExactlyInstanceOf(NullPointerException.class);
+  }
+
+  @Test
+  public void hasCauseTypeOfNonMatchingShouldReturnFalse() {
+    assertThat(hasCauseType(new OneException(), OtherException.class)).isFalse();
+  }
+
+  @Test
+  public void hasCauseTypeOfSameClassShouldReturnTrue() {
+    assertThat(hasCauseType(new OneException(), OneException.class)).isTrue();
+  }
+
+  @Test
+  public void hasCauseTypeOfSuperClassShouldReturnFalse() {
+    assertThat(hasCauseType(new OneException(), SubException.class)).isFalse();
+  }
+
+  @Test
+  public void hasCauseTypeOfSubClassShouldReturnTrue() {
+    assertThat(hasCauseType(new SubException(), OneException.class)).isTrue();
+  }
+
+  @Test
+  public void hasCauseTypeOfWrappedClassShouldReturnTrue() {
+    assertThat(hasCauseType(new OneException(new TwoException()), TwoException.class)).isTrue();
+  }
+
+  @Test
+  public void hasCauseTypeOfWrappingClassShouldReturnTrue() {
+    assertThat(hasCauseType(new OneException(new TwoException()), OneException.class)).isTrue();
+  }
+
+  @Test
+  public void hasCauseTypeOfNestedClassShouldReturnTrue() {
+    assertThat(hasCauseType(new OneException(new TwoException(new OtherException())), OtherException.class)).isTrue();
+  }
+
+  @Test
+  public void hasCauseMessageForNullShouldThrowNullPointerException() {
+    catchException(this).hasCauseMessage(null, "message");
+
+    assertThat((Exception)caughtException()).isExactlyInstanceOf(NullPointerException.class);
+  }
+
+  @Test
+  public void hasCauseMessageOfNullShouldThrowNullPointerException() {
+    catchException(this).hasCauseMessage(new OneException(), null);
+
+    assertThat((Exception)caughtException()).isExactlyInstanceOf(NullPointerException.class);
+  }
+
+  @Test
+  public void hasCauseMessageForNullMessageShouldThrowNullPointerException() {
+    catchException(this).hasCauseMessage(new OneException((String)null), null);
+
+    assertThat((Exception)caughtException()).isExactlyInstanceOf(NullPointerException.class);
+  }
+
+  @Test
+  public void hasCauseMessageOfNonMatchingNullMessageShouldThrowNullPointerException() {
+    catchException(this).hasCauseMessage(new OneException("message"), null);
+
+    assertThat((Exception)caughtException()).isExactlyInstanceOf(NullPointerException.class);
+  }
+
+  @Test
+  public void hasCauseMessageOfEmptyMessageShouldReturnTrue() {
+    assertThat(hasCauseMessage(new OneException(""), "")).isTrue();
+  }
+
+  @Test
+  public void hasCauseMessageOfMatchingMessageShouldReturnTrue() {
+    assertThat(hasCauseMessage(new OneException("message"), "message")).isTrue();
+  }
+
+  @Test
+  public void hasCauseMessageOfNonMatchingMessageShouldReturnFalse() {
+    assertThat(hasCauseMessage(new OneException("non-matching"), "message")).isFalse();
+  }
+
+  @Test
+  public void hasCauseMessageOfContainedMessageShouldReturnTrue() {
+    assertThat(hasCauseMessage(new OneException("this is the message"), "message")).isTrue();
+  }
+
+  @Test
+  public void hasCauseMessageOfPartialMatchingMessageShouldReturnFalse() {
+    assertThat(hasCauseMessage(new OneException("message"), "this is the message")).isFalse();
+  }
+
+  public Throwable getRootCause(final Throwable throwable) {
+    return ThrowableUtils.getRootCause(throwable);
+  }
+
+  public boolean hasCauseType(final Throwable throwable, final Class<? extends Throwable> causeClass) {
+    return ThrowableUtils.hasCauseType(throwable, causeClass);
+  }
+
+  public boolean hasCauseMessage(final Throwable throwable, final String message) {
+    return ThrowableUtils.hasCauseMessage(throwable, message);
+  }
+
+  private static class OneException extends Exception {
+    public OneException() {
+    }
+    public OneException(String message) {
+      super(message);
+    }
+    public OneException(Throwable cause) {
+      super(cause);
+    }
+    public OneException(String message, Throwable cause) {
+      super(message, cause);
+    }
+  }
+
+  private static class SubException extends OneException {
+    public SubException() {
+    }
+    public SubException(String message) {
+      super(message);
+    }
+    public SubException(Throwable cause) {
+      super(cause);
+    }
+    public SubException(String message, Throwable cause) {
+      super(message, cause);
+    }
+  }
+
+  private static class TwoException extends Exception {
+    public TwoException() {
+    }
+    public TwoException(String message) {
+      super(message);
+    }
+    public TwoException(Throwable cause) {
+      super(cause);
+    }
+    public TwoException(String message, Throwable cause) {
+      super(message, cause);
+    }
+  }
+
+  private static class OtherException extends Exception {
+    public OtherException() {
+    }
+    public OtherException(String message) {
+      super(message);
+    }
+    public OtherException(Throwable cause) {
+      super(cause);
+    }
+    public OtherException(String message, Throwable cause) {
+      super(message, cause);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2d5969e/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/AbstractCommandsSupportJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/AbstractCommandsSupportJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/AbstractCommandsSupportJUnitTest.java
index 8d9971e..2b2377b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/AbstractCommandsSupportJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/AbstractCommandsSupportJUnitTest.java
@@ -23,6 +23,14 @@ import java.io.StringWriter;
 import java.util.Collections;
 import java.util.Set;
 
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.execute.FunctionService;
@@ -35,14 +43,6 @@ import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
 import com.gemstone.gemfire.management.internal.cli.util.MemberNotFoundException;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.lib.legacy.ClassImposteriser;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
 /**
  * The AbstractCommandsSupportJUnitTest class is a test suite of test cases testing the contract and functionality
  * of the AbstractCommandsSupport class for implementing GemFire shell (Gfsh) commands.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f2d5969e/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
index 7d8dc55..55f5556 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/CliCommandTestBase.java
@@ -16,8 +16,22 @@
  */
 package com.gemstone.gemfire.management.internal.cli.commands;
 
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.management.ManagementService;
@@ -29,29 +43,14 @@ import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
 import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
 import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
 import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-
-import util.TestException;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
 
 /**
  * Base class for all the CLI/gfsh command dunit tests.
- *
  */
-public class CliCommandTestBase extends CacheTestCase {
+public class CliCommandTestBase extends JUnit4CacheTestCase {
 
   private static final long serialVersionUID = 1L;
 
@@ -68,10 +67,6 @@ public class CliCommandTestBase extends CacheTestCase {
 
   private String jmxHost;
 
-  public CliCommandTestBase(String name) {
-    super(name);
-  }
-
   @Override
   public final void preTearDownCacheTestCase() throws Exception {
     preTearDownCliCommandTestBase();
@@ -238,7 +233,7 @@ public class CliCommandTestBase extends CacheTestCase {
     CommandResult result = executeCommand(shell, command.toString());
 
     if (!shell.isConnectedAndReady()) {
-      throw new TestException(
+      throw new AssertionError(
           "Connect command failed to connect to manager " + endpoint + " result=" + commandResultToString(result));
     }
 
@@ -273,9 +268,9 @@ public class CliCommandTestBase extends CacheTestCase {
       info("Started testable shell: " + shell);
       return shell;
     } catch (ClassNotFoundException e) {
-      throw new TestException(getStackTrace(e));
+      throw new AssertionError(getStackTrace(e));
     } catch (IOException e) {
-      throw new TestException(getStackTrace(e));
+      throw new AssertionError(getStackTrace(e));
     }
   }
 
@@ -338,9 +333,9 @@ public class CliCommandTestBase extends CacheTestCase {
     try {
       info("Executing command " + command + " with command Mgr " + CommandManager.getInstance());
     } catch (ClassNotFoundException cnfex) {
-      throw new TestException(getStackTrace(cnfex));
+      throw new AssertionError(getStackTrace(cnfex));
     } catch (IOException ioex) {
-      throw new TestException(getStackTrace(ioex));
+      throw new AssertionError(getStackTrace(ioex));
     }
 
     shell.executeCommand(command);
@@ -540,18 +535,18 @@ public class CliCommandTestBase extends CacheTestCase {
   }
 
   protected void info(String string) {
-    LogWriterUtils.getLogWriter().info(string);
+    getLogWriter().info(string);
   }
 
   protected void debug(String string) {
-    LogWriterUtils.getLogWriter().fine(string);
+    getLogWriter().fine(string);
   }
 
   protected void error(String string) {
-    LogWriterUtils.getLogWriter().error(string);
+    getLogWriter().error(string);
   }
 
   protected void error(String string, Throwable e) {
-    LogWriterUtils.getLogWriter().error(string, e);
+    getLogWriter().error(string, e);
   }
 }


Mime
View raw message