Ejemplo n.º 1
0
 /** Utility for test method. */
 private OspfInterfaceImpl createOspfInterface1() throws UnknownHostException {
   ospfInterface = new OspfInterfaceImpl();
   OspfAreaImpl ospfArea = new OspfAreaImpl();
   OspfInterfaceChannelHandler ospfInterfaceChannelHandler =
       EasyMock.createMock(OspfInterfaceChannelHandler.class);
   ospfNbr =
       new OspfNbrImpl(
           ospfArea, ospfInterface, ip4Address5, ip4Address6, 2, topologyForDeviceAndLink);
   ospfNbr.setState(OspfNeighborState.FULL);
   ospfNbr.setNeighborId(ip4Address7);
   ospfInterface = new OspfInterfaceImpl();
   ospfInterface.setIpAddress(ip4Address5);
   ospfInterface.setIpNetworkMask(subnetAddress);
   ospfInterface.setBdr(ip4Address4);
   ospfInterface.setDr(ip4Address4);
   ospfInterface.setHelloIntervalTime(20);
   ospfInterface.setInterfaceType(2);
   ospfInterface.setReTransmitInterval(2000);
   ospfInterface.setMtu(6500);
   ospfInterface.setRouterDeadIntervalTime(1000);
   ospfInterface.setRouterPriority(1);
   ospfInterface.setInterfaceType(1);
   ospfInterface.addNeighbouringRouter(ospfNbr);
   return ospfInterface;
 }
Ejemplo n.º 2
0
 /** Tests deleteConfig() method. */
 @Test
 public void testDeleteConfig() throws Exception {
   ospfProcess = new OspfProcessImpl();
   ospfArea = new OspfAreaImpl();
   ospfInterface = new OspfInterfaceImpl();
   ospfInterfaces = new ArrayList();
   ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.5"));
   ospfInterfaces.add(ospfInterface);
   ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2"));
   ospfArea.setInterfacesLst(ospfInterfaces);
   ospfProcess.setProcessId("10.10.10.10");
   areas = new ArrayList();
   areas.add(ospfArea);
   ospfProcess.setAreas(areas);
   ospfProcesses = new ArrayList();
   ospfProcesses.add(ospfProcess);
   process1 = new OspfProcessImpl();
   process1.setProcessId("11.11.11.11");
   ospfArea1 = new OspfAreaImpl();
   ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2"));
   ospfArea1.setInterfacesLst(ospfInterfaces);
   areas.add(ospfArea1);
   process1.setAreas(areas);
   ospfProcesses.add(process1);
   ospfController.deleteConfig(ospfProcesses, "INTERFACE");
   assertThat(ospfController, is(notNullValue()));
 }
Ejemplo n.º 3
0
  /** Tests messageReceived() method. */
  @Test
  public void testMessageReceived() throws Exception {
    ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
    ospfInterface.setInterfaceType(2);
    ospfArea.setAreaId(Ip4Address.valueOf("13.13.13.13"));
    channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
    MessageEvent messageEvent =
        new MessageEvent() {
          @Override
          public Object getMessage() {
            helloPacket = new HelloPacket();
            helloPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
            helloPacket.setRouterId(Ip4Address.valueOf("10.10.10.10"));
            helloPacket.setOspfVer(2);
            helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
            helloPacket.setOptions(2);
            helloPacket.setAreaId(Ip4Address.valueOf("5.5.5.5"));
            helloPacket.setNetworkMask(Ip4Address.valueOf("3.3.3.3"));
            helloPacket.setOspftype(1);
            helloPacket.setAuthType(0);
            helloPacket.setAuthentication(0);
            checksumCalculator = new ChecksumCalculator();
            byteArray = helloPacket.asBytes();
            helloPacket.setOspfPacLength(byteArray.length);
            checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
            buf = ChannelBuffers.copiedBuffer(checkArray);
            helloPacket.setChecksum(buf.readUnsignedShort());
            List<HelloPacket> messPackets = new ArrayList<>();
            messPackets.add(helloPacket);
            return messPackets;
          }

          @Override
          public SocketAddress getRemoteAddress() {
            return null;
          }

          @Override
          public Channel getChannel() {
            return null;
          }

          @Override
          public ChannelFuture getFuture() {
            return null;
          }
        };
    ospfInterfaceChannelHandler.messageReceived(channelHandlerContext, messageEvent);
    assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
  }