boolean ok = dg.waitForBroadcast(1000);
Assert.assertTrue(ok);
Map<String, DiscoveryEntry> entryMap = dg.getDiscoveryEntryMap();
Assert.assertNotNull(entryMap);
Assert.assertEquals(1, entryMap.size());
DiscoveryEntry entry = entryMap.get(node1);
Assert.assertNotNull(entry);
Assert.assertEquals(connectorPair1, entry.getConnectorPair());
Assert.assertTrue(listener1.called);
Assert.assertTrue(listener2.called);
listener1.called = false;
listener2.called = false;
bg2.broadcastConnectors();
ok = dg.waitForBroadcast(1000);
Assert.assertTrue(ok);
entryMap = dg.getDiscoveryEntryMap();
Assert.assertNotNull(entryMap);
Assert.assertEquals(2, entryMap.size());
DiscoveryEntry entry1 = entryMap.get(node1);
Assert.assertNotNull(entry1);
Assert.assertEquals(connectorPair1, entry1.getConnectorPair());
DiscoveryEntry entry2 = entryMap.get(node2);
Assert.assertNotNull(entry2);
Assert.assertEquals(connectorPair2, entry2.getConnectorPair());
Assert.assertTrue(listener1.called);
Assert.assertTrue(listener2.called);
listener1.called = false;
listener2.called = false;
bg3.broadcastConnectors();
ok = dg.waitForBroadcast(1000);
Assert.assertTrue(ok);
entryMap = dg.getDiscoveryEntryMap();
Assert.assertNotNull(entryMap);
Assert.assertEquals(3, entryMap.size());
entry1 = entryMap.get(node1);
Assert.assertNotNull(entry1);
Assert.assertEquals(connectorPair1, entry1.getConnectorPair());
entry2 = entryMap.get(node2);
Assert.assertNotNull(entry2);
Assert.assertEquals(connectorPair2, entry2.getConnectorPair());
DiscoveryEntry entry3 = entryMap.get(node3);
Assert.assertNotNull(entry3);
Assert.assertEquals(connectorPair3, entry3.getConnectorPair());
Assert.assertTrue(listener1.called);
Assert.assertTrue(listener2.called);
listener1.called = false;
listener2.called = false;
bg1.broadcastConnectors();
ok = dg.waitForBroadcast(1000);
Assert.assertTrue(ok);
entryMap = dg.getDiscoveryEntryMap();
Assert.assertNotNull(entryMap);
Assert.assertEquals(3, entryMap.size());
entry1 = entryMap.get(node1);
Assert.assertNotNull(entry1);
Assert.assertEquals(connectorPair1, entry1.getConnectorPair());
entry2 = entryMap.get(node2);
Assert.assertNotNull(entry2);
Assert.assertEquals(connectorPair2, entry2.getConnectorPair());
entry3 = entryMap.get(node3);
Assert.assertNotNull(entry3);
Assert.assertEquals(connectorPair3, entry3.getConnectorPair());
Assert.assertFalse(listener1.called);
Assert.assertFalse(listener2.called);
listener1.called = false;
listener2.called = false;
bg2.broadcastConnectors();
ok = dg.waitForBroadcast(1000);
Assert.assertTrue(ok);
entryMap = dg.getDiscoveryEntryMap();
Assert.assertNotNull(entryMap);
Assert.assertEquals(3, entryMap.size());
entry1 = entryMap.get(node1);
Assert.assertNotNull(entry1);
Assert.assertEquals(connectorPair1, entry1.getConnectorPair());
entry2 = entryMap.get(node2);
Assert.assertNotNull(entry2);
Assert.assertEquals(connectorPair2, entry2.getConnectorPair());
entry3 = entryMap.get(node3);
Assert.assertNotNull(entry3);
Assert.assertEquals(connectorPair3, entry3.getConnectorPair());
Assert.assertFalse(listener1.called);
Assert.assertFalse(listener2.called);
listener1.called = false;
listener2.called = false;
bg3.broadcastConnectors();
ok = dg.waitForBroadcast(1000);
Assert.assertTrue(ok);
entryMap = dg.getDiscoveryEntryMap();
Assert.assertNotNull(entryMap);
Assert.assertEquals(3, entryMap.size());
entry1 = entryMap.get(node1);
Assert.assertNotNull(entry1);
Assert.assertEquals(connectorPair1, entry1.getConnectorPair());
entry2 = entryMap.get(node2);
Assert.assertNotNull(entry2);
Assert.assertEquals(connectorPair2, entry2.getConnectorPair());
entry3 = entryMap.get(node3);
Assert.assertNotNull(entry3);
Assert.assertEquals(connectorPair3, entry3.getConnectorPair());
Assert.assertFalse(listener1.called);
Assert.assertFalse(listener2.called);
listener1.called = false;
listener2.called = false;
bg2.removeConnectorPair(connectorPair2);
bg2.broadcastConnectors();
ok = dg.waitForBroadcast(1000);
Assert.assertTrue(ok);
// Connector2 should still be there since not timed out yet
entryMap = dg.getDiscoveryEntryMap();
Assert.assertNotNull(entryMap);
Assert.assertEquals(3, entryMap.size());
entry1 = entryMap.get(node1);
Assert.assertNotNull(entry1);
Assert.assertEquals(connectorPair1, entry1.getConnectorPair());
entry2 = entryMap.get(node2);
Assert.assertNotNull(entry2);
Assert.assertEquals(connectorPair2, entry2.getConnectorPair());
entry3 = entryMap.get(node3);
Assert.assertNotNull(entry3);
Assert.assertEquals(connectorPair3, entry3.getConnectorPair());
Assert.assertFalse(listener1.called);
Assert.assertFalse(listener2.called);
listener1.called = false;
listener2.called = false;
Thread.sleep(timeout);
bg1.broadcastConnectors();
ok = dg.waitForBroadcast(1000);
bg2.broadcastConnectors();
ok = dg.waitForBroadcast(1000);
bg3.broadcastConnectors();
ok = dg.waitForBroadcast(1000);
entryMap = dg.getDiscoveryEntryMap();
Assert.assertNotNull(entryMap);
Assert.assertEquals(2, entryMap.size());
entry1 = entryMap.get(node1);
Assert.assertNotNull(entry1);
Assert.assertEquals(connectorPair1, entry1.getConnectorPair());
entry3 = entryMap.get(node3);
Assert.assertNotNull(entry3);
Assert.assertEquals(connectorPair3, entry3.getConnectorPair());
Assert.assertTrue(listener1.called);
Assert.assertTrue(listener2.called);
listener1.called = false;
listener2.called = false;