use of org.apache.geode.internal.cache.wan.MyGatewaySenderEventListener2 in project geode by apache.
the class SerialGatewaySenderEventListenerDUnitTest method validateReceivedEventsMapSizeListener2.
public static void validateReceivedEventsMapSizeListener2(final String senderId, final Map map) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
final List<AsyncEventListener> listeners = ((AbstractGatewaySender) sender).getAsyncEventListeners();
if (listeners.size() == 2) {
final AsyncEventListener l1 = listeners.get(0);
final AsyncEventListener l2 = listeners.get(1);
Awaitility.await().atMost(60000, TimeUnit.MILLISECONDS).until(() -> {
Map listenerMap1 = ((MyGatewaySenderEventListener) l1).getEventsMap();
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);
});
}
}
Aggregations