@Test
public void testAddOrUpdateLinkToSelf() throws Exception {

    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
    Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(3), U64.ZERO);
    NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2));
    NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(3));
    LinkInfo info = new LinkInfo(new Date(),
    		new Date(), null);
    linkDiscovery.addOrUpdateLink(lt, info);
    // check invariants hold
    assertNotNull(linkDiscovery.switchLinks.get(lt.getSrc()));
    assertTrue(linkDiscovery.switchLinks.get(lt.getSrc()).contains(lt));
    assertNotNull(linkDiscovery.portLinks.get(srcNpt));
    assertTrue(linkDiscovery.portLinks.get(srcNpt).contains(lt));
    assertNotNull(linkDiscovery.portLinks.get(dstNpt));
    assertTrue(linkDiscovery.portLinks.get(dstNpt).contains(lt));
    assertTrue(linkDiscovery.links.containsKey(lt));
}