Search in sources :

Example 1 with TimeBucket

use of org.opendaylight.lispflowmapping.implementation.timebucket.containers.TimeBucket in project lispflowmapping by opendaylight.

the class TimeBucketWheelUnitTest method mappingRefreshedProperlyTest.

/**
 * Tests {@link TimeBucketWheel#refreshMappping(Eid, MappingData, long, int)} method.
 * {@link ClassCastException} can be thrown.
 */
@Test
public void mappingRefreshedProperlyTest() {
    PowerMockito.mockStatic(System.class);
    long frozenTimeStamp = System.currentTimeMillis();
    PowerMockito.when(System.currentTimeMillis()).thenReturn(frozenTimeStamp);
    TimeBucketWheel timeBucketWheel = getDefaultTimeBucketWheel();
    final int bucketId1 = timeBucketWheel.add(IPV4_EID_1, getDefaultMappingData(IPV4_EID_1), System.currentTimeMillis());
    frozenTimeStamp += 2000;
    PowerMockito.when(System.currentTimeMillis()).thenReturn(frozenTimeStamp);
    MappingData newMappingData = getDefaultMappingData(IPV4_EID_1);
    int currentBucketId = timeBucketWheel.refreshMappping(IPV4_EID_1, newMappingData, System.currentTimeMillis(), bucketId1);
    List<TimeBucket> bucketList = extractBucketList(timeBucketWheel);
    TimeBucket pastTimeBucket = bucketList.get(bucketId1);
    MappingData oldStoredMappingData = getMappingDataFromTimeBucket(pastTimeBucket, IPV4_EID_1);
    Assert.assertNull(oldStoredMappingData);
    TimeBucket presentTimeBucket = bucketList.get(currentBucketId);
    MappingData newStoredMappingData = getMappingDataFromTimeBucket(presentTimeBucket, IPV4_EID_1);
    Assert.assertEquals(newMappingData, newStoredMappingData);
}
Also used : TimeBucketWheel(org.opendaylight.lispflowmapping.implementation.timebucket.containers.TimeBucketWheel) TimeBucket(org.opendaylight.lispflowmapping.implementation.timebucket.containers.TimeBucket) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 TimeBucket (org.opendaylight.lispflowmapping.implementation.timebucket.containers.TimeBucket)1 TimeBucketWheel (org.opendaylight.lispflowmapping.implementation.timebucket.containers.TimeBucketWheel)1 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1