use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbFirst_withServicePathDestinationAddress_singleIpv4LocatorRecord.
/**
* Tests {@link MappingSystem#getMapping} method with ServicePath type dst address and single Ipv4 type locator
* record. Returns the original mapping.
*/
@Test
public void getMappingTest_NbFirst_withServicePathDestinationAddress_singleIpv4LocatorRecord() {
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(// Ipv4 type Rloc
getDefaultLocatorRecordBuilder().build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData);
assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH));
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbFirst_withServicePathDestinationAddress_multipleLocatorRecords.
/**
* Tests {@link MappingSystem#getMapping} method with ServicePath type dst address and multiple locator record.
* Returns the original mapping.
*/
@Test
public void getMappingTest_NbFirst_withServicePathDestinationAddress_multipleLocatorRecords() {
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(// set two locators
getDefaultLocatorRecordBuilder().build(), getDefaultLocatorRecordBuilder().build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData);
assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH));
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbFirst_withServicePathDestinationAddress_singleELPLocatorRecord.
/**
* Tests {@link MappingSystem#getMapping} method with ServicePath type dst address and single ExplicitLocatorPath
* type locator record.
*/
@Test
public void getMappingTest_NbFirst_withServicePathDestinationAddress_singleELPLocatorRecord() throws UnknownHostException {
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(getDefaultLocatorRecordBuilder().setRloc(getELPTypeRloc()).build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData);
final MappingData result = (MappingData) mappingSystem.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH);
final Ipv4Binary ipv4Result = (Ipv4Binary) result.getRecord().getLocatorRecord().get(0).getRloc().getAddress();
assertTrue(Arrays.equals(InetAddress.getByName(IPV4_STRING_3).getAddress(), ipv4Result.getIpv4Binary().getValue()));
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbFirst_withNullNbMapping.
/**
* Tests {@link MappingSystem#getMapping} method with NB mapping == null, not expired mapping.
* Returns the original mapping.
*/
@Test
public void getMappingTest_NbFirst_withNullNbMapping() {
final MappingData mappingData = getDefaultMappingData();
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_IPV4_DST)).thenReturn(null);
Mockito.when(smcMock.getMapping(EID_IPV4_DST, (XtrId) null)).thenReturn(mappingData);
assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_IPV4_DST));
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MapResolverTest method isEqualIpVersionTest.
/**
* Tests {@link MapResolver#isEqualIpVersion} method.
*/
@Test
@Ignore
public void isEqualIpVersionTest() {
// input mapping
final LocatorRecordBuilder locatorRecordBuilder = getDefaultLocatorBuilder();
final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder.build());
final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
Mockito.when(mapServiceMock.getData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock);
Mockito.when(subscriberSetMock.contains(Mockito.any(Subscriber.class))).thenReturn(false);
// ----------------------
// with sourceRloc = null
List<ItrRloc> itrRlocList = Lists.newArrayList(newItrRloc(MacAfi.class, null), newItrRloc(Ipv4BinaryAfi.class, IPV4_ADDRESS));
ArgumentCaptor<Subscriber> captor = ArgumentCaptor.forClass(Subscriber.class);
mapResolver.handleMapRequest(mapRequestBuilder.setSourceRloc(null).setItrRloc(itrRlocList).build());
Mockito.verify(subscriberSetMock).add(captor.capture());
// Since mapRequest's sourceRloc is null, first ItrRloc from the itrRlocList must be used.
assertEquals(MacAfi.class, captor.getValue().getSrcRloc().getAddressType());
// ----------------------
// with sourceRloc address = itrRloc address
itrRlocList = Lists.newArrayList(newItrRloc(MacAfi.class, null), newItrRloc(Ipv4BinaryAfi.class, IPV4_ADDRESS));
MapRequest mapRequest = mapRequestBuilder.setSourceRloc(IPV4_ADDRESS_BINARY_1).setItrRloc(itrRlocList).build();
captor = ArgumentCaptor.forClass(Subscriber.class);
mapResolver.handleMapRequest(mapRequest);
Mockito.verify(subscriberSetMock, Mockito.times(2)).add(captor.capture());
assertEquals(IPV4_ADDRESS, captor.getValue().getSrcRloc().getAddress());
// ----------------------
// with sourceRloc address Afi = itrRloc address Afi (for Ipv4)
itrRlocList = Lists.newArrayList(newItrRloc(MacAfi.class, null), newItrRloc(Ipv6Afi.class, IPV6_ADDRESS), newItrRloc(Ipv4Afi.class, IPV4_ADDRESS));
mapRequest = mapRequestBuilder.setSourceRloc(IPV6_ADDRESS_BINARY).setItrRloc(itrRlocList).build();
captor = ArgumentCaptor.forClass(Subscriber.class);
mapResolver.handleMapRequest(mapRequest);
Mockito.verify(subscriberSetMock, Mockito.times(3)).add(captor.capture());
assertEquals(IPV6_ADDRESS, captor.getValue().getSrcRloc().getAddress());
// ----------------------
// with sourceRloc address Afi = itrRloc address Afi (for Ipv6)
itrRlocList = Lists.newArrayList(newItrRloc(MacAfi.class, null), newItrRloc(Ipv6Afi.class, IPV6_ADDRESS), newItrRloc(Ipv4Afi.class, IPV4_ADDRESS));
mapRequest = mapRequestBuilder.setSourceRloc(IPV4_ADDRESS_BINARY_2).setItrRloc(itrRlocList).build();
captor = ArgumentCaptor.forClass(Subscriber.class);
mapResolver.handleMapRequest(mapRequest);
Mockito.verify(subscriberSetMock, Mockito.times(4)).add(captor.capture());
assertEquals(IPV4_ADDRESS, captor.getValue().getSrcRloc().getAddress());
// ----------------------
// with no common ip address nor Afi
final Mac mac = new MacBuilder().setMac(new MacAddress("aa:bb:cc:dd:ee:ff")).build();
itrRlocList = Lists.newArrayList(newItrRloc(MacAfi.class, mac), newItrRloc(NoAddressAfi.class, Mockito.mock(NoAddress.class)));
mapRequest = mapRequestBuilder.setSourceRloc(IPV4_ADDRESS_BINARY_1).setItrRloc(itrRlocList).build();
captor = ArgumentCaptor.forClass(Subscriber.class);
mapResolver.handleMapRequest(mapRequest);
Mockito.verify(subscriberSetMock, Mockito.times(5)).add(captor.capture());
assertEquals(mac, captor.getValue().getSrcRloc().getAddress());
}
Aggregations