Esempio n. 1
0
  /** Test for {@link TopologyMap#getAllLinks()}. */
  public final void testGetChannels() {
    networkGraph = new TopologyMap(NODE_1);

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

    networkGraph.addLink(NODE_1, NODE_2, CONNECTION_ID_1);
    networkGraph.addLink(NODE_2, NODE_1, CONNECTION_ID_1);
    networkGraph.addLink(NODE_2, NODE_3, CONNECTION_ID_1);

    assertEquals(3, networkGraph.getAllLinks().size());

    assertNotNull(networkGraph.getLinkForConnection(CONNECTION_ID_1));
    assertEquals(
        networkGraph.getLinkForConnection(CONNECTION_ID_1),
        new TopologyLink(NODE_1, NODE_2, CONNECTION_ID_1));

    networkGraph.removeLink(null);
    networkGraph.removeLink(networkGraph.getLinkForConnection(CONNECTION_ID_1));

    assertEquals(2, networkGraph.getAllLinks().size());
    assertFalse(networkGraph.containsLinkBetween(NODE_1, NODE_2));
    assertFalse(networkGraph.containsLink(NODE_1, NODE_2, CONNECTION_ID_1));
  }
Esempio n. 2
0
 /** TODO @krol_ph: Test description. */
 public final void testUpdateGraphEdges() {
   networkGraph = new TopologyMap(NODE_1);
   networkGraph.addNode(NODE_2);
   networkGraph.addNode(NODE_2);
   // should succeed
   networkGraph.addLink(NODE_1, NODE_2, CONNECTION_ID_1);
   // note: changed to assertFalse() after switch from NCP to connection ids
   try {
     networkGraph.addLink(NODE_1, NODE_2, CONNECTION_ID_1);
     fail("Exception expected");
   } catch (IllegalStateException e) {
     assertTrue(true);
   }
   // note: changed to assertFalse() after switch from NCP to connection ids
   assertFalse(networkGraph.addLink(new TopologyLink(NODE_1, NODE_2, CONNECTION_ID_1)));
   networkGraph.getLinkForConnection(CONNECTION_ID_1).incReliability();
   networkGraph.getLinkForConnection(CONNECTION_ID_1).setWeight(7);
   assertEquals(1, networkGraph.getLinkForConnection(CONNECTION_ID_1).getReliability());
   assertEquals(7, networkGraph.getLinkForConnection(CONNECTION_ID_1).getWeight());
 }