use of org.onosproject.net.link.LinkEvent.Type.LINK_UPDATED in project onos by opennetworkinglab.
the class ECLinkStoreTest method testEvents.
// If Delegates should be called only on remote events,
// then Simple* should never call them, thus not test required.
@Ignore("Ignore until Delegate spec. is clear.")
@Test
public final void testEvents() throws InterruptedException {
final ConnectPoint d1P1 = new ConnectPoint(DID1, P1);
final ConnectPoint d2P2 = new ConnectPoint(DID2, P2);
final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
final CountDownLatch addLatch = new CountDownLatch(1);
LinkStoreDelegate checkAdd = event -> {
assertEquals(LINK_ADDED, event.type());
assertLink(linkId1, INDIRECT, event.subject());
addLatch.countDown();
};
final CountDownLatch updateLatch = new CountDownLatch(1);
LinkStoreDelegate checkUpdate = event -> {
assertEquals(LINK_UPDATED, event.type());
assertLink(linkId1, DIRECT, event.subject());
updateLatch.countDown();
};
final CountDownLatch removeLatch = new CountDownLatch(1);
LinkStoreDelegate checkRemove = event -> {
assertEquals(LINK_REMOVED, event.type());
assertLink(linkId1, DIRECT, event.subject());
removeLatch.countDown();
};
linkStore.setDelegate(checkAdd);
putLink(linkId1, INDIRECT);
assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
linkStore.unsetDelegate(checkAdd);
linkStore.setDelegate(checkUpdate);
putLink(linkId1, DIRECT);
assertTrue("Update event fired", updateLatch.await(1, TimeUnit.SECONDS));
linkStore.unsetDelegate(checkUpdate);
linkStore.setDelegate(checkRemove);
linkStore.removeLink(d1P1, d2P2);
assertTrue("Remove event fired", removeLatch.await(1, TimeUnit.SECONDS));
}
Aggregations