Beispiel #1
0
  public final void testLinkStateAdvertisementProduction() {
    networkGraph = new TopologyMap(NODE_1);

    networkGraph.addNode(NODE_2);
    networkGraph.addNode(NODE_3);
    networkGraph.addNode(NODE_4);

    networkGraph.addLink(NODE_1, NODE_2, CONNECTION_ID_1);

    networkGraph.addLink(NODE_1, NODE_3, CONNECTION_ID_1);

    networkGraph.addLink(NODE_1, NODE_4, CONNECTION_ID_1);

    LinkStateAdvertisement lsa = networkGraph.generateNewLocalLSA();

    assertTrue(lsa.getOwner().equals(networkGraph.getLocalNodeId()));
    assertEquals(
        "Collection sizes are expected to be the same.",
        lsa.getLinks().size(),
        networkGraph.getSuccessors(NODE_1).size());

    for (TopologyLink channel : lsa.getLinks()) {
      assertTrue(
          networkGraph
              .getPredecessors(networkGraph.getNode(channel.getDestination()))
              .contains(networkGraph.getNode(networkGraph.getLocalNodeId())));
    }
  }
Beispiel #2
0
  /** Test for {@link NetworkGraph#getSuccessors())}. */
  public final void testGetSuccessors() {
    TopologyMap graph1 = new TopologyMap(NODE_1);

    graph1.addNode(NODE_2);
    graph1.addNode(NODE_3);
    graph1.addNode(NODE_4);

    assertEquals(0, graph1.getSuccessors().size());

    graph1.addLink(NODE_1, NODE_2, CONNECTION_ID_1);

    assertEquals(1, graph1.getSuccessors().size());
    assertTrue(TopologyMap.toNodeIdentifiers(graph1.getSuccessors()).contains(NODE_2));
    assertFalse(TopologyMap.toNodeIdentifiers(graph1.getSuccessors()).contains(NODE_1));

    graph1.addLink(NODE_3, NODE_1, CONNECTION_ID_1);

    assertFalse(TopologyMap.toNodeIdentifiers(graph1.getSuccessors()).contains(NODE_3));
    assertTrue(TopologyMap.toNodeIdentifiers(graph1.getSuccessors()).contains(NODE_2));
  }