use of org.onosproject.net.link.LinkEvent in project onos by opennetworkinglab.
the class SimpleLinkStoreTest method testCreateOrUpdateLink.
@Test
public final void testCreateOrUpdateLink() {
ConnectPoint src = new ConnectPoint(DID1, P1);
ConnectPoint dst = new ConnectPoint(DID2, P2);
// add link
LinkEvent event = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, INDIRECT));
assertLink(DID1, P1, DID2, P2, INDIRECT, event.subject());
assertEquals(LINK_ADDED, event.type());
// update link type
LinkEvent event2 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT));
assertLink(DID1, P1, DID2, P2, DIRECT, event2.subject());
assertEquals(LINK_UPDATED, event2.type());
// no change
LinkEvent event3 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT));
assertNull("No change event expected", event3);
}
use of org.onosproject.net.link.LinkEvent in project onos by opennetworkinglab.
the class SimpleLinkStoreTest method testRemoveLink.
@Test
public final void testRemoveLink() {
final ConnectPoint d1P1 = new ConnectPoint(DID1, P1);
final ConnectPoint d2P2 = new ConnectPoint(DID2, P2);
LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
LinkKey linkId2 = LinkKey.linkKey(d2P2, d1P1);
putLink(linkId1, DIRECT, A1);
putLink(linkId2, DIRECT, A2);
// DID1,P1 => DID2,P2
// DID2,P2 => DID1,P1
// DID1,P2 => DID2,P3
LinkEvent event = linkStore.removeLink(d1P1, d2P2);
assertEquals(LINK_REMOVED, event.type());
assertAnnotationsEquals(event.subject().annotations(), A1);
LinkEvent event2 = linkStore.removeLink(d1P1, d2P2);
assertNull(event2);
assertLink(linkId2, DIRECT, linkStore.getLink(d2P2, d1P1));
assertAnnotationsEquals(linkStore.getLink(d2P2, d1P1).annotations(), A2);
// annotations, etc. should not survive remove
putLink(linkId1, DIRECT);
assertLink(linkId1, DIRECT, linkStore.getLink(d1P1, d2P2));
assertAnnotationsEquals(linkStore.getLink(d1P1, d2P2).annotations());
}
use of org.onosproject.net.link.LinkEvent in project onos by opennetworkinglab.
the class SimpleLinkStoreTest method removeOrDownLink.
private void removeOrDownLink(boolean isDurable) {
final ConnectPoint d1P1 = new ConnectPoint(DID1, P1);
final ConnectPoint d2P2 = new ConnectPoint(DID2, P2);
LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
LinkKey linkId2 = LinkKey.linkKey(d2P2, d1P1);
putLink(linkId1, DIRECT, isDurable ? DA1 : A1);
putLink(linkId2, DIRECT, isDurable ? DA2 : A2);
// DID1,P1 => DID2,P2
// DID2,P2 => DID1,P1
// DID1,P2 => DID2,P3
LinkEvent event = linkStore.removeOrDownLink(d1P1, d2P2);
assertEquals(isDurable ? LINK_UPDATED : LINK_REMOVED, event.type());
assertAnnotationsEquals(event.subject().annotations(), isDurable ? DA1 : A1);
LinkEvent event2 = linkStore.removeOrDownLink(d1P1, d2P2);
assertNull(event2);
assertLink(linkId2, DIRECT, linkStore.getLink(d2P2, d1P1));
assertAnnotationsEquals(linkStore.getLink(d2P2, d1P1).annotations(), isDurable ? DA2 : A2);
// annotations, etc. should not survive remove
if (!isDurable) {
putLink(linkId1, DIRECT);
assertLink(linkId1, DIRECT, linkStore.getLink(d1P1, d2P2));
assertAnnotationsEquals(linkStore.getLink(d1P1, d2P2).annotations());
}
}
use of org.onosproject.net.link.LinkEvent in project onos by opennetworkinglab.
the class MQEventHandlerTest method testAddLink.
@Test
public void testAddLink() throws Exception {
Link link = createLink();
LinkEvent event = new LinkEvent(LINK_ADDED, link, 123L);
validateEvent(event, LINK_ADDED, link, 123L);
}
use of org.onosproject.net.link.LinkEvent in project onos by opennetworkinglab.
the class MQEventHandlerTest method testRemoveLink.
@Test
public void testRemoveLink() throws Exception {
Link link = createLink();
LinkEvent event = new LinkEvent(LINK_ADDED, link, 123L);
validateEvent(event, LINK_ADDED, link, 123L);
LinkEvent event1 = new LinkEvent(LINK_REMOVED, link, 123L);
validateEvent(event1, LINK_REMOVED, link, 123L);
}
Aggregations