Search in sources :

Example 26 with MappingData

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);
}
Also used : TimeBucketWheel(org.opendaylight.lispflowmapping.implementation.timebucket.containers.TimeBucketWheel) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 27 with 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());
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Test(org.junit.Test)

Example 28 with MappingData

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());
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Test(org.junit.Test)

Example 29 with MappingData

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());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Test(org.junit.Test)

Example 30 with MappingData

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));
}
Also used : MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Date(java.util.Date) Test(org.junit.Test)

Aggregations

MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)69 Test (org.junit.Test)40 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)30 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)17 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)14 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)11 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)9 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)9 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)7 MapReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)7 ArrayList (java.util.ArrayList)5 Ignore (org.junit.Ignore)5 Date (java.util.Date)4 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)4 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)4 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)4 Set (java.util.Set)3 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)3 IRowVisitor (org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor)3