@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())); }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { log.debug("OspfChannelHandler::messageReceived...!!!"); Object message = e.getMessage(); if (message instanceof List) { List<OspfMessage> ospfMessageList = (List<OspfMessage>) message; log.debug("OspfChannelHandler::List of IsisMessages Size {}", ospfMessageList.size()); if (ospfMessageList != null) { for (OspfMessage ospfMessage : ospfMessageList) { processOspfMessage(ospfMessage, ctx); } } else { log.debug("OspfChannelHandler::OspfMessages Null List...!!"); } } if (message instanceof OspfMessage) { OspfMessage ospfMessage = (OspfMessage) message; log.debug("OspfChannelHandler::OspfMessages received...!!"); processOspfMessage(ospfMessage, ctx); } }
OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler { @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { log.debug("OspfChannelHandler::messageReceived...!!!"); Object message = e.getMessage(); if (message instanceof List) { List<OspfMessage> ospfMessageList = (List<OspfMessage>) message; log.debug("OspfChannelHandler::List of IsisMessages Size {}", ospfMessageList.size()); if (ospfMessageList != null) { for (OspfMessage ospfMessage : ospfMessageList) { processOspfMessage(ospfMessage, ctx); } } else { log.debug("OspfChannelHandler::OspfMessages Null List...!!"); } } if (message instanceof OspfMessage) { OspfMessage ospfMessage = (OspfMessage) message; log.debug("OspfChannelHandler::OspfMessages received...!!"); processOspfMessage(ospfMessage, ctx); } } }
OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler { @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { log.debug("OspfChannelHandler::messageReceived...!!!"); Object message = e.getMessage(); if (message instanceof List) { List<OspfMessage> ospfMessageList = (List<OspfMessage>) message; log.debug("OspfChannelHandler::List of IsisMessages Size {}", ospfMessageList.size()); if (ospfMessageList != null) { for (OspfMessage ospfMessage : ospfMessageList) { processOspfMessage(ospfMessage, ctx); } } else { log.debug("OspfChannelHandler::OspfMessages Null List...!!"); } } if (message instanceof OspfMessage) { OspfMessage ospfMessage = (OspfMessage) message; log.debug("OspfChannelHandler::OspfMessages received...!!"); processOspfMessage(ospfMessage, ctx); } } OspfInterfaceChannelHandler(Controller controller, List<OspfProcess> processes); }
OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler { @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { log.debug("OspfChannelHandler::messageReceived...!!!"); Object message = e.getMessage(); if (message instanceof List) { List<OspfMessage> ospfMessageList = (List<OspfMessage>) message; log.debug("OspfChannelHandler::List of IsisMessages Size {}", ospfMessageList.size()); if (ospfMessageList != null) { for (OspfMessage ospfMessage : ospfMessageList) { processOspfMessage(ospfMessage, ctx); } } else { log.debug("OspfChannelHandler::OspfMessages Null List...!!"); } } if (message instanceof OspfMessage) { OspfMessage ospfMessage = (OspfMessage) message; log.debug("OspfChannelHandler::OspfMessages received...!!"); processOspfMessage(ospfMessage, ctx); } } OspfInterfaceChannelHandler(Controller controller, List<OspfProcess> processes); void initializeInterfaceMap(); void updateInterfaceMap(List<OspfProcess> ospfProcesses); @Override void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt); @Override void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt); @Override void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent
            e); @Override void messageReceived(ChannelHandlerContext ctx, MessageEvent
            e); void processOspfMessage(OspfMessage
                                           ospfMessage, ChannelHandlerContext ctx); void sentConfigPacket(byte[] configPacket); }
OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler { @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { log.debug("OspfChannelHandler::messageReceived...!!!"); Object message = e.getMessage(); if (message instanceof List) { List<OspfMessage> ospfMessageList = (List<OspfMessage>) message; log.debug("OspfChannelHandler::List of IsisMessages Size {}", ospfMessageList.size()); if (ospfMessageList != null) { for (OspfMessage ospfMessage : ospfMessageList) { processOspfMessage(ospfMessage, ctx); } } else { log.debug("OspfChannelHandler::OspfMessages Null List...!!"); } } if (message instanceof OspfMessage) { OspfMessage ospfMessage = (OspfMessage) message; log.debug("OspfChannelHandler::OspfMessages received...!!"); processOspfMessage(ospfMessage, ctx); } } OspfInterfaceChannelHandler(Controller controller, List<OspfProcess> processes); void initializeInterfaceMap(); void updateInterfaceMap(List<OspfProcess> ospfProcesses); @Override void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt); @Override void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt); @Override void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent
            e); @Override void messageReceived(ChannelHandlerContext ctx, MessageEvent
            e); void processOspfMessage(OspfMessage
                                           ospfMessage, ChannelHandlerContext ctx); void sentConfigPacket(byte[] configPacket);  }