geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hiteshkhame...@apache.org
Subject [24/50] [abbrv] incubator-geode git commit: GEODE-1066: Replaced WaitCriterion with Awaitility
Date Thu, 18 Aug 2016 19:27:42 GMT
GEODE-1066: Replaced WaitCriterion with Awaitility

	* Awaitility is used
	* Correct order of creation of caches/regions/senders/recievers


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

Branch: refs/heads/feature/GEODE-1372
Commit: a1d2fa2bdc3c74946d37025455acb9516a9b6535
Parents: f8f8986
Author: nabarun <nnag@pivotal.io>
Authored: Mon Aug 8 12:00:22 2016 -0700
Committer: nabarun <nnag@pivotal.io>
Committed: Mon Aug 15 14:15:23 2016 -0700

----------------------------------------------------------------------
 ...rialGatewaySenderEventListenerDUnitTest.java | 66 +++++++++-----------
 1 file changed, 28 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a1d2fa2b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderEventListenerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderEventListenerDUnitTest.java
b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderEventListenerDUnitTest.java
index 56d2bcc..a6a68e3 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderEventListenerDUnitTest.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/serial/SerialGatewaySenderEventListenerDUnitTest.java
@@ -16,20 +16,20 @@
  */
 package com.gemstone.gemfire.internal.cache.wan.serial;
 
+import com.jayway.awaitility.Awaitility;
 import org.junit.Ignore;
 import org.junit.experimental.categories.Category;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
 
-import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
-import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 import org.junit.experimental.categories.Category;
 
@@ -171,6 +171,12 @@ public class SerialGatewaySenderEventListenerDUnitTest extends WANTestBase
{
     Integer nyPort = (Integer)vm1.invoke(() -> WANTestBase.createFirstRemoteLocator( 2,
lnPort ));
 
     createCacheInVMs(nyPort, vm2, vm3);
+
+    vm2.invoke(() -> WANTestBase.createReplicatedRegion(
+      getTestMethodName() + "_RR", null, isOffHeap() ));
+    vm3.invoke(() -> WANTestBase.createReplicatedRegion(
+      getTestMethodName() + "_RR", null, isOffHeap() ));
+
     createReceiverInVMs(vm2, vm3);
 
     createCacheInVMs(lnPort, vm4, vm5, vm6, vm7);
@@ -180,21 +186,12 @@ public class SerialGatewaySenderEventListenerDUnitTest extends WANTestBase
{
     vm5.invoke(() -> WANTestBase.createSenderWithListener( "ln", 2,
         false, 100, 10, false, false, null, true, true));
 
-    vm2.invoke(() -> WANTestBase.createReplicatedRegion(
-        getTestMethodName() + "_RR", null, isOffHeap() ));
-    vm3.invoke(() -> WANTestBase.createReplicatedRegion(
-        getTestMethodName() + "_RR", null, isOffHeap() ));
-
     startSenderInVMs("ln", vm4, vm5);
 
     vm4.invoke(() -> WANTestBase.createReplicatedRegion(
         getTestMethodName() + "_RR", "ln", isOffHeap() ));
     vm5.invoke(() -> WANTestBase.createReplicatedRegion(
         getTestMethodName() + "_RR", "ln", isOffHeap() ));
-    vm6.invoke(() -> WANTestBase.createReplicatedRegion(
-        getTestMethodName() + "_RR", "ln", isOffHeap() ));
-    vm7.invoke(() -> WANTestBase.createReplicatedRegion(
-        getTestMethodName() + "_RR", "ln", isOffHeap() ));
 
     final Map keyValues = new HashMap();
     for(int i=0; i< 1000; i++) {
@@ -359,35 +356,28 @@ public class SerialGatewaySenderEventListenerDUnitTest extends WANTestBase
{
     if(listeners.size() == 2) {
       final AsyncEventListener l1 = listeners.get(0);
       final AsyncEventListener l2 = listeners.get(1);
-
-      WaitCriterion wc = new WaitCriterion() {
-        Map listenerMap1, listenerMap2;
-        public boolean done() {
-          listenerMap1 = ((MyGatewaySenderEventListener)l1)
-              .getEventsMap();
-          
-          listenerMap2 = ((MyGatewaySenderEventListener2)l2)
+      Awaitility.await().atMost(60000, TimeUnit.MILLISECONDS).until(()->{
+        Map listenerMap1 = ((MyGatewaySenderEventListener)l1)
           .getEventsMap();
-          
-          boolean sizeCorrect = map.size() == listenerMap1.size();
-          boolean keySetCorrect = listenerMap1.keySet().containsAll(map.keySet());
-          boolean valuesCorrect = listenerMap1.values().containsAll(map.values());
-          
-          boolean sizeCorrect2 = map.size() == listenerMap2.size();
-          boolean keySetCorrect2 = listenerMap2.keySet().containsAll(map.keySet());
-          boolean valuesCorrect2 = listenerMap2.values().containsAll(map.values());
-          
-          
-          return sizeCorrect && keySetCorrect && valuesCorrect &&
sizeCorrect2 && keySetCorrect2 && valuesCorrect2;
-        }
 
-        public String description() {
-          return "Waiting for all sites to get updated, the sizes are "
-              + listenerMap1.size() + " and listenerMap2 "
-              + listenerMap2.size() + " expected map size " + map.size();
-        }
-      };
-      Wait.waitForCriterion(wc, 60000, 500, true); 
+        Map listenerMap2 = ((MyGatewaySenderEventListener2)l2)
+          .getEventsMap();
+        int listener1MapSize = listenerMap1.size();
+        int listener2MapSize = listenerMap1.size();
+        int expectedMapSize = map.size();
+        boolean sizeCorrect = expectedMapSize == listener1MapSize;
+        boolean keySetCorrect = listenerMap1.keySet().containsAll(map.keySet());
+        boolean valuesCorrect = listenerMap1.values().containsAll(map.values());
+
+        boolean sizeCorrect2 = expectedMapSize== listener2MapSize;
+        boolean keySetCorrect2 = listenerMap2.keySet().containsAll(map.keySet());
+        boolean valuesCorrect2 = listenerMap2.values().containsAll(map.values());
+
+        assertEquals("Failed while waiting for all sites to get updated with the correct
events. \nThe " +
+                     "size of listener 1's map = "+ listener1MapSize + "\n The size of listener
2's map = " +
+                     ""+ listener2MapSize + "\n The expected map size =" + expectedMapSize
,
+          true, sizeCorrect && keySetCorrect && valuesCorrect &&
sizeCorrect2 && keySetCorrect2 && valuesCorrect2);
+      });
     }
   }
 }


Mime
View raw message