geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [02/27] incubator-geode git commit: GEODE 773 rough draft
Date Tue, 26 Jan 2016 00:49:12 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2f18f97/gemfire-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
index 2ac470c..45334cc 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
@@ -78,7 +78,12 @@ import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.internal.logging.PureLogWriter;
 import com.gemstone.gemfire.internal.util.Callable;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.DUnitEnv;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.NetworkSupport;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
 
 /**
  * Contains utility methods for setting up servers/clients for authentication
@@ -207,7 +212,7 @@ public class SecurityTestUtil extends DistributedTestCase {
 
     Integer locatorPort = new Integer(AvailablePort
         .getRandomAvailablePort(AvailablePort.SOCKET));
-    String addr = DistributedTestCase.getIPLiteral();
+    String addr = NetworkSupport.getIPLiteral();
     if (locatorString == null) {
       locatorString = addr + "[" + locatorPort + ']';
     }
@@ -287,10 +292,10 @@ public class SecurityTestUtil extends DistributedTestCase {
       authProps.setProperty(DistributionConfig.LOCATORS_NAME, locatorString);
       if (locatorPort != null) {
         authProps.setProperty(DistributionConfig.START_LOCATOR_NAME,
-            DistributedTestCase.getIPLiteral() + "[" + locatorPort.toString() + ']');
+            NetworkSupport.getIPLiteral() + "[" + locatorPort.toString() + ']');
       }
     } else {
-      authProps.setProperty("locators", "localhost["+getDUnitLocatorPort()+"]");
+      authProps.setProperty("locators", "localhost["+DUnitEnv.getDUnitLocatorPort()+"]");
     }
     authProps.setProperty(DistributionConfig.SECURITY_LOG_LEVEL_NAME, "finest");
     getLogWriter().info("Set the server properties to: " + authProps);
@@ -309,7 +314,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         return new Integer(0);
       }
       else {
-        fail("Got unexpected exception when starting peer", ex);
+        Assert.fail("Got unexpected exception when starting peer", ex);
       }
     }
     catch (AuthenticationFailedException ex) {
@@ -318,11 +323,11 @@ public class SecurityTestUtil extends DistributedTestCase {
         return new Integer(0);
       }
       else {
-        fail("Got unexpected exception when starting peer", ex);
+        Assert.fail("Got unexpected exception when starting peer", ex);
       }
     }
     catch (Exception ex) {
-      fail("Got unexpected exception when starting peer", ex);
+      Assert.fail("Got unexpected exception when starting peer", ex);
     }
 
     if (setupDynamicRegionFactory.booleanValue()) {
@@ -348,7 +353,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       server1.start();
     }
     catch (Exception ex) {
-      fail("Got unexpected exception when starting CacheServer", ex);
+      Assert.fail("Got unexpected exception when starting CacheServer", ex);
     }
     return new Integer(server1.getPort());
   }
@@ -422,7 +427,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         //poolFactory.setSubscriptionEnabled(false);
       }
       pool = ClientServerTestCase.configureConnectionPoolWithNameAndFactory(factory,
-          DistributedTestCase.getIPLiteral(), portsI, subscriptionEnabled, 0,
+          NetworkSupport.getIPLiteral(), portsI, subscriptionEnabled, 0,
           numConnections == null ? -1 : numConnections.intValue(), null, null,
           poolFactory);
 
@@ -441,7 +446,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected UnsupportedOperationException in single-user
mode");
         }
         else {
-          fail("Got unexpected exception in multi-user mode ", uoe);
+          Assert.fail("Got unexpected exception in multi-user mode ", uoe);
         }
       }
 
@@ -466,7 +471,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        fail("Got unexpected exception when starting client", ex);
+        Assert.fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (AuthenticationFailedException ex) {
@@ -475,7 +480,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        fail("Got unexpected exception when starting client", ex);
+        Assert.fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (ServerRefusedConnectionException ex) {
@@ -484,11 +489,11 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        fail("Got unexpected exception when starting client", ex);
+        Assert.fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (Exception ex) {
-      fail("Got unexpected exception when starting client", ex);
+      Assert.fail("Got unexpected exception when starting client", ex);
     }
   }
 
@@ -564,7 +569,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       poolFactory.setMultiuserAuthentication(multiUserAuthMode);
       poolFactory.setSubscriptionEnabled(true);
       pool = ClientServerTestCase.configureConnectionPoolWithNameAndFactory(factory,
-          DistributedTestCase.getIPLiteral(), portsI, true, 1,
+          NetworkSupport.getIPLiteral(), portsI, true, 1,
           numConnections == null ? -1 : numConnections.intValue(), null, null,
           poolFactory);
 
@@ -595,7 +600,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        fail("Got unexpected exception when starting client", ex);
+        Assert.fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (AuthenticationFailedException ex) {
@@ -604,7 +609,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        fail("Got unexpected exception when starting client", ex);
+        Assert.fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (ServerRefusedConnectionException ex) {
@@ -613,11 +618,11 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        fail("Got unexpected exception when starting client", ex);
+        Assert.fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (Exception ex) {
-      fail("Got unexpected exception when starting client", ex);
+      Assert.fail("Got unexpected exception when starting client", ex);
     }
   }
 
@@ -647,7 +652,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         server.start();
       }
       catch (Exception ex) {
-        fail("Unexpected exception when restarting cache servers", ex);
+        Assert.fail("Unexpected exception when restarting cache servers", ex);
       }
       assertTrue(server.isRunning());
     }
@@ -664,7 +669,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       }
       authProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
       authProps.setProperty(DistributionConfig.LOCATORS_NAME, 
-                            DistributedTestCase.getIPLiteral() + "[" + port + "]");
+                            NetworkSupport.getIPLiteral() + "[" + port + "]");
       authProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
       clearStaticSSLContext();
       setJavaProps((Properties)javaProps);
@@ -678,7 +683,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           authProps);
     }
     catch (IOException ex) {
-      fail("While starting locator on port " + port.intValue(), ex);
+      Assert.fail("While starting locator on port " + port.intValue(), ex);
     }
   }
 
@@ -690,7 +695,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           .getDistributedSystem().getLogWriter());
     }
     catch (Exception ex) {
-      fail("While stopping locator on port " + port.intValue(), ex);
+      Assert.fail("While stopping locator on port " + port.intValue(), ex);
     }
   }
 
@@ -712,7 +717,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           return ((Boolean)cond.call()).booleanValue();
         }
         catch (Exception e) {
-          fail("Unexpected exception", e);
+          Assert.fail("Unexpected exception", e);
         }
         return false; // NOTREACHED
       }
@@ -720,7 +725,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         return null;
       }
     };
-    DistributedTestCase.waitForCriterion(ev, sleepMillis * numTries, 200, true);
+    Wait.waitForCriterion(ev, sleepMillis * numTries, 200, true);
   }
 
   public static Object getLocalValue(Region region, Object key) {
@@ -760,7 +765,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info("Got expected exception when doing puts: " + ex);
       }
       else {
-        fail("Got unexpected exception when doing puts", ex);
+        Assert.fail("Got unexpected exception when doing puts", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
@@ -783,7 +788,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           continue;
         }
         else {
-          fail("Got unexpected exception when doing puts", ex);
+          Assert.fail("Got unexpected exception when doing puts", ex);
         }
       }
       catch (ServerConnectivityException ex) {
@@ -812,7 +817,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected exception when doing puts: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing puts", ex);
+          Assert.fail("Got unexpected exception when doing puts", ex);
         }
       }
       catch (Exception ex) {
@@ -820,7 +825,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected exception when doing puts: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing puts", ex);
+          Assert.fail("Got unexpected exception when doing puts", ex);
         }
       }
     }
@@ -843,7 +848,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info("Got expected exception when doing getAll: " + ex);
       }
       else {
-        fail("Got unexpected exception when doing getAll", ex);
+        Assert.fail("Got unexpected exception when doing getAll", ex);
       }
     }
     try {
@@ -873,7 +878,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected NoAvailableServers when doing getAll: "
                 + ex.getCause());
       } else {
-        fail("Got unexpected exception when doing getAll", ex);
+        Assert.fail("Got unexpected exception when doing getAll", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -884,13 +889,13 @@ public class SecurityTestUtil extends DistributedTestCase {
       } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing getAll: " + ex);
       } else {
-        fail("Got unexpected exception when doing getAll", ex);
+        Assert.fail("Got unexpected exception when doing getAll", ex);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing getAll: " + ex);
       } else {
-        fail("Got unexpected exception when doing getAll", ex);
+        Assert.fail("Got unexpected exception when doing getAll", ex);
       }
     }
   }
@@ -919,7 +924,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info("Got expected exception when doing gets: " + ex);
       }
       else {
-        fail("Got unexpected exception when doing gets", ex);
+        Assert.fail("Got unexpected exception when doing gets", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
@@ -943,7 +948,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           continue;
         }
         else {
-          fail("Got unexpected exception when doing gets", ex);
+          Assert.fail("Got unexpected exception when doing gets", ex);
         }
       }
       catch (ServerConnectivityException ex) {
@@ -958,7 +963,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected exception when doing gets: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing gets", ex);
+          Assert.fail("Got unexpected exception when doing gets", ex);
         }
       }
       catch (Exception ex) {
@@ -966,7 +971,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected exception when doing gets: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing gets", ex);
+          Assert.fail("Got unexpected exception when doing gets", ex);
         }
       }
       assertNotNull(value);
@@ -1020,7 +1025,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info(
             "Got expected exception when doing region destroy: " + ex);
       } else {
-        fail("Got unexpected exception when doing region destroy", ex);
+        Assert.fail("Got unexpected exception when doing region destroy", ex);
       }
     }
 
@@ -1041,7 +1046,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected NoAvailableServers when doing region destroy: "
                 + ex.getCause());
       } else {
-        fail("Got unexpected exception when doing region destroy", ex);
+        Assert.fail("Got unexpected exception when doing region destroy", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1053,14 +1058,14 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info(
             "Got expected exception when doing region destroy: " + ex);
       } else {
-        fail("Got unexpected exception when doing region destroy", ex);
+        Assert.fail("Got unexpected exception when doing region destroy", ex);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         getLogWriter().info(
             "Got expected exception when doing region destroy: " + ex);
       } else {
-        fail("Got unexpected exception when doing region destroy", ex);
+        Assert.fail("Got unexpected exception when doing region destroy", ex);
       }
     }
   }
@@ -1084,7 +1089,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info("Got expected exception when doing destroys: " + ex);
       }
       else {
-        fail("Got unexpected exception when doing destroys", ex);
+        Assert.fail("Got unexpected exception when doing destroys", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
@@ -1102,7 +1107,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           continue;
         }
         else {
-          fail("Got unexpected exception when doing destroys", ex);
+          Assert.fail("Got unexpected exception when doing destroys", ex);
         }
       }
       catch (ServerConnectivityException ex) {
@@ -1117,7 +1122,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected exception when doing destroys: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing destroys", ex);
+          Assert.fail("Got unexpected exception when doing destroys", ex);
         }
       }
       catch (Exception ex) {
@@ -1125,7 +1130,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected exception when doing destroys: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing destroys", ex);
+          Assert.fail("Got unexpected exception when doing destroys", ex);
         }
       }
     }
@@ -1150,7 +1155,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info("Got expected exception when doing invalidates: " + ex);
       }
       else {
-        fail("Got unexpected exception when doing invalidates", ex);
+        Assert.fail("Got unexpected exception when doing invalidates", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
@@ -1168,7 +1173,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           continue;
         }
         else {
-          fail("Got unexpected exception when doing invalidates", ex);
+          Assert.fail("Got unexpected exception when doing invalidates", ex);
         }
       }
       catch (ServerConnectivityException ex) {
@@ -1183,7 +1188,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected exception when doing invalidates: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing invalidates", ex);
+          Assert.fail("Got unexpected exception when doing invalidates", ex);
         }
       }
       catch (Exception ex) {
@@ -1191,7 +1196,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected exception when doing invalidates: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing invalidates", ex);
+          Assert.fail("Got unexpected exception when doing invalidates", ex);
         }
       }
     }
@@ -1216,7 +1221,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info("Got expected exception when doing containsKey: " + ex);
       }
       else {
-        fail("Got unexpected exception when doing containsKey", ex);
+        Assert.fail("Got unexpected exception when doing containsKey", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
@@ -1235,7 +1240,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           continue;
         }
         else {
-          fail("Got unexpected exception when doing containsKey", ex);
+          Assert.fail("Got unexpected exception when doing containsKey", ex);
         }
       }
       catch (ServerConnectivityException ex) {
@@ -1250,7 +1255,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected exception when doing containsKey: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing containsKey", ex);
+          Assert.fail("Got unexpected exception when doing containsKey", ex);
         }
       }
       catch (Exception ex) {
@@ -1258,7 +1263,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           getLogWriter().info("Got expected exception when doing containsKey: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing containsKey", ex);
+          Assert.fail("Got unexpected exception when doing containsKey", ex);
         }
       }
       assertEquals(expectedValue, result);
@@ -1279,7 +1284,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing queries: " + ex);
       } else {
-        fail("Got unexpected exception when doing queries", ex);
+        Assert.fail("Got unexpected exception when doing queries", ex);
       }
     }
     String queryStr = "SELECT DISTINCT * FROM " + region.getFullPath();
@@ -1296,7 +1301,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected NoAvailableServers when doing queries: "
                 + ex.getCause());
       } else {
-        fail("Got unexpected exception when doing queries", ex);
+        Assert.fail("Got unexpected exception when doing queries", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1307,7 +1312,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing queries: " + ex);
       } else {
-        fail("Got unexpected exception when doing queries", ex);
+        Assert.fail("Got unexpected exception when doing queries", ex);
       }
     } catch (QueryInvocationTargetException qite) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1318,13 +1323,13 @@ public class SecurityTestUtil extends DistributedTestCase {
       } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing queries: " + qite);
       } else {
-        fail("Got unexpected exception when doing queries", qite);
+        Assert.fail("Got unexpected exception when doing queries", qite);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing queries: " + ex);
       } else {
-        fail("Got unexpected exception when doing queries", ex);
+        Assert.fail("Got unexpected exception when doing queries", ex);
       }
     }
   }
@@ -1345,7 +1350,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info(
             "Got expected exception when executing function: " + ex);
       } else {
-        fail("Got unexpected exception when executing function", ex);
+        Assert.fail("Got unexpected exception when executing function", ex);
       }
     }
     try {
@@ -1376,7 +1381,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected NoAvailableServers when executing function: "
                 + ex.getCause());
       } else {
-        fail("Got unexpected exception when executing function", ex);
+        Assert.fail("Got unexpected exception when executing function", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1388,7 +1393,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info(
             "Got expected exception when executing function: " + ex);
       } else {
-        fail("Got unexpected exception when executing function", ex);
+        Assert.fail("Got unexpected exception when executing function", ex);
       }
     } catch (FunctionException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1402,14 +1407,14 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info(
             "Got expected exception when executing function: " + ex);
       } else {
-        fail("Got unexpected exception when executing function", ex);
+        Assert.fail("Got unexpected exception when executing function", ex);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         getLogWriter().info(
             "Got expected exception when executing function: " + ex);
       } else {
-        fail("Got unexpected exception when executing function", ex);
+        Assert.fail("Got unexpected exception when executing function", ex);
       }
     }
   }
@@ -1429,7 +1434,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info(
             "Got expected exception when executing query: " + ex);
       } else {
-        fail("Got unexpected exception when executing query", ex);
+        Assert.fail("Got unexpected exception when executing query", ex);
       }
     }
     try {
@@ -1452,7 +1457,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected NoAvailableServers when executing query: "
                 + ex.getCause());
       } else {
-        fail("Got unexpected exception when executing query", ex);
+        Assert.fail("Got unexpected exception when executing query", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1464,14 +1469,14 @@ public class SecurityTestUtil extends DistributedTestCase {
         getLogWriter().info(
             "Got expected exception when executing query: " + ex);
       } else {
-        fail("Got unexpected exception when executing query", ex);
+        Assert.fail("Got unexpected exception when executing query", ex);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         getLogWriter().info(
             "Got expected exception when executing query: " + ex);
       } else {
-        fail("Got unexpected exception when executing query", ex);
+        Assert.fail("Got unexpected exception when executing query", ex);
       }
     }
   }
@@ -1699,7 +1704,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         }
       } catch (Exception e) {
         if (!e.getClass().getSimpleName().endsWith(expectedResult)) {
-          fail("Expected " + expectedResult + " but found "
+          Assert.fail("Expected " + expectedResult + " but found "
               + e.getClass().getSimpleName() + " in doSimplePut()", e);
         } else {
           getLogWriter().fine(

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2f18f97/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java
index 6735fe5..5ba6302 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/AsyncInvocation.java
@@ -21,13 +21,10 @@ import java.util.concurrent.TimeoutException;
 import com.gemstone.gemfire.InternalGemFireError;
 import com.gemstone.gemfire.SystemFailure;
 
-// @todo davidw Add the ability to get a return value back from the
-// async method call.  (Use a static ThreadLocal field that is
-// accessible from the Runnable used in VM#invoke)
 /**
  * <P>An <code>AsyncInvocation</code> represents the invocation of a
  * remote invocation that executes asynchronously from its caller.  An
- * instanceof <code>AsyncInvocation</code> provides information about
+ * instance of <code>AsyncInvocation</code> provides information about
  * the invocation such as any exception that it may have thrown.</P>
  *
  * <P>Because it is a <code>Thread</code>, an
@@ -50,6 +47,9 @@ import com.gemstone.gemfire.SystemFailure;
  * @see VM#invokeAsync(Class, String)
  */
 public class AsyncInvocation<T> extends Thread {
+  //@todo davidw Add the ability to get a return value back from the
+  //async method call.  (Use a static ThreadLocal field that is
+  //accessible from the Runnable used in VM#invoke)
   
   private static final ThreadLocal returnValue = new ThreadLocal();
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2f18f97/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 eea2d65..640b67c 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
@@ -21,8 +21,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.Map.Entry;
 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;
 import com.gemstone.gemfire.test.dunit.standalone.BounceResult;
 
 /**
@@ -47,7 +55,7 @@ public abstract class DUnitEnv {
         // for tests that are still being migrated to the open-source
         // distributed unit test framework  we need to look for this
         // old closed-source dunit environment
-        Class clazz = Class.forName("dunit.hydra.HydraDUnitEnv");
+        Class<?> clazz = Class.forName("dunit.hydra.HydraDUnitEnv");
         instance = (DUnitEnv)clazz.newInstance();
       } catch (Exception e) {
         throw new Error("Distributed unit test environment is not initialized");
@@ -75,5 +83,91 @@ public abstract class DUnitEnv {
   public abstract BounceResult bounce(int pid) throws RemoteException;
 
   public abstract File getWorkingDirectory(int pid);
+
+  /**
+   * 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
+   */
+  public static void addHydraProperties(Properties config) {
+    Properties p = 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);
+      }
+    }
+  }
+
+  /**
+   * 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
+   */
+  public static LogWriter createLogWriter(Properties config) { // LOG:CONVERT: this is being
used for ExpectedExceptions
+    Properties nonDefault = config;
+    if (nonDefault == null) {
+      nonDefault = new Properties();
+    }
+    DUnitEnv.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;
+  }
+
+  public final static Properties getAllDistributedSystemProperties(Properties props) { //
TODO: delete
+    Properties dsProps = get().getDistributedSystemProperties();
+    
+    // our tests do not expect auto-reconnect to be on by default
+    if (!dsProps.contains(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME)) {
+      dsProps.put(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true");
+    }
+  
+    for (Iterator<Map.Entry<Object, Object>> iter = (Iterator<Map.Entry<Object,
Object>>)props.entrySet().iterator(); iter.hasNext(); ) {
+      Map.Entry<Object, Object> entry = (Map.Entry<Object, Object>) iter.next();
+      String key = (String) entry.getKey();
+      Object value = entry.getValue();
+      dsProps.put(key, value);
+    }
+    return dsProps;
+  }
   
+  /**
+   * Get the port that the standard dunit locator is listening on.
+   * @return
+   */
+  public static int getDUnitLocatorPort() {
+    return get().getLocatorPort();
+  }
+
+  /**
+   * 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() {
+    Properties p = get().getDistributedSystemProperties();
+    String result = p.getProperty(DistributionConfig.LOG_LEVEL_NAME);
+    if (result == null) {
+      result = ManagerLogWriter.levelToString(DistributionConfig.DEFAULT_LOG_LEVEL);
+    }
+    return result;
+  }
 }


Mime
View raw message