@Test public void testConstructionNonExisting() { device1 = new EcmpSwitch(1, null, 5, new IdentityFlowletIntermediary()); device1.addConnection(topology.getPort(1, 0)); device1.addConnection(topology.getPort(1, 2)); device1.addConnection(topology.getPort(1, 3)); device1.addDestinationToNextSwitch(0, 0); boolean thrown = false; try { device1.addDestinationToNextSwitch(2, 4); } catch (IllegalArgumentException e) { thrown = true; } assertTrue(thrown); }
@Override public void addDestinationToNextSwitch(int destinationId, int nextHopId) { if (!connectedTo.contains(nextHopId)) { throw new IllegalArgumentException("Cannot add hop to a network device to which it is not connected (" + nextHopId + ")"); } List<Integer> current = this.destinationToNextSwitch.get(destinationId); if (current.contains(nextHopId)) { throw new IllegalArgumentException("Cannot add a duplicate next hop network device identifier (" + nextHopId + ")"); } current.add(nextHopId); }
EcmpSwitch extends NetworkDevice implements EcmpSwitchRoutingInterface { @Override public void addDestinationToNextSwitch(int destinationId, int nextHopId) { if (!connectedTo.contains(nextHopId)) { throw new IllegalArgumentException("Cannot add hop to a network device to which it is not connected (" + nextHopId + ")"); } List<Integer> current = this.destinationToNextSwitch.get(destinationId); if (current.contains(nextHopId)) { throw new IllegalArgumentException("Cannot add a duplicate next hop network device identifier (" + nextHopId + ")"); } current.add(nextHopId); } }
EcmpSwitch extends NetworkDevice implements EcmpSwitchRoutingInterface { @Override public void addDestinationToNextSwitch(int destinationId, int nextHopId) { if (!connectedTo.contains(nextHopId)) { throw new IllegalArgumentException("Cannot add hop to a network device to which it is not connected (" + nextHopId + ")"); } List<Integer> current = this.destinationToNextSwitch.get(destinationId); if (current.contains(nextHopId)) { throw new IllegalArgumentException("Cannot add a duplicate next hop network device identifier (" + nextHopId + ")"); } current.add(nextHopId); } EcmpSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); }
EcmpSwitch extends NetworkDevice implements EcmpSwitchRoutingInterface { @Override public void addDestinationToNextSwitch(int destinationId, int nextHopId) { if (!connectedTo.contains(nextHopId)) { throw new IllegalArgumentException("Cannot add hop to a network device to which it is not connected (" + nextHopId + ")"); } List<Integer> current = this.destinationToNextSwitch.get(destinationId); if (current.contains(nextHopId)) { throw new IllegalArgumentException("Cannot add a duplicate next hop network device identifier (" + nextHopId + ")"); } current.add(nextHopId); } EcmpSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); @Override void receive(Packet genericPacket); @Override void receiveFromIntermediary(Packet genericPacket); @Override void addDestinationToNextSwitch(int destinationId, int nextHopId); @Override String toString(); }
EcmpSwitch extends NetworkDevice implements EcmpSwitchRoutingInterface { @Override public void addDestinationToNextSwitch(int destinationId, int nextHopId) { if (!connectedTo.contains(nextHopId)) { throw new IllegalArgumentException("Cannot add hop to a network device to which it is not connected (" + nextHopId + ")"); } List<Integer> current = this.destinationToNextSwitch.get(destinationId); if (current.contains(nextHopId)) { throw new IllegalArgumentException("Cannot add a duplicate next hop network device identifier (" + nextHopId + ")"); } current.add(nextHopId); } EcmpSwitch(int identifier, TransportLayer transportLayer, int n, Intermediary intermediary); @Override void receive(Packet genericPacket); @Override void receiveFromIntermediary(Packet genericPacket); @Override void addDestinationToNextSwitch(int destinationId, int nextHopId); @Override String toString();  }