@Test public void testIsNewerorSameLsa() throws Exception { lsaWrapper = new LsaWrapperImpl(); opaqueLsaHeader1 = new OpaqueLsaHeader(); opaqueLsaHeader1.setLsType(1); key = ospfLsdb.getLsaKey(opaqueLsaHeader1); lsaWrapper.setLsaHeader(opaqueLsaHeader1); ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper); lsaWrapper = new LsaWrapperImpl(); opaqueLsaHeader = new OpaqueLsaHeader(); opaqueLsaHeader.setLsType(2); ospfLsdb.getLsaKey(opaqueLsaHeader); lsaWrapper.setLsaHeader(opaqueLsaHeader); ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper); assertThat(ospfLsdb.isNewerOrSameLsa(opaqueLsaHeader1, opaqueLsaHeader), is(notNullValue())); assertThat(ospfLsdb, is(notNullValue())); }
public String isNewerOrSameLsa(LsaHeader lsa1, LsaHeader lsa2) { if (lsa1.lsSequenceNo() > lsa2.lsSequenceNo()) { return "latest"; } else if (lsa1.lsSequenceNo() < lsa2.lsSequenceNo()) { return "old"; } else if (lsa1.lsSequenceNo() == lsa2.lsSequenceNo()) { if (lsa1.lsCheckSum() > lsa2.lsCheckSum()) { return "latest"; } else if (lsa1.lsCheckSum() < lsa2.lsCheckSum()) { return "old"; } else if (lsa1.lsCheckSum() == lsa2.lsCheckSum()) { if (lsa1.age() == lsa2.age()) { return "same"; } else if (lsa1.age() == OspfParameters.MAXAGE) { return "latest"; } else if (lsa2.age() == OspfParameters.MAXAGE) { return "old"; } else if (OspfParameters.MAXAGEDIFF == (lsa1.age() - lsa2.age())) { if (lsa1.age() < lsa2.age()) { return "latest"; } else { return "old"; } } else { return "same"; } } } return ""; }
OspfLsdbImpl implements OspfLsdb { public String isNewerOrSameLsa(LsaHeader lsa1, LsaHeader lsa2) { if (lsa1.lsSequenceNo() > lsa2.lsSequenceNo()) { return "latest"; } else if (lsa1.lsSequenceNo() < lsa2.lsSequenceNo()) { return "old"; } else if (lsa1.lsSequenceNo() == lsa2.lsSequenceNo()) { if (lsa1.lsCheckSum() > lsa2.lsCheckSum()) { return "latest"; } else if (lsa1.lsCheckSum() < lsa2.lsCheckSum()) { return "old"; } else if (lsa1.lsCheckSum() == lsa2.lsCheckSum()) { if (lsa1.age() == lsa2.age()) { return "same"; } else if (lsa1.age() == OspfParameters.MAXAGE) { return "latest"; } else if (lsa2.age() == OspfParameters.MAXAGE) { return "old"; } else if (OspfParameters.MAXAGEDIFF == (lsa1.age() - lsa2.age())) { if (lsa1.age() < lsa2.age()) { return "latest"; } else { return "old"; } } else { return "same"; } } } return ""; } }
OspfLsdbImpl implements OspfLsdb { public String isNewerOrSameLsa(LsaHeader lsa1, LsaHeader lsa2) { if (lsa1.lsSequenceNo() > lsa2.lsSequenceNo()) { return "latest"; } else if (lsa1.lsSequenceNo() < lsa2.lsSequenceNo()) { return "old"; } else if (lsa1.lsSequenceNo() == lsa2.lsSequenceNo()) { if (lsa1.lsCheckSum() > lsa2.lsCheckSum()) { return "latest"; } else if (lsa1.lsCheckSum() < lsa2.lsCheckSum()) { return "old"; } else if (lsa1.lsCheckSum() == lsa2.lsCheckSum()) { if (lsa1.age() == lsa2.age()) { return "same"; } else if (lsa1.age() == OspfParameters.MAXAGE) { return "latest"; } else if (lsa2.age() == OspfParameters.MAXAGE) { return "old"; } else if (OspfParameters.MAXAGEDIFF == (lsa1.age() - lsa2.age())) { if (lsa1.age() < lsa2.age()) { return "latest"; } else { return "old"; } } else { return "same"; } } } return ""; } OspfLsdbImpl(OspfArea ospfArea); }
OspfLsdbImpl implements OspfLsdb { public String isNewerOrSameLsa(LsaHeader lsa1, LsaHeader lsa2) { if (lsa1.lsSequenceNo() > lsa2.lsSequenceNo()) { return "latest"; } else if (lsa1.lsSequenceNo() < lsa2.lsSequenceNo()) { return "old"; } else if (lsa1.lsSequenceNo() == lsa2.lsSequenceNo()) { if (lsa1.lsCheckSum() > lsa2.lsCheckSum()) { return "latest"; } else if (lsa1.lsCheckSum() < lsa2.lsCheckSum()) { return "old"; } else if (lsa1.lsCheckSum() == lsa2.lsCheckSum()) { if (lsa1.age() == lsa2.age()) { return "same"; } else if (lsa1.age() == OspfParameters.MAXAGE) { return "latest"; } else if (lsa2.age() == OspfParameters.MAXAGE) { return "old"; } else if (OspfParameters.MAXAGEDIFF == (lsa1.age() - lsa2.age())) { if (lsa1.age() < lsa2.age()) { return "latest"; } else { return "old"; } } else { return "same"; } } } return ""; } OspfLsdbImpl(OspfArea ospfArea); @Override boolean equals(Object o); @Override int hashCode(); void initializeDb(); List getAllLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable); String getLsaKey(LsaHeader lsaHeader); LsaWrapper lsaLookup(LsaHeader lsaHeader); LsaWrapper findLsa(int lsType, String lsaKey); boolean addLsa(LsaHeader newLsa, boolean isSelfOriginated, OspfInterface ospfInterface); void addLsaToMaxAgeBin(String key, Object wrapper); void removeLsaFromBin(Object lsaWrapper); String isNewerOrSameLsa(LsaHeader lsa1, LsaHeader lsa2); long getLsSequenceNumber(OspfLsaType lsaType); void deleteLsa(LsaHeader lsaHeader); void setRouterLsaSeqNo(long routerLsaSeqNo); void setNetworkLsaSeqNo(long networkLsaSeqNo); }
OspfLsdbImpl implements OspfLsdb { public String isNewerOrSameLsa(LsaHeader lsa1, LsaHeader lsa2) { if (lsa1.lsSequenceNo() > lsa2.lsSequenceNo()) { return "latest"; } else if (lsa1.lsSequenceNo() < lsa2.lsSequenceNo()) { return "old"; } else if (lsa1.lsSequenceNo() == lsa2.lsSequenceNo()) { if (lsa1.lsCheckSum() > lsa2.lsCheckSum()) { return "latest"; } else if (lsa1.lsCheckSum() < lsa2.lsCheckSum()) { return "old"; } else if (lsa1.lsCheckSum() == lsa2.lsCheckSum()) { if (lsa1.age() == lsa2.age()) { return "same"; } else if (lsa1.age() == OspfParameters.MAXAGE) { return "latest"; } else if (lsa2.age() == OspfParameters.MAXAGE) { return "old"; } else if (OspfParameters.MAXAGEDIFF == (lsa1.age() - lsa2.age())) { if (lsa1.age() < lsa2.age()) { return "latest"; } else { return "old"; } } else { return "same"; } } } return ""; } OspfLsdbImpl(OspfArea ospfArea); @Override boolean equals(Object o); @Override int hashCode(); void initializeDb(); List getAllLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable); String getLsaKey(LsaHeader lsaHeader); LsaWrapper lsaLookup(LsaHeader lsaHeader); LsaWrapper findLsa(int lsType, String lsaKey); boolean addLsa(LsaHeader newLsa, boolean isSelfOriginated, OspfInterface ospfInterface); void addLsaToMaxAgeBin(String key, Object wrapper); void removeLsaFromBin(Object lsaWrapper); String isNewerOrSameLsa(LsaHeader lsa1, LsaHeader lsa2); long getLsSequenceNumber(OspfLsaType lsaType); void deleteLsa(LsaHeader lsaHeader); void setRouterLsaSeqNo(long routerLsaSeqNo); void setNetworkLsaSeqNo(long networkLsaSeqNo);  }