/** 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()));
 }
Example #2
0
 /** Utility for test method. */
 private OspfInterfaceImpl createOspfInterface() throws Exception {
   ospfInterface = new OspfInterfaceImpl();
   LsaHeader lsaHeader = new LsaHeader();
   lsaHeader.setLsType(OspfLsaType.ROUTER.value());
   RouterLsa routerLsa = new RouterLsa();
   OspfAreaImpl ospfArea = new OspfAreaImpl();
   ospfArea.addLsa(routerLsa, true, ospfInterface);
   ospfNbr =
       new OspfNbrImpl(
           ospfArea, ospfInterface, ip4Address5, ip4Address6, 2, topologyForDeviceAndLink);
   ospfNbr.setState(OspfNeighborState.EXSTART);
   ospfNbr.setNeighborId(ip4Address7);
   this.ospfInterface = new OspfInterfaceImpl();
   this.ospfInterface.setIpAddress(ip4Address5);
   this.ospfInterface.setIpNetworkMask(subnetAddress);
   this.ospfInterface.setBdr(ip4Address4);
   this.ospfInterface.setDr(ip4Address4);
   this.ospfInterface.setHelloIntervalTime(20);
   this.ospfInterface.setInterfaceType(2);
   this.ospfInterface.setReTransmitInterval(2000);
   this.ospfInterface.setMtu(6500);
   this.ospfInterface.setRouterDeadIntervalTime(1000);
   this.ospfInterface.setRouterPriority(1);
   this.ospfInterface.setInterfaceType(1);
   this.ospfInterface.setInterfaceIndex(1);
   this.ospfInterface.addNeighbouringRouter(ospfNbr);
   this.ospfInterface.setOspfArea(ospfArea);
   return this.ospfInterface;
 }
Example #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()));
  }
Example #4
0
  /** Utility for test method. */
  private OspfAreaImpl createOspfArea() throws Exception {
    OspfAreaAddressRangeImpl ospfAreaAddressRange;
    ospfAreaAddressRange = createOspfAreaAddressRange();
    addressRanges.add(ospfAreaAddressRange);
    OspfAreaImpl ospfArea = new OspfAreaImpl();
    ospfArea.setAreaId(ip4Address5);
    ospfArea.setExternalRoutingCapability(true);
    OspfInterfaceImpl ospfInterface = createOspfInterface();
    ospfInterfaces.add(ospfInterface);
    ospfArea.setOspfInterfaceList(ospfInterfaces);
    RouterLsa routerLsa = new RouterLsa();
    routerLsa.setLsType(1);
    routerLsa.setLinkStateId(string1);
    routerLsa.setAdvertisingRouter(ip4Address2);
    ospfArea.addLsa(routerLsa, false, ospfInterface);
    ospfArea.setRouterId(ip4Address4);

    return ospfArea;
  }