geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [2/2] incubator-geode git commit: GEODE-1268: Cleanup of multiple AvailablePort.getRandomAvailablePort invocations
Date Thu, 21 Apr 2016 18:23:24 GMT
GEODE-1268: Cleanup of multiple AvailablePort.getRandomAvailablePort invocations


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

Branch: refs/heads/develop
Commit: 9b0026b2f72e5ac0f79afbba4dec9e6ab1231084
Parents: 79b3544
Author: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Authored: Thu Apr 21 08:10:49 2016 +1000
Committer: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Committed: Fri Apr 22 04:22:40 2016 +1000

----------------------------------------------------------------------
 .../gemfire/distributed/LocatorDUnitTest.java   | 431 +++++++++----------
 .../security/ClientAuthorizationDUnitTest.java  |   6 +-
 .../security/ClientAuthorizationTestCase.java   |  24 +-
 .../DeltaClientPostAuthorizationDUnitTest.java  |   6 +-
 .../security/P2PAuthenticationDUnitTest.java    |   2 -
 .../security/ClientAuthzObjectModDUnitTest.java |  36 +-
 .../ClientCQPostAuthorizationDUnitTest.java     |   8 +-
 .../ClientPostAuthorizationDUnitTest.java       |  11 +-
 .../MultiUserDurableCQAuthzDUnitTest.java       |   8 +-
 .../wan/misc/WANConfigurationJUnitTest.java     |  11 +-
 10 files changed, 266 insertions(+), 277 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
index 3b5f23f..71eb68e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
@@ -16,15 +16,6 @@
  */
 package com.gemstone.gemfire.distributed;
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.LineNumberReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
 import com.gemstone.gemfire.ForcedDisconnectException;
 import com.gemstone.gemfire.GemFireConfigException;
 import com.gemstone.gemfire.LogWriter;
@@ -47,6 +38,9 @@ import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.internal.logging.LocalLogWriter;
 import com.gemstone.gemfire.internal.tcp.Connection;
+import com.gemstone.gemfire.test.dunit.*;
+import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import org.junit.experimental.categories.Category;
 
 import java.io.File;
 import java.io.IOException;
@@ -55,23 +49,6 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.test.dunit.AsyncInvocation;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
-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.NetworkUtils;
-import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-import com.gemstone.gemfire.test.dunit.ThreadUtils;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
-import com.gemstone.gemfire.test.dunit.WaitCriterion;
-import com.gemstone.gemfire.test.junit.categories.FlakyTest;
-
 /**
  * Tests the ability of the {@link Locator} API to start and stop
  * locators running in remote VMs.
@@ -158,11 +135,11 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("mcast-port", "0");
     properties.put("start-locator", locators);
     properties.put("log-level", LogWriterUtils.getDUnitLogLevel());
-    properties.put("security-peer-auth-init","com.gemstone.gemfire.distributed.AuthInitializer.create");
-    properties.put("security-peer-authenticator","com.gemstone.gemfire.distributed.MyAuthenticator.create");
+    properties.put("security-peer-auth-init", "com.gemstone.gemfire.distributed.AuthInitializer.create");
+    properties.put("security-peer-authenticator", "com.gemstone.gemfire.distributed.MyAuthenticator.create");
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
     properties.put(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "false");
-    system = (InternalDistributedSystem)DistributedSystem.connect(properties);
+    system = (InternalDistributedSystem) DistributedSystem.connect(properties);
     InternalDistributedMember mbr = system.getDistributedMember();
     assertEquals("expected the VM to have NORMAL vmKind",
         DistributionManager.NORMAL_DM_TYPE, system.getDistributedMember().getVmKind());
@@ -172,7 +149,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("locators", locators);
     SerializableRunnable startSystem = new SerializableRunnable("start system") {
       public void run() {
-        system = (InternalDistributedSystem)DistributedSystem.connect(properties);
+        system = (InternalDistributedSystem) DistributedSystem.connect(properties);
       }
     };
     vm1.invoke(startSystem);
@@ -228,15 +205,15 @@ public class LocatorDUnitTest extends DistributedTestCase {
 
       properties.put("start-locator", locators);
       properties.put("log-level", LogWriterUtils.getDUnitLogLevel());
-      system = (InternalDistributedSystem)DistributedSystem.connect(properties);
+      system = (InternalDistributedSystem) DistributedSystem.connect(properties);
       System.out.println("done connecting distributed system.  Membership view is " +
-        MembershipManagerHelper.getMembershipManager(system).getView());
-      
+          MembershipManagerHelper.getMembershipManager(system).getView());
+
       assertEquals("should be the coordinator", system.getDistributedMember(), MembershipManagerHelper.getCoordinator(system));
       NetView view = MembershipManagerHelper.getMembershipManager(system).getView();
       com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("view after becoming coordinator is " + view);
-      assertNotSame("should not be the first member in the view ("+view+")", system.getDistributedMember(), view.get(0));
-      
+      assertNotSame("should not be the first member in the view (" + view + ")", system.getDistributedMember(), view.get(0));
+
       service = DistributedLockService.create("test service", system);
 
       // now force a non-elder VM to get a lock.  This will hang if the bug is not fixed 
@@ -287,7 +264,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     DistributedTestUtils.deleteLocatorStateFile(port2);
     final String host0 = NetworkUtils.getServerHostName(host);
     final String locators = host0 + "[" + port1 + "]," +
-                            host0 + "[" + port2 + "]";
+        host0 + "[" + port2 + "]";
     final Properties properties = new Properties();
     properties.put("mcast-port", "0");
     properties.put("locators", locators);
@@ -510,7 +487,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     DistributedTestUtils.deleteLocatorStateFile(port1, port2);
     final String host0 = NetworkUtils.getServerHostName(host);
     final String locators = host0 + "[" + port1 + "]," +
-                            host0 + "[" + port2 + "]";
+        host0 + "[" + port2 + "]";
     final Properties properties = new Properties();
     properties.put("mcast-port", "0");
     properties.put("locators", locators);
@@ -518,7 +495,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("disable-auto-reconnect", "true");
     properties.put("member-timeout", "2000");
     properties.put("log-level", LogWriterUtils.getDUnitLogLevel());
-//    properties.put("log-level", "fine");
+    //    properties.put("log-level", "fine");
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
 
     try {
@@ -533,8 +510,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
           File lf = new File("");
           try {
             Locator.startLocatorAndDS(port2, lf, properties);
-          }
-          catch (IOException ios) {
+          } catch (IOException ios) {
             com.gemstone.gemfire.test.dunit.Assert.fail("Unable to start locator2", ios);
           }
         }
@@ -584,7 +560,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
        * It will take 3 * (3 * member-timeout) milliseconds to detect the full
        * failure and eject the lost members from the view.
        */
-      
+
       com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("waiting for my distributed system to disconnect due to partition detection");
       WaitCriterion ev = new WaitCriterion() {
         public boolean done() {
@@ -644,7 +620,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     DistributedTestUtils.deleteLocatorStateFile(port1, port2);
     final String host0 = NetworkUtils.getServerHostName(host);
     final String locators = host0 + "[" + port1 + "],"
-          + host0 + "[" + port2 + "]";
+        + host0 + "[" + port2 + "]";
     final Properties properties = new Properties();
     properties.put("mcast-port", "0");
     properties.put("locators", locators);
@@ -666,8 +642,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
           try {
             Locator.startLocatorAndDS(port2, lf, properties);
             MembershipManagerHelper.inhibitForcedDisconnectLogging(true);
-          }
-          catch (IOException ios) {
+          } catch (IOException ios) {
             com.gemstone.gemfire.test.dunit.Assert.fail("Unable to start locator2", ios);
           }
         }
@@ -703,7 +678,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       vm1.invoke(crashSystem);
 
       Wait.pause(4 * 2000); // 4 x the member-timeout
-      
+
       assertTrue("Distributed system should not have disconnected",
           isSystemConnected());
 
@@ -730,8 +705,8 @@ public class LocatorDUnitTest extends DistributedTestCase {
 
       // the remaining non-locator member should now be the lead member
       assertEquals("This test sometimes fails.  If the log contains " +
-      		"'failed to collect all ACKs' it is a false failure.",
-      		mem2, vm2.invoke(() -> LocatorDUnitTest.getLeadMember()));
+              "'failed to collect all ACKs' it is a false failure.",
+          mem2, vm2.invoke(() -> LocatorDUnitTest.getLeadMember()));
 
       SerializableRunnable disconnect =
           new SerializableRunnable("Disconnect from " + locators) {
@@ -865,7 +840,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       vm2.invokeAsync(crashSystem);
 
       Wait.pause(1000); // 4 x the member-timeout
-      
+
       // request member removal for first peer from second peer.
       vm2.invoke(new SerializableRunnable("Request Member Removal") {
 
@@ -927,7 +902,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     DistributedTestUtils.deleteLocatorStateFile(port1, port2);
     final String host0 = NetworkUtils.getServerHostName(host);
     final String locators = host0 + "[" + port1 + "],"
-          + host0 + "[" + port2 + "]";
+        + host0 + "[" + port2 + "]";
     final Properties properties = new Properties();
     properties.put("mcast-port", "0");
     properties.put("locators", locators);
@@ -992,7 +967,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       DistributedMember mem2 = (DistributedMember) vm2.invoke(this.getClass(),
           "getDistributedMember", connectArgs);
 
-      DistributedMember loc1Mbr = (DistributedMember)locvm.invoke(() -> this.getLocatorDistributedMember());
+      DistributedMember loc1Mbr = (DistributedMember) locvm.invoke(() -> this.getLocatorDistributedMember());
 
       assertLeadMember(mem1, sys, 5000);
 
@@ -1015,7 +990,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       // locator notice the failure and continue to run
       vm1.invoke(disconnect);
       Wait.pause(10 * 1000);
-      
+
       assertTrue("Distributed system should not have disconnected",
           vm2.invoke(() -> LocatorDUnitTest.isSystemConnected()));
 
@@ -1041,7 +1016,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     int port =
-      AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     DistributedTestUtils.deleteLocatorStateFile(port1);
     String locators = NetworkUtils.getServerHostName(host) + "[" + port + "]";
     Properties props = new Properties();
@@ -1075,8 +1050,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       // if you see this fail, determine if unexpected exception is expected
       // if expected then add in a catch block for it above this catch
       com.gemstone.gemfire.test.dunit.Assert.fail("Failed with unexpected exception", ex);
-    }
-    finally {
+    } finally {
       if (oldValue == null) {
         System.getProperties().remove("p2p.joinTimeout");
       } else {
@@ -1106,7 +1080,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     VM vm2 = host.getVM(2);
 
     final int port =
-      AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     DistributedTestUtils.deleteLocatorStateFile(port1);
     final String locators = NetworkUtils.getServerHostName(host) + "[" + port + "]";
     final String uniqueName = getUniqueName();
@@ -1120,12 +1094,12 @@ public class LocatorDUnitTest extends DistributedTestCase {
           locProps.setProperty("member-timeout", "1000");
           locProps.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
 
-            Locator.startLocatorAndDS(port, logFile, locProps);
-          } catch (IOException ex) {
-            com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port, ex);
-          }
+          Locator.startLocatorAndDS(port, logFile, locProps);
+        } catch (IOException ex) {
+          com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port, ex);
         }
-      });
+      }
+    });
     try {
 
       SerializableRunnable connect =
@@ -1147,33 +1121,33 @@ public class LocatorDUnitTest extends DistributedTestCase {
       props.setProperty("locators", locators);
       props.setProperty("member-timeout", "1000");
 
-    system = (InternalDistributedSystem)DistributedSystem.connect(props);
-    
-    final DistributedMember coord = MembershipManagerHelper.getCoordinator(system);
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator before termination of locator is " + coord);
+      system = (InternalDistributedSystem) DistributedSystem.connect(props);
 
-    vm0.invoke(getStopLocatorRunnable());
-    
-    // now ensure that one of the remaining members became the coordinator
-    WaitCriterion ev = new WaitCriterion() {
-      public boolean done() {
-        return !coord.equals(MembershipManagerHelper.getCoordinator(system));
-      }
-      public String description() {
-        return "expected the coordinator to not be " + coord + " but it is " +
-          MembershipManagerHelper.getCoordinator(system);
+      final DistributedMember coord = MembershipManagerHelper.getCoordinator(system);
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator before termination of locator is " + coord);
+
+      vm0.invoke(getStopLocatorRunnable());
+
+      // now ensure that one of the remaining members became the coordinator
+      WaitCriterion ev = new WaitCriterion() {
+        public boolean done() {
+          return !coord.equals(MembershipManagerHelper.getCoordinator(system));
+        }
+
+        public String description() {
+          return "expected the coordinator to not be " + coord + " but it is " +
+              MembershipManagerHelper.getCoordinator(system);
+        }
+      };
+      Wait.waitForCriterion(ev, 15 * 1000, 200, false);
+      DistributedMember newCoord = MembershipManagerHelper.getCoordinator(system);
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator after shutdown of locator was " +
+          newCoord);
+      if (coord.equals(newCoord)) {
+        fail("another member should have become coordinator after the locator was stopped");
       }
-    };
-    Wait.waitForCriterion(ev, 15 * 1000, 200, false);
-    DistributedMember newCoord = MembershipManagerHelper.getCoordinator(system);
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator after shutdown of locator was " +
-        newCoord);
-    if (coord.equals(newCoord)) {
-      fail("another member should have become coordinator after the locator was stopped");
-    }
-      
 
-    system.disconnect();
+      system.disconnect();
 
       vm1.invoke(getDisconnectRunnable(locators));
       vm2.invoke(getDisconnectRunnable(locators));
@@ -1204,11 +1178,11 @@ public class LocatorDUnitTest extends DistributedTestCase {
     VM vm2 = host.getVM(2);
 
     final int port =
-      AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     DistributedTestUtils.deleteLocatorStateFile(port1);
     final String locators = NetworkUtils.getServerHostName(host) + "[" + port + "]";
-    
-    vm0.invoke(getStartSBLocatorRunnable(port, getUniqueName()+"1"));
+
+    vm0.invoke(getStartSBLocatorRunnable(port, getUniqueName() + "1"));
     try {
 
       final Properties props = new Properties();
@@ -1229,51 +1203,52 @@ public class LocatorDUnitTest extends DistributedTestCase {
 
       system = (InternalDistributedSystem) getSystem(props);
 
-    final DistributedMember coord = MembershipManagerHelper.getCoordinator(system);
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator before termination of locator is " + coord);
+      final DistributedMember coord = MembershipManagerHelper.getCoordinator(system);
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator before termination of locator is " + coord);
 
-    vm0.invoke(getStopLocatorRunnable());
-    
-    // now ensure that one of the remaining members became the coordinator
-    WaitCriterion ev = new WaitCriterion() {
-      public boolean done() {
-        return !coord.equals(MembershipManagerHelper.getCoordinator(system));
-      }
-      public String description() {
-        return "expected the coordinator to be " + coord + " but it is " +
-          MembershipManagerHelper.getCoordinator(system);
-      }
-    };
-    Wait.waitForCriterion(ev, 15000, 200, true);
-    DistributedMember newCoord = MembershipManagerHelper.getCoordinator(system);
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator after shutdown of locator was " +
-        newCoord);
-    if (newCoord == null || coord.equals(newCoord)) {
-      fail("another member should have become coordinator after the locator was stopped: "
-          + newCoord);
-    }
-      
-
-    // restart the locator to demonstrate reconnection & make disconnects faster
-    // it should also regain the role of coordinator, so we check to make sure
-    // that the coordinator has changed
-    vm0.invoke(getStartSBLocatorRunnable(port, getUniqueName()+"2"));
-    
-    final DistributedMember tempCoord = newCoord;
-    ev = new WaitCriterion() {
-      public boolean done() {
-        return !tempCoord.equals(MembershipManagerHelper.getCoordinator(system));
-      }
-      public String description() {
-        return null;
+      vm0.invoke(getStopLocatorRunnable());
+
+      // now ensure that one of the remaining members became the coordinator
+      WaitCriterion ev = new WaitCriterion() {
+        public boolean done() {
+          return !coord.equals(MembershipManagerHelper.getCoordinator(system));
+        }
+
+        public String description() {
+          return "expected the coordinator to be " + coord + " but it is " +
+              MembershipManagerHelper.getCoordinator(system);
+        }
+      };
+      Wait.waitForCriterion(ev, 15000, 200, true);
+      DistributedMember newCoord = MembershipManagerHelper.getCoordinator(system);
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("coordinator after shutdown of locator was " +
+          newCoord);
+      if (newCoord == null || coord.equals(newCoord)) {
+        fail("another member should have become coordinator after the locator was stopped: "
+            + newCoord);
       }
-    };
-    Wait.waitForCriterion(ev, 5000, 200, true);
-    
-    system.disconnect();
-    LogWriter bgexecLogger =
-      new LocalLogWriter(InternalLogWriter.ALL_LEVEL, System.out);
-    bgexecLogger.info(removeExpected);
+
+      // restart the locator to demonstrate reconnection & make disconnects faster
+      // it should also regain the role of coordinator, so we check to make sure
+      // that the coordinator has changed
+      vm0.invoke(getStartSBLocatorRunnable(port, getUniqueName() + "2"));
+
+      final DistributedMember tempCoord = newCoord;
+      ev = new WaitCriterion() {
+        public boolean done() {
+          return !tempCoord.equals(MembershipManagerHelper.getCoordinator(system));
+        }
+
+        public String description() {
+          return null;
+        }
+      };
+      Wait.waitForCriterion(ev, 5000, 200, true);
+
+      system.disconnect();
+      LogWriter bgexecLogger =
+          new LocalLogWriter(InternalLogWriter.ALL_LEVEL, System.out);
+      bgexecLogger.info(removeExpected);
 
       SerializableRunnable disconnect =
           new SerializableRunnable("Disconnect from " + locators) {
@@ -1298,13 +1273,16 @@ public class LocatorDUnitTest extends DistributedTestCase {
 
   }
 
-  
-  /** set a short locator refresh rate */
+  /**
+   * set a short locator refresh rate
+   */
   public static void setShortRefreshWait() {
     System.setProperty("p2p.gossipRefreshRate", "2000");
   }
-  
-  /** remove shortened locator refresh rate */
+
+  /**
+   * remove shortened locator refresh rate
+   */
   public static void resetRefreshWait() {
     System.getProperties().remove("p2p.gossipRefreshRate");
   }
@@ -1631,49 +1609,47 @@ public class LocatorDUnitTest extends DistributedTestCase {
     this.port2 = port2;
     DistributedTestUtils.deleteLocatorStateFile(port1, port2);
     final int mcastport = AvailablePort.getRandomAvailablePort(AvailablePort.MULTICAST);
-    
+
     final String host0 = NetworkUtils.getServerHostName(host);
     final String locators = host0 + "[" + port1 + "]," +
         host0 + "[" + port2 + "]";
     final String uniqueName = getUniqueName();
 
     vm0.invoke(new SerializableRunnable("Start locator on " + port1) {
-        public void run() {
-          File logFile = new File("");
-          try {
-            Properties props = new Properties();
-            props.setProperty("mcast-port", String.valueOf(mcastport));
-            props.setProperty("locators", locators);
-            props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
-            props.setProperty("mcast-ttl", "0");
-            props.setProperty("enable-network-partition-detection", "true");
-            props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
-
-            Locator.startLocatorAndDS(port1, logFile, null, props);
-          }
-          catch (IOException ex) {
-            com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port1, ex);
-          }
+      public void run() {
+        File logFile = new File("");
+        try {
+          Properties props = new Properties();
+          props.setProperty("mcast-port", String.valueOf(mcastport));
+          props.setProperty("locators", locators);
+          props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
+          props.setProperty("mcast-ttl", "0");
+          props.setProperty("enable-network-partition-detection", "true");
+          props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
+
+          Locator.startLocatorAndDS(port1, logFile, null, props);
+        } catch (IOException ex) {
+          com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port1, ex);
         }
-      });
+      }
+    });
     vm3.invoke(new SerializableRunnable("Start locator on " + port2) {
-        public void run() {
-          File logFile = new File("");
-          try {
-            Properties props = new Properties();
-            props.setProperty("mcast-port", String.valueOf(mcastport));
-            props.setProperty("locators", locators);
-            props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
-            props.setProperty("mcast-ttl", "0");
-            props.setProperty("enable-network-partition-detection", "true");
-            props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
-            Locator.startLocatorAndDS(port2, logFile, null, props);
-          }
-          catch (IOException ex) {
-            com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port2, ex);
-          }
+      public void run() {
+        File logFile = new File("");
+        try {
+          Properties props = new Properties();
+          props.setProperty("mcast-port", String.valueOf(mcastport));
+          props.setProperty("locators", locators);
+          props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
+          props.setProperty("mcast-ttl", "0");
+          props.setProperty("enable-network-partition-detection", "true");
+          props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
+          Locator.startLocatorAndDS(port2, logFile, null, props);
+        } catch (IOException ex) {
+          com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port2, ex);
         }
-      });
+      }
+    });
 
     SerializableRunnable connect =
         new SerializableRunnable("Connect to " + locators) {
@@ -1737,13 +1713,13 @@ public class LocatorDUnitTest extends DistributedTestCase {
     Host host = Host.getHost(0);
 
     port1 =
-      AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     DistributedTestUtils.deleteLocatorStateFile(port1);
     File logFile = new File("");
     Locator locator = Locator.startLocator(port1, logFile);
     try {
 
-    final String locators = NetworkUtils.getServerHostName(host) + "[" + port1 + "]";
+      final String locators = NetworkUtils.getServerHostName(host) + "[" + port1 + "]";
 
       Properties props = new Properties();
       props.setProperty("mcast-port", "0");
@@ -1838,43 +1814,41 @@ public class LocatorDUnitTest extends DistributedTestCase {
     Host host = Host.getHost(0);
     //VM vm = host.getVM(0);
     //VM vm1 = host.getVM(1);
-
-    port1 =
-        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    port1 = randomAvailableTCPPorts[0];
     File logFile1 = new File("");
     DistributedTestUtils.deleteLocatorStateFile(port1);
     Locator locator1 = Locator.startLocator(port1, logFile1);
 
     try {
 
-      int port2 =
-          AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+      int port2 = randomAvailableTCPPorts[1];
       File logFile2 = new File("");
 
-    DistributedTestUtils.deleteLocatorStateFile(port2);
-    
-    try {
-      Locator locator2 = Locator.startLocator(port2, logFile2);
-      fail("expected second locator start to fail.");
-    } catch (IllegalStateException expected) {
-    }
+      DistributedTestUtils.deleteLocatorStateFile(port2);
 
-    final String host0 = NetworkUtils.getServerHostName(host);
-    final String locators = host0 + "[" + port1 + "]," +
-                            host0 + "[" + port2 + "]";
+      try {
+        Locator locator2 = Locator.startLocator(port2, logFile2);
+        fail("expected second locator start to fail.");
+      } catch (IllegalStateException expected) {
+      }
 
-    SerializableRunnable connect =
-      new SerializableRunnable("Connect to " + locators) {
-          public void run() {
-            Properties props = new Properties();
-            props.setProperty("mcast-port", "0");
-            props.setProperty("locators", locators);
-            props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
-            DistributedSystem.connect(props);
-          }
-        };
-    connect.run();
-    //vm1.invoke(connect);
+      final String host0 = NetworkUtils.getServerHostName(host);
+      final String locators = host0 + "[" + port1 + "]," +
+          host0 + "[" + port2 + "]";
+
+      SerializableRunnable connect =
+          new SerializableRunnable("Connect to " + locators) {
+            public void run() {
+              Properties props = new Properties();
+              props.setProperty("mcast-port", "0");
+              props.setProperty("locators", locators);
+              props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
+              DistributedSystem.connect(props);
+            }
+          };
+      connect.run();
+      //vm1.invoke(connect);
 
       SerializableRunnable disconnect = getDisconnectRunnable(locators);
 
@@ -1895,7 +1869,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
   public void testRestartLocator() throws Exception {
     disconnectAllFromDS();
     port1 =
-      AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     DistributedTestUtils.deleteLocatorStateFile(port1);
     File logFile = new File("");
     File stateFile = new File("locator" + port1 + "state.dat");
@@ -1911,34 +1885,36 @@ public class LocatorDUnitTest extends DistributedTestCase {
     com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Starting locator");
     Locator locator = Locator.startLocatorAndDS(port1, logFile, p);
     try {
-    
-    SerializableRunnable connect =
-      new SerializableRunnable("Connect to locator on port " + port1) {
-          public void run() {
-            DistributedSystem.connect(p);
-          }
-        };
-    vm0.invoke(connect);
-    
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Stopping locator");
-    locator.stop();
 
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Starting locator");
-    locator = Locator.startLocatorAndDS(port1, logFile, p);
-    
-    vm0.invoke(new SerializableRunnable("disconnect") {
-      public void run() {
-        DistributedSystem.connect(p).disconnect();
-      }
-    });
-    
+      SerializableRunnable connect =
+          new SerializableRunnable("Connect to locator on port " + port1) {
+            public void run() {
+              DistributedSystem.connect(p);
+            }
+          };
+      vm0.invoke(connect);
+
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Stopping locator");
+      locator.stop();
+
+      com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Starting locator");
+      locator = Locator.startLocatorAndDS(port1, logFile, p);
+
+      vm0.invoke(new SerializableRunnable("disconnect") {
+        public void run() {
+          DistributedSystem.connect(p).disconnect();
+        }
+      });
+
     } finally {
       locator.stop();
     }
 
   }
-  
-  /** return the distributed member id for the ds on this vm */
+
+  /**
+   * return the distributed member id for the ds on this vm
+   */
   public static DistributedMember getDistributedMember(Properties props) {
     props.put("name", "vm_" + VM.getCurrentVMNum());
     DistributedSystem sys = DistributedSystem.connect(props);
@@ -1947,14 +1923,18 @@ public class LocatorDUnitTest extends DistributedTestCase {
     sys.getLogWriter().info("<ExpectedException action=add>com.gemstone.gemfire.ForcedDisconnectException</ExpectedException>");
     return DistributedSystem.connect(props).getDistributedMember();
   }
-  
-  /** find a running locator and return its distributed member id */
+
+  /**
+   * find a running locator and return its distributed member id
+   */
   public static DistributedMember getLocatorDistributedMember() {
     return (Locator.getLocators().iterator().next())
         .getDistributedSystem().getDistributedMember();
   }
-  
-  /** find the lead member and return its id */
+
+  /**
+   * find the lead member and return its id
+   */
   public static DistributedMember getLeadMember() {
     DistributedSystem sys = InternalDistributedSystem.getAnyInstance();
     return MembershipManagerHelper.getLeadMember(sys);
@@ -1986,8 +1966,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
           Locator.startLocatorAndDS(port, logFile, locProps);
         } catch (IOException ex) {
           com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port " + port, ex);
-        }
-        finally {
+        } finally {
           System.getProperties().remove(InternalLocator.LOCATORS_PREFERRED_AS_COORDINATORS);
           System.getProperties().remove("p2p.joinTimeout");
         }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
index 961e844..711be43 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
@@ -29,6 +29,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -355,8 +356,9 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestCase {
     Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps);
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 = getRandomAvailablePort(SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
 
     // Perform all the ops on the clients
     List opBlock = new ArrayList();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
index 4cc8155..7a4308f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
@@ -56,6 +56,7 @@ import com.gemstone.gemfire.cache.query.QueryService;
 import com.gemstone.gemfire.cache.query.SelectResults;
 import com.gemstone.gemfire.cache.query.Struct;
 import com.gemstone.gemfire.internal.AvailablePort.*;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.cache.AbstractRegionEntry;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
@@ -756,7 +757,8 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
         if (useThisVM) {
           SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION);
         } else {
-          clientVM.invoke(() -> SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION));
+          clientVM.invoke("SecurityTestUtils.createCacheClientWithDynamicRegion",
+              () -> SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION));
         }
       }
 
@@ -775,7 +777,8 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
       } else {
         byte ordinal = opCode.toOrdinal();
         int[] indices = currentOp.getIndices();
-        clientVM.invoke(() -> ClientAuthorizationTestCase.doOp( new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
+        clientVM.invoke("ClientAuthorizationTestCase.doOp",
+            () -> ClientAuthorizationTestCase.doOp( new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
       }
     }
   }
@@ -828,10 +831,11 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
     Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps);
 
     // Get ports for the servers
-    Keeper locator1PortKeeper = getRandomAvailablePortKeeper(SOCKET);
-    Keeper locator2PortKeeper = getRandomAvailablePortKeeper(SOCKET);
-    Keeper port1Keeper = getRandomAvailablePortKeeper(SOCKET);
-    Keeper port2Keeper = getRandomAvailablePortKeeper(SOCKET);
+    List<Keeper> randomAvailableTCPPortKeepers = AvailablePortHelper.getRandomAvailableTCPPortKeepers(4);
+    Keeper locator1PortKeeper = randomAvailableTCPPortKeepers.get(0);
+    Keeper locator2PortKeeper = randomAvailableTCPPortKeepers.get(1);
+    Keeper port1Keeper = randomAvailableTCPPortKeepers.get(2);
+    Keeper port2Keeper = randomAvailableTCPPortKeepers.get(3);
     int locator1Port = locator1PortKeeper.getPort();
     int locator2Port = locator2PortKeeper.getPort();
     int port1 = port1Keeper.getPort();
@@ -852,8 +856,8 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
           port1Keeper.release();
 
           // Start the first server and execute the operation block
-          server1.invoke(() -> ClientAuthorizationTestCase.createCacheServer(locator1Port, port1, serverProps, javaProps ));
-          server2.invoke(() -> closeCache());
+          server1.invoke("createCacheServer", () -> ClientAuthorizationTestCase.createCacheServer(locator1Port, port1, serverProps, javaProps ));
+          server2.invoke("closeCache", () -> closeCache());
 
           executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
 
@@ -862,8 +866,8 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
             locator2PortKeeper.release();
             port2Keeper.release();
 
-            server2.invoke(() -> ClientAuthorizationTestCase.createCacheServer(locator2Port, port2, serverProps, javaProps ));
-            server1.invoke(() -> closeCache());
+            server2.invoke("createCacheServer", () -> ClientAuthorizationTestCase.createCacheServer(locator2Port, port2, serverProps, javaProps ));
+            server1.invoke("closeCache", () -> closeCache());
 
             executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
           }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
index 61ff55a..dcc087b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
@@ -30,6 +30,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -86,8 +87,9 @@ public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTe
     Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 = getRandomAvailablePort(SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
 
     // Perform all the ops on the clients
     List opBlock = new ArrayList();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
index 56f5186..31184aa 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
@@ -326,8 +326,6 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
   @Ignore("disabled for some reason?")
   @Test
   public void testP2PViewChangeReject() throws Exception {
-    int locatorPort = getRandomAvailablePort(SOCKET);
-
     final Host host = Host.getHost(0);
     final VM peer2 = host.getVM(1);
     final VM peer3 = host.getVM(2);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
index 012ac33..4f121f3 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
@@ -17,15 +17,14 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
-import static com.gemstone.gemfire.internal.AvailablePort.*;
 import static com.gemstone.gemfire.security.SecurityTestUtils.*;
-import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -39,7 +38,6 @@ import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyAuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
 import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
 import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@@ -72,13 +70,8 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
     //this would be automatically registered in the static initializer, but with dunit
     //a previous test may have already loaded these classes. We clear the instantiators
     //between each test.
-    SerializableRunnable registerInstantiator = new SerializableRunnable() {
-      public void run() {
-        Instantiator.register(new MyInstantiator(), false);
-      }
-    };
-    server1.invoke(registerInstantiator);
-    server2.invoke(registerInstantiator);
+    server1.invoke("registerInstantiator", () -> Instantiator.register(new MyInstantiator(), false));
+    server2.invoke("registerInstantiator", () -> Instantiator.register(new MyInstantiator(), false));
   }
 
   @Category(FlakyTest.class) // GEODE-1228: random ports, BindException, uses Random
@@ -95,20 +88,21 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
     String authInit = credentialGenerator.getAuthInit();
     String authenticator = credentialGenerator.getAuthenticator();
 
-    getLogWriter().info("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
-    getLogWriter().info("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
-    getLogWriter().info("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
-    getLogWriter().info("testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
+    System.out.println("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
+    System.out.println("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
+    System.out.println("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
+    System.out.println("testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
 
     // Start servers with all required properties
     Properties serverProps = buildProperties(authenticator, extraProps, preAccessor, postAccessor);
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 =getRandomAvailablePort(SOCKET);
+    int[] portsList = AvailablePortHelper.getRandomAvailableTCPPortsForDUnitSite(2);
+    int port1 = portsList[0];
+    int port2 = portsList[1];
 
     // Perform all the ops on the clients
-    List opBlock = new ArrayList();
+    List<OperationWithAction> opBlock = new ArrayList();
     Random rnd = new Random();
 
     for (int opNum = 0; opNum < allOps.length; ++opNum) {
@@ -118,13 +112,13 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
         // End of current operation block; execute all the operations on the servers with failover
         if (opBlock.size() > 0) {
           // Start the first server and execute the operation block
-          server1.invoke(() -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
-          server2.invoke(() -> closeCache());
+          server1.invoke("createCacheServer", () -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
+          server2.invoke("closeCache", () -> closeCache());
           executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
           if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
             // Failover to the second server and run the block again
-            server2.invoke(() -> createCacheServer(getLocatorPort(), port2, serverProps, javaProps ));
-            server1.invoke(() -> closeCache());
+            server2.invoke("createCacheServer", () -> createCacheServer(getLocatorPort(), port2, serverProps, javaProps ));
+            server1.invoke("closeCache", () -> closeCache());
             executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
           }
           opBlock.clear();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
index e3e7886..41019f1 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Random;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -171,9 +172,10 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestC
     }
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 = getRandomAvailablePort(SOCKET);
-    int locatorPort = getRandomAvailablePort(SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(3);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
+    int locatorPort = randomAvailableTCPPorts[2];
 
     // Close down any running servers
     server1.invoke(() -> closeCache());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
index 963d2f0..03528fd 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -73,8 +74,9 @@ public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestCas
       Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
 
       // Get ports for the servers
-      int port1 = getRandomAvailablePort(SOCKET);
-      int port2 = getRandomAvailablePort(SOCKET);
+      int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+      int port1 = randomAvailableTCPPorts[0];
+      int port2 = randomAvailableTCPPorts[1];
 
       // Close down any running servers
       server1.invoke(() -> closeCache());
@@ -137,8 +139,9 @@ public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestCas
     Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 = getRandomAvailablePort(SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
 
     // Perform all the ops on the clients
     List opBlock = new ArrayList();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
index 3a97b7c..54cf8c2 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiUserDurableCQAuthzDUnitTest.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Random;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -192,9 +193,10 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestCas
     }
 
     // Get ports for the servers
-    int port1 = getRandomAvailablePort(SOCKET);
-    int port2 = getRandomAvailablePort(SOCKET);
-    int locatorPort = getRandomAvailablePort(SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
+    int locatorPort = randomAvailableTCPPorts[2];
 
     // Close down any running servers
     server1.invoke(() -> closeCache());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b0026b2/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANConfigurationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANConfigurationJUnitTest.java b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANConfigurationJUnitTest.java
index 84eb365..22c129e 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANConfigurationJUnitTest.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WANConfigurationJUnitTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
 
+import com.gemstone.gemfire.internal.AvailablePortHelper;
 import org.junit.After;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -223,8 +224,9 @@ public class WANConfigurationJUnitTest {
   @Test
   public void test_ValidateGatewayReceiverAttributes() {
     cache = new CacheFactory().set("mcast-port", "0").create();
-    int port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    int port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
     
     GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
     if(port1 < port2){
@@ -264,8 +266,9 @@ public class WANConfigurationJUnitTest {
   @Test
   public void test_ValidateGatewayReceiverStatus() {
     cache = new CacheFactory().set("mcast-port", "0").create();
-    int port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    int port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    int port1 = randomAvailableTCPPorts[0];
+    int port2 = randomAvailableTCPPorts[1];
     
     GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
     if(port1 < port2){


Mime
View raw message