geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [29/63] [abbrv] incubator-geode git commit: GEODE-1240: Changed the test to use Awaitility with a maximum timeout period. This might work better than the time sensitive conditionals that this test uses.
Date Wed, 04 May 2016 22:57:29 GMT
GEODE-1240: Changed the test to use Awaitility with a maximum timeout period. This might work better than the time sensitive conditionals that this test uses.


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

Branch: refs/heads/feature/GEODE-1276
Commit: 9fbf219c383ff499fa34c7cf9ad846ecdffcf3d4
Parents: ecbbf76
Author: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Authored: Thu Apr 28 04:14:00 2016 +1000
Committer: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Committed: Thu Apr 28 11:32:48 2016 +1000

----------------------------------------------------------------------
 .../cache30/ClientMembershipDUnitTest.java      | 799 +++++++++----------
 1 file changed, 398 insertions(+), 401 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9fbf219c/geode-core/src/test/java/com/gemstone/gemfire/cache30/ClientMembershipDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/ClientMembershipDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/ClientMembershipDUnitTest.java
index 46e91b0..9036e5e 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/ClientMembershipDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/ClientMembershipDUnitTest.java
@@ -16,24 +16,7 @@
  */
 package com.gemstone.gemfire.cache30;
 
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.junit.experimental.categories.Category;
-
 import com.gemstone.gemfire.InternalGemFireException;
-import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.Statistics;
 import com.gemstone.gemfire.StatisticsType;
 import com.gemstone.gemfire.cache.AttributesFactory;
@@ -48,27 +31,23 @@ import com.gemstone.gemfire.distributed.DistributedSystem;
 import com.gemstone.gemfire.distributed.DurableClientAttributes;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.internal.SocketCreator;
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.tier.InternalClientMembership;
 import com.gemstone.gemfire.internal.cache.tier.sockets.AcceptorImpl;
 import com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection;
-import com.gemstone.gemfire.internal.logging.LocalLogWriter;
-import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.management.membership.ClientMembership;
 import com.gemstone.gemfire.management.membership.ClientMembershipEvent;
 import com.gemstone.gemfire.management.membership.ClientMembershipListener;
-import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
-import com.gemstone.gemfire.test.dunit.Invoke;
-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.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
-import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.*;
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import com.jayway.awaitility.Awaitility;
+import org.junit.experimental.categories.Category;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Tests the ClientMembership API including ClientMembershipListener.
@@ -79,13 +58,13 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
 
   protected static final boolean CLIENT = true;
   protected static final boolean SERVER = false;
-  
+
   protected static final int JOINED = 0;
   protected static final int LEFT = 1;
   protected static final int CRASHED = 2;
-  
+
   private static Properties properties;
-    
+
   public ClientMembershipDUnitTest(String name) {
     super(name);
   }
@@ -94,16 +73,17 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
   public final void postTearDownCacheTestCase() throws Exception {
     Invoke.invokeInEveryVM((() -> cleanup()));
   }
-  
+
   public static void cleanup() {
     properties = null;
     InternalClientMembership.unregisterAllListeners();
   }
-  
+
   private void waitForAcceptsInProgressToBe(final int target)
-    throws Exception {
+      throws Exception {
     WaitCriterion ev = new WaitCriterion() {
       String excuse;
+
       public boolean done() {
         int actual = getAcceptsInProgress();
         if (actual == getAcceptsInProgress()) {
@@ -112,13 +92,22 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
         excuse = "accepts in progress (" + actual + ") never became " + target;
         return false;
       }
+
       public String description() {
         return excuse;
       }
     };
-    Wait.waitForCriterion(ev, 60 * 1000, 200, true);
+    Awaitility.await().pollInterval(200, TimeUnit.MILLISECONDS).atMost(60, TimeUnit.SECONDS)
+        .until(() -> {
+          int actual = getAcceptsInProgress();
+          if (actual == getAcceptsInProgress()) {
+            return true;
+          }
+          return false;
+        });
+//    Wait.waitForCriterion(ev, 60 * 1000, 200, true);
   }
-  
+
   protected int getAcceptsInProgress() {
     StatisticsType st = InternalDistributedSystem.getAnyInstance().findType("CacheServerStats");
     Statistics[] s = InternalDistributedSystem.getAnyInstance().findStatisticsByType(st);
@@ -127,8 +116,9 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
 
   protected static Socket meanSocket;
 
-  /** test that a server times out waiting for a handshake that
-      never arrives. 
+  /**
+   * test that a server times out waiting for a handshake that
+   * never arrives.
    */
   public void testConnectionTimeout() throws Exception {
     IgnoredException.addIgnoredException("failed accepting client connection");
@@ -137,101 +127,97 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     final VM vm0 = host.getVM(0);
     System.setProperty(AcceptorImpl.ACCEPT_TIMEOUT_PROPERTY_NAME, "1000");
     try {
-    final int port = startBridgeServer(0);
-//    AsyncInvocation ai = null;
-    try {
-      assertTrue(port != 0);
-      SerializableRunnable createMeanSocket = new CacheSerializableRunnable("Connect to server with socket") {
-        public void run2() throws CacheException {
-          getCache(); // create a cache so we have stats
-          System.out.println("connecting to cache server with socket");
-          try {
-            InetAddress addr = InetAddress.getByName(hostName);
-            meanSocket = new Socket(addr, port);
+      final int port = startBridgeServer(0);
+      //    AsyncInvocation ai = null;
+      try {
+        assertTrue(port != 0);
+        SerializableRunnable createMeanSocket = new CacheSerializableRunnable("Connect to server with socket") {
+          public void run2() throws CacheException {
+            getCache(); // create a cache so we have stats
+            System.out.println("connecting to cache server with socket");
+            try {
+              InetAddress addr = InetAddress.getByName(hostName);
+              meanSocket = new Socket(addr, port);
+            } catch (Exception e) {
+              throw new RuntimeException("Test failed to connect or was interrupted", e);
+            }
           }
-          catch (Exception e) {
-            throw new RuntimeException("Test failed to connect or was interrupted", e);
+        };
+        SerializableRunnable closeMeanSocket = new CacheSerializableRunnable("close mean socket") {
+          public void run2() throws CacheException {
+            System.out.println("closing mean socket");
+            try {
+              meanSocket.close();
+            } catch (IOException ignore) {
+            }
           }
-        }
-      };
-      SerializableRunnable closeMeanSocket = new CacheSerializableRunnable("close mean socket") {
-        public void run2() throws CacheException {
+        };
+
+        assertEquals(0, getAcceptsInProgress());
+
+        System.out.println("creating mean socket");
+        vm0.invoke(createMeanSocket);
+        try {
+          System.out.println("waiting to see it connect on server");
+          waitForAcceptsInProgressToBe(1);
+        } finally {
           System.out.println("closing mean socket");
-          try {
-            meanSocket.close();
-          }
-          catch (IOException ignore) {
-          }
+          vm0.invoke(closeMeanSocket);
         }
-      };
+        System.out.println("waiting to see accept to go away on server");
+        waitForAcceptsInProgressToBe(0);
 
-      assertEquals(0, getAcceptsInProgress());
-      
-      System.out.println("creating mean socket");
-      vm0.invoke(createMeanSocket);
-      try {
-        System.out.println("waiting to see it connect on server");
-        waitForAcceptsInProgressToBe(1);
-      } finally {
-        System.out.println("closing mean socket");
-        vm0.invoke(closeMeanSocket);
-      }
-      System.out.println("waiting to see accept to go away on server");
-      waitForAcceptsInProgressToBe(0);
+        // now try it without a close. Server should timeout the mean connect
+        System.out.println("creating mean socket 2");
+        vm0.invoke(createMeanSocket);
+        try {
+          System.out.println("waiting to see it connect on server 2");
+          waitForAcceptsInProgressToBe(1);
+          System.out.println("waiting to see accept to go away on server without us closing");
+          waitForAcceptsInProgressToBe(0);
+        } finally {
+          System.out.println("closing mean socket 2");
+          vm0.invoke(closeMeanSocket);
+        }
 
-      // now try it without a close. Server should timeout the mean connect
-      System.out.println("creating mean socket 2");
-      vm0.invoke(createMeanSocket);
-      try {
-        System.out.println("waiting to see it connect on server 2");
-        waitForAcceptsInProgressToBe(1);
-        System.out.println("waiting to see accept to go away on server without us closing");
-        waitForAcceptsInProgressToBe(0);
+        //       SerializableRunnable denialOfService = new CacheSerializableRunnable("Do lots of connects") {
+        //         public void run2() throws CacheException {
+        //           int connectionCount = 0;
+        //           ArrayList al = new ArrayList(60000);
+        //           try {
+        //             InetAddress addr = InetAddress.getLocalHost();
+        //             for (;;) {
+        //               Socket s = new Socket(addr, port);
+        //               al.add(s);
+        //               connectionCount++;
+        //               getLogWriter().info("connected # " + connectionCount + " s=" + s);
+        // //               try {
+        // //                 s.close();
+        // //               } catch (IOException ignore) {}
+        //             }
+        //           }
+        //           catch (Exception e) {
+        //             getLogWriter().info("connected # " + connectionCount
+        //                                 + " stopped because of exception " + e);
+        //             Iterator it = al.iterator();
+        //             while (it.hasNext()) {
+        //               Socket s = (Socket)it.next();
+        //               try {
+        //                 s.close();
+        //               } catch (IOException ignore) {}
+        //             }
+        //           }
+        //         }
+        //       };
+        //       // now pretend to do a denial of service attack by doing a bunch of connects
+        //       // really fast and see what that does to the server's fds.
+        //       getLogWriter().info("doing denial of service attach");
+        //       vm0.invoke(denialOfService);
+        //       // @todo darrel: check fd limit?
       } finally {
-        System.out.println("closing mean socket 2");
-        vm0.invoke(closeMeanSocket);
+        stopBridgeServers(getCache());
       }
-
-//       SerializableRunnable denialOfService = new CacheSerializableRunnable("Do lots of connects") {
-//         public void run2() throws CacheException {
-//           int connectionCount = 0;
-//           ArrayList al = new ArrayList(60000);
-//           try {
-//             InetAddress addr = InetAddress.getLocalHost();
-//             for (;;) {
-//               Socket s = new Socket(addr, port);
-//               al.add(s);
-//               connectionCount++;
-//               getLogWriter().info("connected # " + connectionCount + " s=" + s);
-// //               try {
-// //                 s.close();
-// //               } catch (IOException ignore) {}
-//             }
-//           }
-//           catch (Exception e) {
-//             getLogWriter().info("connected # " + connectionCount
-//                                 + " stopped because of exception " + e);
-//             Iterator it = al.iterator();
-//             while (it.hasNext()) {
-//               Socket s = (Socket)it.next();
-//               try {
-//                 s.close();
-//               } catch (IOException ignore) {}
-//             }
-//           }
-//         }
-//       };
-//       // now pretend to do a denial of service attack by doing a bunch of connects
-//       // really fast and see what that does to the server's fds.
-//       getLogWriter().info("doing denial of service attach");
-//       vm0.invoke(denialOfService);
-//       // @todo darrel: check fd limit?
-    }
-    finally {
-      stopBridgeServers(getCache());
-    }
-    }
-    finally {
+    } finally {
       System.getProperties().remove(AcceptorImpl.ACCEPT_TIMEOUT_PROPERTY_NAME);
     }
   }
@@ -241,12 +227,11 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     InternalClientMembership.setForceSynchronous(true);
     try {
       doTestBasicEvents();
-    }
-    finally {
+    } finally {
       InternalClientMembership.setForceSynchronous(false);
     }
   }
-  
+
   /**
    * Tests event notification methods on ClientMembership.
    */
@@ -254,13 +239,13 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     getSystem();
     doTestBasicEvents();
   }
-  
+
   public void doTestBasicEvents() throws Exception {
     final boolean[] fired = new boolean[3];
     final DistributedMember[] member = new DistributedMember[3];
     final String[] memberId = new String[3];
     final boolean[] isClient = new boolean[3];
-    
+
     ClientMembershipListener listener = new ClientMembershipListener() {
       public synchronized void memberJoined(ClientMembershipEvent event) {
         fired[JOINED] = true;
@@ -269,6 +254,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
         isClient[JOINED] = event.isClient();
         notify();
       }
+
       public synchronized void memberLeft(ClientMembershipEvent event) {
         fired[LEFT] = true;
         member[LEFT] = event.getMember();
@@ -276,6 +262,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
         isClient[LEFT] = event.isClient();
         notify();
       }
+
       public synchronized void memberCrashed(ClientMembershipEvent event) {
         fired[CRASHED] = true;
         member[CRASHED] = event.getMember();
@@ -285,11 +272,11 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       }
     };
     ClientMembership.registerClientMembershipListener(listener);
-    
+
     // test JOIN for server
     DistributedMember serverJoined = new TestDistributedMember("serverJoined");
     InternalClientMembership.notifyJoined(serverJoined, SERVER);
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[JOINED]) {
         listener.wait(2000);
       }
@@ -309,7 +296,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     // test JOIN for client
     DistributedMember clientJoined = new TestDistributedMember("clientJoined");
     InternalClientMembership.notifyJoined(clientJoined, CLIENT);
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[JOINED]) {
         listener.wait(2000);
       }
@@ -329,7 +316,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     // test LEFT for server
     DistributedMember serverLeft = new TestDistributedMember("serverLeft");
     InternalClientMembership.notifyLeft(serverLeft, SERVER);
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[LEFT]) {
         listener.wait(2000);
       }
@@ -349,7 +336,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     // test LEFT for client
     DistributedMember clientLeft = new TestDistributedMember("clientLeft");
     InternalClientMembership.notifyLeft(clientLeft, CLIENT);
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[LEFT]) {
         listener.wait(2000);
       }
@@ -369,7 +356,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     // test CRASHED for server
     DistributedMember serverCrashed = new TestDistributedMember("serverCrashed");
     InternalClientMembership.notifyCrashed(serverCrashed, SERVER);
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[CRASHED]) {
         listener.wait(2000);
       }
@@ -389,7 +376,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     // test CRASHED for client
     DistributedMember clientCrashed = new TestDistributedMember("clientCrashed");
     InternalClientMembership.notifyCrashed(clientCrashed, CLIENT);
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[CRASHED]) {
         listener.wait(2000);
       }
@@ -406,15 +393,15 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertTrue(isClient[CRASHED]);
     resetArraysForTesting(fired, member, memberId, isClient);
   }
-  
+
   /**
    * Resets all elements of arrays used for listener testing. Boolean values
    * are reset to false. String values are reset to null.
    */
-  private void resetArraysForTesting(boolean[] fired, 
-                                     DistributedMember[] member,
-                                     String[] memberId, 
-                                     boolean[] isClient) {
+  private void resetArraysForTesting(boolean[] fired,
+      DistributedMember[] member,
+      String[] memberId,
+      boolean[] isClient) {
     for (int i = 0; i < fired.length; i++) {
       fired[i] = false;
       member[i] = null;
@@ -422,7 +409,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       isClient[i] = false;
     }
   }
-  
+
   /**
    * Tests unregisterClientMembershipListener to ensure that no further events
    * are delivered to unregistered listeners.
@@ -432,7 +419,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     final DistributedMember[] member = new DistributedMember[1];
     final String[] memberId = new String[1];
     final boolean[] isClient = new boolean[1];
-    
+
     getSystem();
 
     ClientMembershipListener listener = new ClientMembershipListener() {
@@ -443,17 +430,19 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
         isClient[0] = event.isClient();
         notify();
       }
+
       public void memberLeft(ClientMembershipEvent event) {
       }
+
       public void memberCrashed(ClientMembershipEvent event) {
       }
     };
     ClientMembership.registerClientMembershipListener(listener);
-    
+
     // fire event to make sure listener is registered
     DistributedMember clientJoined = new TestDistributedMember("clientJoined");
     InternalClientMembership.notifyJoined(clientJoined, true);
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[0]) {
         listener.wait(2000);
       }
@@ -471,7 +460,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     // unregister and verify listener is not notified
     ClientMembership.unregisterClientMembershipListener(listener);
     InternalClientMembership.notifyJoined(clientJoined, true);
-    synchronized(listener) {
+    synchronized (listener) {
       listener.wait(20);
     }
     assertFalse(fired[0]);
@@ -479,14 +468,14 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertNull(memberId[0]);
     assertFalse(isClient[0]);
   }
-  
+
   public void testMultipleListeners() throws Exception {
     final int NUM_LISTENERS = 4;
     final boolean[] fired = new boolean[NUM_LISTENERS];
     final DistributedMember[] member = new DistributedMember[NUM_LISTENERS];
     final String[] memberId = new String[NUM_LISTENERS];
     final boolean[] isClient = new boolean[NUM_LISTENERS];
-    
+
     getSystem();
 
     final ClientMembershipListener[] listeners = new ClientMembershipListener[NUM_LISTENERS];
@@ -504,17 +493,19 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
           isClient[whichListener] = event.isClient();
           notify();
         }
+
         public void memberLeft(ClientMembershipEvent event) {
         }
+
         public void memberCrashed(ClientMembershipEvent event) {
         }
       };
     }
-    
+
     final DistributedMember clientJoined = new TestDistributedMember("clientJoined");
     InternalClientMembership.notifyJoined(clientJoined, true);
     for (int i = 0; i < NUM_LISTENERS; i++) {
-      synchronized(listeners[i]) {
+      synchronized (listeners[i]) {
         listeners[i].wait(20);
       }
       assertFalse(fired[i]);
@@ -522,17 +513,17 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       assertNull(memberId[i]);
       assertFalse(isClient[i]);
     }
-    
+
     // attempt to register same listener twice... 2nd reg should be ignored
     // failure would cause an assertion failure in memberJoined impl
     ClientMembership.registerClientMembershipListener(listeners[0]);
     ClientMembership.registerClientMembershipListener(listeners[0]);
-    
-    ClientMembershipListener[] registeredListeners = 
-      ClientMembership.getClientMembershipListeners();
+
+    ClientMembershipListener[] registeredListeners =
+        ClientMembership.getClientMembershipListeners();
     assertEquals(1, registeredListeners.length);
     assertEquals(listeners[0], registeredListeners[0]);
-    
+
     ClientMembership.registerClientMembershipListener(listeners[1]);
     registeredListeners = ClientMembership.getClientMembershipListeners();
     assertEquals(2, registeredListeners.length);
@@ -540,7 +531,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertEquals(listeners[1], registeredListeners[1]);
 
     InternalClientMembership.notifyJoined(clientJoined, true);
-    synchronized(listeners[1]) {
+    synchronized (listeners[1]) {
       if (!fired[1]) {
         listeners[1].wait(2000);
       }
@@ -559,14 +550,14 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       }
     }
     resetArraysForTesting(fired, member, memberId, isClient);
-        
+
     ClientMembership.unregisterClientMembershipListener(listeners[0]);
     registeredListeners = ClientMembership.getClientMembershipListeners();
     assertEquals(1, registeredListeners.length);
     assertEquals(listeners[1], registeredListeners[0]);
-    
+
     InternalClientMembership.notifyJoined(clientJoined, true);
-    synchronized(listeners[1]) {
+    synchronized (listeners[1]) {
       if (!fired[1]) {
         listeners[1].wait(2000);
       }
@@ -595,7 +586,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertEquals(listeners[3], registeredListeners[2]);
 
     InternalClientMembership.notifyJoined(clientJoined, true);
-    synchronized(listeners[3]) {
+    synchronized (listeners[3]) {
       if (!fired[3]) {
         listeners[3].wait(2000);
       }
@@ -614,7 +605,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       }
     }
     resetArraysForTesting(fired, member, memberId, isClient);
-    
+
     ClientMembership.registerClientMembershipListener(listeners[0]);
     registeredListeners = ClientMembership.getClientMembershipListeners();
     assertEquals(4, registeredListeners.length);
@@ -624,7 +615,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertEquals(listeners[0], registeredListeners[3]);
 
     InternalClientMembership.notifyJoined(clientJoined, true);
-    synchronized(listeners[0]) {
+    synchronized (listeners[0]) {
       if (!fired[0]) {
         listeners[0].wait(2000);
       }
@@ -636,16 +627,16 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       assertTrue(isClient[i]);
     }
     resetArraysForTesting(fired, member, memberId, isClient);
-    
+
     ClientMembership.unregisterClientMembershipListener(listeners[3]);
     registeredListeners = ClientMembership.getClientMembershipListeners();
     assertEquals(3, registeredListeners.length);
     assertEquals(listeners[1], registeredListeners[0]);
     assertEquals(listeners[2], registeredListeners[1]);
     assertEquals(listeners[0], registeredListeners[2]);
-    
+
     InternalClientMembership.notifyJoined(clientJoined, true);
-    synchronized(listeners[0]) {
+    synchronized (listeners[0]) {
       if (!fired[0]) {
         listeners[0].wait(2000);
       }
@@ -670,9 +661,9 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertEquals(2, registeredListeners.length);
     assertEquals(listeners[1], registeredListeners[0]);
     assertEquals(listeners[0], registeredListeners[1]);
-    
+
     InternalClientMembership.notifyJoined(clientJoined, true);
-    synchronized(listeners[0]) {
+    synchronized (listeners[0]) {
       if (!fired[0]) {
         listeners[0].wait(2000);
       }
@@ -696,10 +687,10 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     ClientMembership.unregisterClientMembershipListener(listeners[0]);
     registeredListeners = ClientMembership.getClientMembershipListeners();
     assertEquals(0, registeredListeners.length);
-    
+
     InternalClientMembership.notifyJoined(clientJoined, true);
     for (int i = 0; i < NUM_LISTENERS; i++) {
-      synchronized(listeners[i]) {
+      synchronized (listeners[i]) {
         listeners[i].wait(20);
       }
       assertFalse(fired[i]);
@@ -708,14 +699,14 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       assertFalse(isClient[i]);
     }
     resetArraysForTesting(fired, member, memberId, isClient);
-    
+
     ClientMembership.registerClientMembershipListener(listeners[1]);
     registeredListeners = ClientMembership.getClientMembershipListeners();
     assertEquals(1, registeredListeners.length);
     assertEquals(listeners[1], registeredListeners[0]);
-    
+
     InternalClientMembership.notifyJoined(clientJoined, true);
-    synchronized(listeners[1]) {
+    synchronized (listeners[1]) {
       if (!fired[1]) {
         listeners[1].wait(2000);
       }
@@ -734,11 +725,13 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       }
     }
   }
- 
+
   protected static int testClientMembershipEventsInClient_port;
+
   private static int getTestClientMembershipEventsInClient_port() {
     return testClientMembershipEventsInClient_port;
   }
+
   /**
    * Tests notification of events in client process. Bridge clients detect
    * server joins when the client connects to the server. If the server
@@ -752,28 +745,27 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     final DistributedMember[] member = new DistributedMember[3];
     final String[] memberId = new String[3];
     final boolean[] isClient = new boolean[3];
-    
+
     // create and register ClientMembershipListener in controller vm...
     ClientMembershipListener listener = new ClientMembershipListener() {
-      public synchronized void memberJoined(ClientMembershipEvent event) {
+      public void memberJoined(ClientMembershipEvent event) {
         System.out.println("[testClientMembershipEventsInClient] memberJoined: " + event);
         fired[JOINED] = true;
         member[JOINED] = event.getMember();
         memberId[JOINED] = event.getMemberId();
         isClient[JOINED] = event.isClient();
-        notifyAll();
       }
-      public synchronized void memberLeft(ClientMembershipEvent event) {
+
+      public void memberLeft(ClientMembershipEvent event) {
         System.out.println("[testClientMembershipEventsInClient] memberLeft: " + event);
-//        fail("Please update testClientMembershipEventsInClient to handle memberLeft for BridgeServer.");
       }
-      public synchronized void memberCrashed(ClientMembershipEvent event) {
+
+      public void memberCrashed(ClientMembershipEvent event) {
         System.out.println("[testClientMembershipEventsInClient] memberCrashed: " + event);
         fired[CRASHED] = true;
         member[CRASHED] = event.getMember();
         memberId[CRASHED] = event.getMemberId();
         isClient[CRASHED] = event.isClient();
-        notifyAll();
       }
     };
     ClientMembership.registerClientMembershipListener(listener);
@@ -783,31 +775,29 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     final int[] ports = new int[1];
 
     // create BridgeServer in vm0...
-    vm0.invoke(new CacheSerializableRunnable("Create BridgeServer") {
-      public void run2() throws CacheException {
-        try {
-          System.out.println("[testClientMembershipEventsInClient] Create BridgeServer");
-          getSystem();
-          AttributesFactory factory = new AttributesFactory();
-          factory.setScope(Scope.LOCAL);
-          Region region = createRegion(name, factory.create());
-          assertNotNull(region);
-          assertNotNull(getRootRegion().getSubregion(name));
-          testClientMembershipEventsInClient_port = startBridgeServer(0);
-        }
-        catch(IOException e) {
-          getSystem().getLogWriter().fine(new Exception(e));
-          fail("Failed to start CacheServer on VM1: " + e.getMessage());
-        }
+    vm0.invoke("create Bridge Server", () -> {
+      try {
+        System.out.println("[testClientMembershipEventsInClient] Create BridgeServer");
+        getSystem();
+        AttributesFactory factory = new AttributesFactory();
+        factory.setScope(Scope.LOCAL);
+        Region region = createRegion(name, factory.create());
+        assertNotNull(region);
+        assertNotNull(getRootRegion().getSubregion(name));
+        testClientMembershipEventsInClient_port = startBridgeServer(0);
+      } catch (IOException e) {
+        getSystem().getLogWriter().fine(new Exception(e));
+        fail("Failed to start CacheServer: " + e.getMessage());
       }
     });
-    
+
     // gather details for later creation of ConnectionPool...
     ports[0] = vm0.invoke("getTestClientMembershipEventsInClient_port",
         () -> ClientMembershipDUnitTest.getTestClientMembershipEventsInClient_port());
     assertTrue(ports[0] != 0);
 
-    DistributedMember serverMember = (DistributedMember) vm0.invoke("get distributed member", () -> ClientMembershipDUnitTest.getDistributedMember());
+    DistributedMember serverMember = (DistributedMember) vm0.invoke("get distributed member", () ->
+        ClientMembershipDUnitTest.getDistributedMember());
 
     String serverMemberId = serverMember.toString();
 
@@ -827,17 +817,20 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertNull(member[CRASHED]);
     assertNull(memberId[CRASHED]);
     assertFalse(isClient[CRASHED]);
-    
+
     // sanity check...
     System.out.println("[testClientMembershipEventsInClient] sanity check");
     DistributedMember test = new TestDistributedMember("test");
     InternalClientMembership.notifyJoined(test, SERVER);
-    synchronized(listener) {
-      if (!fired[JOINED] && !fired[CRASHED]) {
-        listener.wait(2000);
-      }
-    }
-    
+
+    Awaitility.await().pollInterval(50,TimeUnit.MILLISECONDS).timeout(300,TimeUnit.SECONDS)
+        .pollDelay(50,TimeUnit.MILLISECONDS).until(()->fired[JOINED] || fired[CRASHED]);
+//    synchronized (listener) {
+//      if (!fired[JOINED] && !fired[CRASHED]) {
+//        listener.wait(2000);
+//      }
+//    }
+
     assertTrue(fired[JOINED]);
     assertEquals(test, member[JOINED]);
     assertEquals(test.getId(), memberId[JOINED]);
@@ -851,14 +844,14 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertNull(memberId[CRASHED]);
     assertFalse(isClient[CRASHED]);
     resetArraysForTesting(fired, member, memberId, isClient);
-    
+
     // create bridge client in controller vm...
     System.out.println("[testClientMembershipEventsInClient] create bridge client");
     Properties config = new Properties();
     config.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
     config.setProperty(DistributionConfig.LOCATORS_NAME, "");
     getSystem(config);
-    
+
     try {
       getCache();
       AttributesFactory factory = new AttributesFactory();
@@ -866,26 +859,28 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       ClientServerTestCase.configureConnectionPool(factory, NetworkUtils.getServerHostName(Host.getHost(0)), ports, true, -1, -1, null);
       createRegion(name, factory.create());
       assertNotNull(getRootRegion().getSubregion(name));
-    }
-    catch (CacheException ex) {
+    } catch (CacheException ex) {
       Assert.fail("While creating Region on Edge", ex);
     }
-    synchronized(listener) {
-      if (!fired[JOINED] && !fired[CRASHED]) {
-        listener.wait(60 * 1000);
-      }
-    }
-    
+
+    Awaitility.await().pollInterval(50,TimeUnit.MILLISECONDS).timeout(300,TimeUnit.SECONDS)
+        .pollDelay(50,TimeUnit.MILLISECONDS).until(()->fired[JOINED] || fired[CRASHED]);
+//    synchronized(listener) {
+//      if (!fired[JOINED] && !fired[CRASHED]) {
+//        listener.wait(60 * 1000);
+//      }
+//    }
+
     System.out.println("[testClientMembershipEventsInClient] assert client detected server join");
-    
+
     // first check the getCurrentServers() result
-    ClientCache clientCache = (ClientCache)getCache();
+    ClientCache clientCache = (ClientCache) getCache();
     Set<InetSocketAddress> servers = clientCache.getCurrentServers();
     assertTrue(!servers.isEmpty());
     InetSocketAddress serverAddr = servers.iterator().next();
     InetSocketAddress expectedAddr = new InetSocketAddress(serverMember.getHost(), ports[0]);
     assertEquals(expectedAddr, serverAddr);
-    
+
     // now check listener results
     assertTrue(fired[JOINED]);
     assertNotNull(member[JOINED]);
@@ -903,18 +898,17 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertFalse(isClient[CRASHED]);
     resetArraysForTesting(fired, member, memberId, isClient);
 
-    vm0.invoke(new SerializableRunnable("Stop BridgeServer") {
-      public void run() {
-        System.out.println("[testClientMembershipEventsInClient] Stop BridgeServer");
-        stopBridgeServers(getCache());
-      }
-    });
-    synchronized(listener) {
-      if (!fired[JOINED] && !fired[CRASHED]) {
-        listener.wait(60 * 1000);
-      }
-    }
-    
+    vm0.invoke("Stop BridgeServer", () -> stopBridgeServers(getCache()));
+
+//    synchronized (listener) {
+//      if (!fired[JOINED] && !fired[CRASHED]) {
+//        listener.wait(60 * 1000);
+//      }
+//    }
+
+    Awaitility.await().pollInterval(50,TimeUnit.MILLISECONDS).timeout(300,TimeUnit.SECONDS)
+        .pollDelay(50,TimeUnit.MILLISECONDS).until(()->fired[JOINED] || fired[CRASHED]);
+
     System.out.println("[testClientMembershipEventsInClient] assert client detected server departure");
     assertFalse(fired[JOINED]);
     assertNull(member[JOINED]);
@@ -931,26 +925,26 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertEquals(serverMemberId, memberId[CRASHED]);
     assertFalse(isClient[CRASHED]);
     resetArraysForTesting(fired, member, memberId, isClient);
-    
+
     //now test that we redisover the bridge server
-    vm0.invoke(new CacheSerializableRunnable("Recreate BridgeServer") {
-      public void run2() throws CacheException {
-        try {
-          System.out.println("[testClientMembershipEventsInClient] restarting BridgeServer");
-          startBridgeServer(ports[0]);
-        }
-        catch(IOException e) {
-          getSystem().getLogWriter().fine(new Exception(e));
-          fail("Failed to start CacheServer on VM1: " + e.getMessage());
-        }
+    vm0.invoke("Recreate BridgeServer", () -> {
+      try {
+        System.out.println("[testClientMembershipEventsInClient] restarting BridgeServer");
+        startBridgeServer(ports[0]);
+      } catch (IOException e) {
+        getSystem().getLogWriter().fine(new Exception(e));
+        fail("Failed to start CacheServer on VM1: " + e.getMessage());
       }
     });
-    synchronized(listener) {
-      if (!fired[JOINED] && !fired[CRASHED]) {
-        listener.wait(60 * 1000);
-      }
-    }
-    
+//    synchronized (listener) {
+//      if (!fired[JOINED] && !fired[CRASHED]) {
+//        listener.wait(60 * 1000);
+//      }
+//    }
+
+    Awaitility.await().pollInterval(50,TimeUnit.MILLISECONDS).timeout(300,TimeUnit.SECONDS)
+        .pollDelay(50,TimeUnit.MILLISECONDS).until(()->fired[JOINED] || fired[CRASHED]);
+
     System.out.println("[testClientMembershipEventsInClient] assert client detected server recovery");
     assertTrue(fired[JOINED]);
     assertNotNull(member[JOINED]);
@@ -966,7 +960,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertNull(member[CRASHED]);
     assertNull(memberId[CRASHED]);
   }
-  
+
   /**
    * Tests notification of events in server process. Bridge servers detect
    * client joins when the client connects to the server.
@@ -976,34 +970,33 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     final DistributedMember[] member = new DistributedMember[3];
     final String[] memberId = new String[3];
     final boolean[] isClient = new boolean[3];
-    
+
     // create and register ClientMembershipListener in controller vm...
     ClientMembershipListener listener = new ClientMembershipListener() {
-      public synchronized void memberJoined(ClientMembershipEvent event) {
+      public void memberJoined(ClientMembershipEvent event) {
         System.out.println("[testClientMembershipEventsInServer] memberJoined: " + event);
         fired[JOINED] = true;
         member[JOINED] = event.getMember();
         memberId[JOINED] = event.getMemberId();
         isClient[JOINED] = event.isClient();
-        notifyAll();
         assertFalse(fired[LEFT] || fired[CRASHED]);
       }
-      public synchronized void memberLeft(ClientMembershipEvent event) {
+
+      public void memberLeft(ClientMembershipEvent event) {
         System.out.println("[testClientMembershipEventsInServer] memberLeft: " + event);
         fired[LEFT] = true;
         member[LEFT] = event.getMember();
         memberId[LEFT] = event.getMemberId();
         isClient[LEFT] = event.isClient();
-        notifyAll();
         assertFalse(fired[JOINED] || fired[CRASHED]);
       }
-      public synchronized void memberCrashed(ClientMembershipEvent event) {
+
+      public void memberCrashed(ClientMembershipEvent event) {
         System.out.println("[testClientMembershipEventsInServer] memberCrashed: " + event);
         fired[CRASHED] = true;
         member[CRASHED] = event.getMember();
         memberId[CRASHED] = event.getMemberId();
         isClient[CRASHED] = event.isClient();
-        notifyAll();
         assertFalse(fired[JOINED] || fired[LEFT]);
       }
     };
@@ -1021,12 +1014,12 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     Region region = createRegion(name, factory.create());
     assertNotNull(region);
     assertNotNull(getRootRegion().getSubregion(name));
-    
+
     ports[0] = startBridgeServer(0);
     assertTrue(ports[0] != 0);
     DistributedMember serverMember = getMemberId();
     String serverMemberId = serverMember.toString();
-    
+
     System.out.println("[testClientMembershipEventsInServer] ports[0]=" + ports[0]);
     System.out.println("[testClientMembershipEventsInServer] serverMemberId=" + serverMemberId);
     System.out.println("[testClientMembershipEventsInServer] serverMember=" + serverMember);
@@ -1043,12 +1036,12 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertNull(member[CRASHED]);
     assertNull(memberId[CRASHED]);
     assertFalse(isClient[CRASHED]);
-    
+
     // sanity check...
     System.out.println("[testClientMembershipEventsInServer] sanity check");
     DistributedMember test = new TestDistributedMember("test");
     InternalClientMembership.notifyJoined(test, CLIENT);
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[JOINED] && !fired[LEFT] && !fired[CRASHED]) {
         listener.wait(2000);
       }
@@ -1066,42 +1059,42 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertNull(memberId[CRASHED]);
     assertFalse(isClient[CRASHED]);
     resetArraysForTesting(fired, member, memberId, isClient);
-    
+
     final Host host = Host.getHost(0);
     SerializableCallable createConnectionPool =
-    new SerializableCallable("Create connectionPool") {
-      public Object call() {
-        System.out.println("[testClientMembershipEventsInServer] create bridge client");
-        Properties config = new Properties();
-        config.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        config.setProperty(DistributionConfig.LOCATORS_NAME, "");
-        properties = config;
-        DistributedSystem s = getSystem(config);
-        AttributesFactory factory = new AttributesFactory();
-        Pool pool = ClientServerTestCase.configureConnectionPool(factory, NetworkUtils.getServerHostName(host), ports, true, -1, 2, null);
-        createRegion(name, factory.create());
-        assertNotNull(getRootRegion().getSubregion(name));
-        assertTrue(s == basicGetSystem()); // see geode-1078
-        return getMemberId();
-      }
-    };
+        new SerializableCallable("Create connectionPool") {
+          public Object call() {
+            System.out.println("[testClientMembershipEventsInServer] create bridge client");
+            Properties config = new Properties();
+            config.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+            config.setProperty(DistributionConfig.LOCATORS_NAME, "");
+            properties = config;
+            DistributedSystem s = getSystem(config);
+            AttributesFactory factory = new AttributesFactory();
+            Pool pool = ClientServerTestCase.configureConnectionPool(factory, NetworkUtils.getServerHostName(host), ports, true, -1, 2, null);
+            createRegion(name, factory.create());
+            assertNotNull(getRootRegion().getSubregion(name));
+            assertTrue(s == basicGetSystem()); // see geode-1078
+            return getMemberId();
+          }
+        };
 
     // create bridge client in vm0...
-    DistributedMember clientMember = (DistributedMember)vm0.invoke(createConnectionPool);
+    DistributedMember clientMember = (DistributedMember) vm0.invoke(createConnectionPool);
     String clientMemberId = clientMember.toString();
-                                                
-    synchronized(listener) {
+
+    synchronized (listener) {
       if (!fired[JOINED] && !fired[LEFT] && !fired[CRASHED]) {
         listener.wait(60000);
       }
     }
-    
+
     System.out.println("[testClientMembershipEventsInServer] assert server detected client join");
     assertTrue(fired[JOINED]);
     assertEquals(member[JOINED] + " should equal " + clientMember,
-      clientMember, member[JOINED]);
+        clientMember, member[JOINED]);
     assertEquals(memberId[JOINED] + " should equal " + clientMemberId,
-      clientMemberId, memberId[JOINED]);
+        clientMemberId, memberId[JOINED]);
     assertTrue(isClient[JOINED]);
     assertFalse(fired[LEFT]);
     assertNull(member[LEFT]);
@@ -1114,26 +1107,26 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     resetArraysForTesting(fired, member, memberId, isClient);
 
     pauseForClientToJoin();
-    
+
     vm0.invoke(new SerializableRunnable("Stop bridge client") {
       public void run() {
         System.out.println("[testClientMembershipEventsInServer] Stop bridge client");
         getRootRegion().getSubregion(name).close();
         Map m = PoolManager.getAll();
         Iterator mit = m.values().iterator();
-        while(mit.hasNext()) {
-          Pool p = (Pool)mit.next();
+        while (mit.hasNext()) {
+          Pool p = (Pool) mit.next();
           p.destroy();
         }
       }
     });
 
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[JOINED] && !fired[LEFT] && !fired[CRASHED]) {
         listener.wait(60000);
       }
     }
-    
+
     System.out.println("[testClientMembershipEventsInServer] assert server detected client left");
     assertFalse(fired[JOINED]);
     assertNull(member[JOINED]);
@@ -1151,13 +1144,13 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
 
     // reconnect bridge client to test for crashed event
     clientMemberId = vm0.invoke(createConnectionPool).toString();
-                                                
-    synchronized(listener) {
+
+    synchronized (listener) {
       if (!fired[JOINED] && !fired[LEFT] && !fired[CRASHED]) {
         listener.wait(60000);
       }
     }
-    
+
     System.out.println("[testClientMembershipEventsInServer] assert server detected client re-join");
     assertTrue(fired[JOINED]);
     assertEquals(clientMember, member[JOINED]);
@@ -1172,7 +1165,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertNull(memberId[CRASHED]);
     assertFalse(isClient[CRASHED]);
     resetArraysForTesting(fired, member, memberId, isClient);
-    
+
     pauseForClientToJoin();
 
     ServerConnection.setForceClientCrashEvent(true);
@@ -1183,19 +1176,19 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
           getRootRegion().getSubregion(name).close();
           Map m = PoolManager.getAll();
           Iterator mit = m.values().iterator();
-          while(mit.hasNext()) {
-            Pool p = (Pool)mit.next();
+          while (mit.hasNext()) {
+            Pool p = (Pool) mit.next();
             p.destroy();
           }
         }
       });
-  
-      synchronized(listener) {
+
+      synchronized (listener) {
         if (!fired[JOINED] && !fired[LEFT] && !fired[CRASHED]) {
           listener.wait(60000);
         }
       }
-      
+
       System.out.println("[testClientMembershipEventsInServer] assert server detected client crashed");
       assertFalse(fired[JOINED]);
       assertNull(member[JOINED]);
@@ -1209,12 +1202,11 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       assertEquals(clientMember, member[CRASHED]);
       assertEquals(clientMemberId, memberId[CRASHED]);
       assertTrue(isClient[CRASHED]);
-    }
-    finally {
+    } finally {
       ServerConnection.setForceClientCrashEvent(false);
     }
   }
-  
+
   /**
    * The joined event fires when the first client handshake is processed.
    * This pauses long enough to allow the rest of the client sockets to
@@ -1227,17 +1219,17 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
   private void pauseForClientToJoin() {
     Wait.pause(2000);
   }
-  
-  /** 
-   * Tests registration and event notification in conjunction with 
-   * disconnecting and reconnecting to DistributedSystem. 
+
+  /**
+   * Tests registration and event notification in conjunction with
+   * disconnecting and reconnecting to DistributedSystem.
    */
   public void testLifecycle() throws Exception {
     final boolean[] fired = new boolean[3];
     final DistributedMember[] member = new DistributedMember[3];
     final String[] memberId = new String[3];
     final boolean[] isClient = new boolean[3];
-    
+
     // create and register ClientMembershipListener in controller vm...
     ClientMembershipListener listener = new ClientMembershipListener() {
       public synchronized void memberJoined(ClientMembershipEvent event) {
@@ -1251,24 +1243,26 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
         isClient[JOINED] = event.isClient();
         notifyAll();
       }
+
       public synchronized void memberLeft(ClientMembershipEvent event) {
       }
+
       public synchronized void memberCrashed(ClientMembershipEvent event) {
       }
     };
     ClientMembership.registerClientMembershipListener(listener);
-    
+
     // create loner in controller vm...
     Properties config = new Properties();
     config.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
     config.setProperty(DistributionConfig.LOCATORS_NAME, "");
     properties = config;
     getSystem(config);
-    
+
     // assert that event is fired while connected
     DistributedMember serverJoined = new TestDistributedMember("serverJoined");
     InternalClientMembership.notifyJoined(serverJoined, SERVER);
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[JOINED]) {
         listener.wait(2000);
       }
@@ -1278,13 +1272,12 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertEquals(serverJoined.getId(), memberId[JOINED]);
     assertFalse(isClient[JOINED]);
     resetArraysForTesting(fired, member, memberId, isClient);
-    
+
     // assert that event is NOT fired while disconnected
     disconnectFromDS();
-    
 
     InternalClientMembership.notifyJoined(serverJoined, SERVER);
-    synchronized(listener) {
+    synchronized (listener) {
       listener.wait(20);
     }
     assertFalse(fired[JOINED]);
@@ -1292,14 +1285,14 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertNull(memberId[JOINED]);
     assertFalse(isClient[JOINED]);
     resetArraysForTesting(fired, member, memberId, isClient);
-    
+
     // assert that event is fired again after reconnecting
     properties = config;
     InternalDistributedSystem sys = getSystem(config);
     assertTrue(sys.isConnected());
 
     InternalClientMembership.notifyJoined(serverJoined, SERVER);
-    synchronized(listener) {
+    synchronized (listener) {
       if (!fired[JOINED]) {
         listener.wait(2000);
       }
@@ -1309,15 +1302,15 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     assertEquals(serverJoined.getId(), memberId[JOINED]);
     assertFalse(isClient[JOINED]);
   }
-  
+
   /**
    * Starts up server in controller vm and 4 clients, then calls and tests
-   * ClientMembership.getConnectedClients(). 
+   * ClientMembership.getConnectedClients().
    */
   public void testGetConnectedClients() throws Exception {
     final String name = this.getUniqueName();
     final int[] ports = new int[1];
-    
+
     IgnoredException.addIgnoredException("ConnectException");
 
     // create BridgeServer in controller vm...
@@ -1328,7 +1321,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     Region region = createRegion(name, factory.create());
     assertNotNull(region);
     assertNotNull(getRootRegion().getSubregion(name));
-    
+
     ports[0] = startBridgeServer(0);
     assertTrue(ports[0] != 0);
     String serverMemberId = getSystem().getDistributedMember().toString();
@@ -1338,39 +1331,40 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
 
     final Host host = Host.getHost(0);
     SerializableCallable createPool =
-    new SerializableCallable("Create connection pool") {
-      public Object call() {
-        System.out.println("[testGetConnectedClients] create bridge client");
-        properties = new Properties();
-        properties.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        properties.setProperty(DistributionConfig.LOCATORS_NAME, "");
-        getSystem(properties);
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        Pool p = ClientServerTestCase.configureConnectionPool(factory, NetworkUtils.getServerHostName(host), ports, true, -1, -1, null);
-        createRegion(name, factory.create());
-        assertNotNull(getRootRegion().getSubregion(name));
-        assertTrue(p.getServers().size() > 0);
-        return getMemberId();
-      }
-    };
+        new SerializableCallable("Create connection pool") {
+          public Object call() {
+            System.out.println("[testGetConnectedClients] create bridge client");
+            properties = new Properties();
+            properties.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+            properties.setProperty(DistributionConfig.LOCATORS_NAME, "");
+            getSystem(properties);
+            AttributesFactory factory = new AttributesFactory();
+            factory.setScope(Scope.LOCAL);
+            Pool p = ClientServerTestCase.configureConnectionPool(factory, NetworkUtils.getServerHostName(host), ports, true, -1, -1, null);
+            createRegion(name, factory.create());
+            assertNotNull(getRootRegion().getSubregion(name));
+            assertTrue(p.getServers().size() > 0);
+            return getMemberId();
+          }
+        };
 
     // create bridge client in vm0...
     final String[] clientMemberIdArray = new String[host.getVMCount()];
-    
-    for (int i = 0; i < host.getVMCount(); i++) { 
+
+    for (int i = 0; i < host.getVMCount(); i++) {
       final VM vm = Host.getHost(0).getVM(i);
-      System.out.println("creating pool in vm_"+i);
+      System.out.println("creating pool in vm_" + i);
       clientMemberIdArray[i] = vm.invoke(createPool).toString();
     }
     Collection clientMemberIds = Arrays.asList(clientMemberIdArray);
-                                                
+
     {
       final int expectedClientCount = clientMemberIds.size();
       WaitCriterion wc = new WaitCriterion() {
         public String description() {
           return "wait for clients";
         }
+
         public boolean done() {
           Map connectedClients = InternalClientMembership.getConnectedClients(false);
           if (connectedClients == null) {
@@ -1384,32 +1378,32 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       };
       Wait.waitForCriterion(wc, 30000, 100, false);
     }
-    
+
     Map connectedClients = InternalClientMembership.getConnectedClients(false);
     assertNotNull(connectedClients);
     assertEquals(clientMemberIds.size(), connectedClients.size());
     System.out.println("connectedClients: " + connectedClients + "; clientMemberIds: " + clientMemberIds);
-    for (Iterator iter = connectedClients.keySet().iterator(); iter.hasNext();) {
-      String connectedClient = (String)iter.next();
+    for (Iterator iter = connectedClients.keySet().iterator(); iter.hasNext(); ) {
+      String connectedClient = (String) iter.next();
       System.out.println("[testGetConnectedClients] checking for client " + connectedClient);
       assertTrue(clientMemberIds.contains(connectedClient));
-      Object[] result = (Object[])connectedClients.get(connectedClient);
-      System.out.println("[testGetConnectedClients] result: " + 
-                          (result==null? "none"
-                              : String.valueOf(result[0])+"; connections="+result[1]));
+      Object[] result = (Object[]) connectedClients.get(connectedClient);
+      System.out.println("[testGetConnectedClients] result: " +
+          (result == null ? "none"
+              : String.valueOf(result[0]) + "; connections=" + result[1]));
     }
   }
 
   /**
    * Starts up 4 server and the controller vm as a client, then calls and tests
-   * ClientMembership.getConnectedServers(). 
+   * ClientMembership.getConnectedServers().
    */
   public void testGetConnectedServers() throws Exception {
     final Host host = Host.getHost(0);
     final String name = this.getUniqueName();
     final int[] ports = new int[host.getVMCount()];
-    
-    for (int i = 0; i < host.getVMCount(); i++) { 
+
+    for (int i = 0; i < host.getVMCount(); i++) {
       final int whichVM = i;
       final VM vm = Host.getHost(0).getVM(i);
       vm.invoke(new CacheSerializableRunnable("Create bridge server") {
@@ -1419,32 +1413,31 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
           getSystem();
           AttributesFactory factory = new AttributesFactory();
           factory.setScope(Scope.LOCAL);
-          Region region = createRegion(name+"_"+whichVM, factory.create());
+          Region region = createRegion(name + "_" + whichVM, factory.create());
           assertNotNull(region);
-          assertNotNull(getRootRegion().getSubregion(name+"_"+whichVM));
+          assertNotNull(getRootRegion().getSubregion(name + "_" + whichVM));
           region.put("KEY-1", "VAL-1");
-          
+
           try {
             testGetConnectedServers_port = startBridgeServer(0);
-          }
-          catch (IOException e) {
+          } catch (IOException e) {
             com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().error("startBridgeServer threw IOException", e);
             fail("startBridgeServer threw IOException " + e.getMessage());
           }
-          
+
           assertTrue(testGetConnectedServers_port != 0);
-      
-          System.out.println("[testGetConnectedServers] port=" + 
-            ports[whichVM]);
-          System.out.println("[testGetConnectedServers] serverMemberId=" + 
-            getDistributedMember());
+
+          System.out.println("[testGetConnectedServers] port=" +
+              ports[whichVM]);
+          System.out.println("[testGetConnectedServers] serverMemberId=" +
+              getDistributedMember());
         }
       });
       ports[whichVM] = vm.invoke("getTestGetConnectedServers_port",
           () -> ClientMembershipDUnitTest.getTestGetConnectedServers_port());
       assertTrue(ports[whichVM] != 0);
     }
-    
+
     System.out.println("[testGetConnectedServers] create bridge client");
     Properties config = new Properties();
     config.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
@@ -1452,17 +1445,17 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     properties = config;
     getSystem(config);
     getCache();
-    
+
     AttributesFactory factory = new AttributesFactory();
     factory.setScope(Scope.LOCAL);
 
     for (int i = 0; i < ports.length; i++) {
-      System.out.println("[testGetConnectedServers] creating connectionpool for " + 
-        NetworkUtils.getServerHostName(host) + " " + ports[i]);
+      System.out.println("[testGetConnectedServers] creating connectionpool for " +
+          NetworkUtils.getServerHostName(host) + " " + ports[i]);
       int[] thisServerPorts = new int[] { ports[i] };
-      ClientServerTestCase.configureConnectionPoolWithName(factory, NetworkUtils.getServerHostName(host), thisServerPorts, false, -1, -1, null,"pooly"+i);
-      Region region = createRegion(name+"_"+i, factory.create());
-      assertNotNull(getRootRegion().getSubregion(name+"_"+i));
+      ClientServerTestCase.configureConnectionPoolWithName(factory, NetworkUtils.getServerHostName(host), thisServerPorts, false, -1, -1, null, "pooly" + i);
+      Region region = createRegion(name + "_" + i, factory.create());
+      assertNotNull(getRootRegion().getSubregion(name + "_" + i));
       region.get("KEY-1");
     }
 
@@ -1472,6 +1465,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
         public String description() {
           return "wait for pools and servers";
         }
+
         public boolean done() {
           if (PoolManager.getAll().size() != expectedVMCount) {
             return false;
@@ -1491,25 +1485,25 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
 
     {
       assertEquals(host.getVMCount(), PoolManager.getAll().size());
-      
+
     }
-    
+
     Map connectedServers = InternalClientMembership.getConnectedServers();
     assertNotNull(connectedServers);
     assertEquals(host.getVMCount(), connectedServers.size());
-    for (Iterator iter = connectedServers.keySet().iterator(); iter.hasNext();) {
+    for (Iterator iter = connectedServers.keySet().iterator(); iter.hasNext(); ) {
       String connectedServer = (String) iter.next();
-      System.out.println("[testGetConnectedServers]  value for connectedServer: " + 
-                          connectedServers.get(connectedServer));
+      System.out.println("[testGetConnectedServers]  value for connectedServer: " +
+          connectedServers.get(connectedServer));
     }
   }
 
   protected static int testGetConnectedServers_port;
+
   private static int getTestGetConnectedServers_port() {
     return testGetConnectedServers_port;
   }
 
-  
   public Properties getDistributedSystemProperties() {
     if (properties == null) {
       properties = new Properties();
@@ -1525,8 +1519,8 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     final Host host = Host.getHost(0);
     final String name = this.getUniqueName();
     final int[] ports = new int[host.getVMCount()];
-    
-    for (int i = 0; i < host.getVMCount(); i++) { 
+
+    for (int i = 0; i < host.getVMCount(); i++) {
       final int whichVM = i;
       final VM vm = Host.getHost(0).getVM(i);
       vm.invoke(new CacheSerializableRunnable("Create bridge server") {
@@ -1539,28 +1533,27 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
           assertNotNull(region);
           assertNotNull(getRootRegion().getSubregion(name));
           region.put("KEY-1", "VAL-1");
-          
+
           try {
             testGetNotifiedClients_port = startBridgeServer(0);
-          }
-          catch (IOException e) {
+          } catch (IOException e) {
             com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().error("startBridgeServer threw IOException", e);
             fail("startBridgeServer threw IOException " + e.getMessage());
           }
-          
+
           assertTrue(testGetNotifiedClients_port != 0);
-      
-          System.out.println("[testGetNotifiedClients] port=" + 
-            ports[whichVM]);
-          System.out.println("[testGetNotifiedClients] serverMemberId=" + 
-            getMemberId());
+
+          System.out.println("[testGetNotifiedClients] port=" +
+              ports[whichVM]);
+          System.out.println("[testGetNotifiedClients] serverMemberId=" +
+              getMemberId());
         }
       });
       ports[whichVM] = vm.invoke("getTestGetNotifiedClients_port",
           () -> ClientMembershipDUnitTest.getTestGetNotifiedClients_port());
       assertTrue(ports[whichVM] != 0);
     }
-    
+
     System.out.println("[testGetNotifiedClients] create bridge client");
     Properties config = new Properties();
     config.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
@@ -1568,7 +1561,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     properties = config;
     getSystem();
     getCache();
-    
+
     AttributesFactory factory = new AttributesFactory();
     factory.setScope(Scope.LOCAL);
 
@@ -1580,14 +1573,14 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     region.get("KEY-1");
 
     final String clientMemberId = getMemberId().toString();
-    
+
     pauseForClientToJoin();
-    
+
     // assertions go here
     int[] clientCounts = new int[host.getVMCount()];
-    
+
     // only one server vm will have that client for updating
-    for (int i = 0; i < host.getVMCount(); i++) { 
+    for (int i = 0; i < host.getVMCount(); i++) {
       final int whichVM = i;
       final VM vm = Host.getHost(0).getVM(i);
       vm.invoke(new CacheSerializableRunnable("Create bridge server") {
@@ -1604,7 +1597,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
       clientCounts[whichVM] = vm.invoke("getTestGetNotifiedClients_clientCount",
           () -> ClientMembershipDUnitTest.getTestGetNotifiedClients_clientCount());
     }
-    
+
     // only one server should have a notifier for this client...
     int totalClientCounts = 0;
     for (int i = 0; i < clientCounts.length; i++) {
@@ -1613,20 +1606,24 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     // this assertion fails because the count is 4
     //assertEquals(1, totalClientCounts);
   }
+
   protected static int testGetNotifiedClients_port;
+
   private static int getTestGetNotifiedClients_port() {
     return testGetNotifiedClients_port;
   }
+
   protected static int testGetNotifiedClients_clientCount;
+
   private static int getTestGetNotifiedClients_clientCount() {
     return testGetNotifiedClients_clientCount;
   }
 
   // Simple DistributedMember implementation
   static final class TestDistributedMember implements DistributedMember {
-    
+
     private String host;
-    
+
     public TestDistributedMember(String host) {
       this.host = host;
     }
@@ -1650,29 +1647,29 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     public String getId() {
       return this.host;
     }
-    
+
     public int compareTo(DistributedMember o) {
       if ((o == null) || !(o instanceof TestDistributedMember)) {
         throw new InternalGemFireException("Invalidly comparing TestDistributedMember to " + o);
       }
-      
+
       TestDistributedMember tds = (TestDistributedMember) o;
       return getHost().compareTo(tds.getHost());
     }
-    
+
     public boolean equals(Object obj) {
       if ((obj == null) || !(obj instanceof TestDistributedMember)) {
         return false;
       }
-      return compareTo((TestDistributedMember)obj) == 0;
+      return compareTo((TestDistributedMember) obj) == 0;
     }
-    
+
     public int hashCode() {
       return getHost().hashCode();
     }
-    
+
     public DurableClientAttributes getDurableClientAttributes() {
-      
+
       return null;
     }
 


Mime
View raw message