use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class TimeBucketWheelUnitTest method expiredMappingClearedProperlyTest.
/**
* Tests {@link TimeBucketWheel#clearExpiredMappingAndRotate(long)} method.
* {@link ClassCastException} can be thrown.
*/
@Test
public void expiredMappingClearedProperlyTest() {
PowerMockito.mockStatic(System.class);
long frozenTimeStamp = System.currentTimeMillis();
PowerMockito.when(System.currentTimeMillis()).thenReturn(frozenTimeStamp);
TimeBucketWheel timeBucketWheel = getDefaultTimeBucketWheel();
MappingData mappingData = getDefaultMappingData(IPV4_EID_1);
timeBucketWheel.add(IPV4_EID_1, mappingData, System.currentTimeMillis());
frozenTimeStamp = System.currentTimeMillis() + 4000;
PowerMockito.when(System.currentTimeMillis()).thenReturn(frozenTimeStamp);
timeBucketWheel.clearExpiredMappingAndRotate(frozenTimeStamp);
Mockito.verify(mappingSystem).handleSbExpiredMapping(IPV4_EID_1, null, mappingData);
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MappingMergeUtilTest method getCommonLocatorRecords_withEmptyLocatorRecords.
/**
* Tests {@link MappingMergeUtil#getCommonLocatorRecords} method with empty list of locator records.
*/
@Test
public void getCommonLocatorRecords_withEmptyLocatorRecords() {
MappingRecord nbMappingRecord = getDefaultMappingRecordBuilder().setEid(IPV4_EID_2).build();
MappingRecord sbMappingRecord = getDefaultMappingRecordBuilder().setEid(IPV4_EID_1).build();
MappingData nbMappingData = getDefaultMappingData(nbMappingRecord);
MappingData sbMappingData = getDefaultMappingData(sbMappingRecord);
// result
MappingData result = MappingMergeUtil.computeNbSbIntersection(nbMappingData, sbMappingData);
assertEquals(0, result.getRecord().getLocatorRecord().size());
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MappingMergeUtilTest method computeNbSbIntersectionTest_withMaskableIpv4PrefixEIDs.
/**
* Tests {@link MappingMergeUtil#computeNbSbIntersection} method, Nb mask less than SB mask.
*/
@Test
public void computeNbSbIntersectionTest_withMaskableIpv4PrefixEIDs() {
MappingRecord nbMappingRecord = getDefaultMappingRecordBuilder().setEid(IPV4_PREFIX_EID_2).build();
MappingRecord sbMappingRecord = getDefaultMappingRecordBuilder().setEid(IPV4_PREFIX_EID_1).build();
MappingData nbMappingData = getDefaultMappingData(nbMappingRecord);
MappingData sbMappingData = getDefaultMappingData(sbMappingRecord);
// result
MappingData result = MappingMergeUtil.computeNbSbIntersection(nbMappingData, sbMappingData);
assertEquals(IPV4_PREFIX_EID_1, result.getRecord().getEid());
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MappingMergeUtilTest method computeNbSbIntersectionTest_withMaskableSourceDestKeyEIDs_Ipv4SB.
/**
* Tests {@link MappingMergeUtil#computeNbSbIntersection} method with SourceDestKey Eid address type, Ipv4Prefix
* SB Eid, Nb mask less than SB mask.
*/
@Test
public void computeNbSbIntersectionTest_withMaskableSourceDestKeyEIDs_Ipv4SB() {
MappingRecord nbMappingRecord = getDefaultMappingRecordBuilder().setEid(SOURCE_DEST_KEY_EID_1).build();
MappingRecord sbMappingRecord = getDefaultMappingRecordBuilder().setEid(IPV4_PREFIX_EID_1).build();
MappingData nbMappingData = getDefaultMappingData(nbMappingRecord);
MappingData sbMappingData = getDefaultMappingData(sbMappingRecord);
// result
final MappingData result = MappingMergeUtil.computeNbSbIntersection(nbMappingData, sbMappingData);
final Eid eid = LispAddressUtil.asSrcDstEid(IPV4_STRING_3, IPV4_STRING_1, 24, 24, 1);
assertEquals(eid, result.getRecord().getEid());
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MappingMergeUtilTest method mappingIsExpiredTest.
/**
* Tests {@link MappingMergeUtil#mappingIsExpired} method.
*/
@Test
public void mappingIsExpiredTest() {
long timestamp = new Date().getTime();
MappingData mappingData = getDefaultMappingData();
mappingData.setTimestamp(new Date(timestamp - (REGISTRATION_VALIDITY + 1L)));
assertTrue(MappingMergeUtil.mappingIsExpired(mappingData));
mappingData.setTimestamp(new Date(timestamp));
assertFalse(MappingMergeUtil.mappingIsExpired(mappingData));
mappingData.setTimestamp(null);
assertFalse(MappingMergeUtil.mappingIsExpired(mappingData));
}
Aggregations