use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class LispSouthboundHandlerTest method mapRegister__TwoRlocs.
@Test
public void mapRegister__TwoRlocs() throws Exception {
// P Bit & M Bit set
// EID prefix: 172.1.1.2/32, TTL: 10, Authoritative, No-Action
// Local RLOC: 10.1.0.110, Reachable, Priority/Weight: 1/100, Multicast
// Priority/Weight: 255/0
// Local RLOC: 192.168.136.51, Reachable, Priority/Weight: 6/100,
// Multicast Priority/Weight: 255/0
mapRegisterPacket = extractWSUdpByteArray("0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 " + "0010 00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 " + "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 " + "0030 00 00 00 00 00 00 00 01 00 14 ae d8 7b d4 9c 59 " + "0040 e9 35 75 6e f1 29 27 a3 45 20 96 06 c2 e1 00 00 " + "0050 00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 01 64 " + "0060 ff 00 00 05 00 01 0a 01 00 6e 06 64 ff 00 00 05 " + "0070 00 01 c0 a8 88 33");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(mapRegisterPacket);
Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
List<MappingRecordItem> eidRecords = captor.getValue().getMapRegister().getMappingRecordItem();
assertEquals(1, eidRecords.size());
MappingRecord eidRecord = eidRecords.get(0).getMappingRecord();
assertEquals(2, eidRecord.getLocatorRecord().size());
assertEquals(LispAddressUtil.asIpv4Rloc("10.1.0.110"), eidRecord.getLocatorRecord().get(0).getRloc());
assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.51"), eidRecord.getLocatorRecord().get(1).getRloc());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class LispSouthboundHandlerTest method mapRegister_isMappingKeepAliveAndMapNotifyGenerated.
/**
* Tests whether handling of map-register message will generate mapping-keep-alive notification.
*/
@Test
public void mapRegister_isMappingKeepAliveAndMapNotifyGenerated() throws InterruptedException, UnknownHostException {
byte[] eidPrefixAfi = new byte[] { // eid-prefix-afi
0x00, 0x01 };
byte[] eidPrefix = new byte[] { // ipv4 address
0x0a, 0x0a, 0x0a, 0x0a };
// send stream of byte -> map register message
InOrder inOrder = Mockito.inOrder(mockLispSouthboundPlugin);
final MapRegisterCacheKey cacheKey = MapRegisterCacheTestUtil.createMapRegisterCacheKey(eidPrefix);
MapRegisterCacheTestUtil.beforeMapRegisterInvocationValidation(cacheKey, mapRegisterCache);
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
mapRegisterInvocationForCacheTest(eidPrefixAfi, eidPrefix);
inOrder.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
MapRegisterCacheTestUtil.afterMapRegisterInvocationValidation(cacheKey, mapRegisterCache, eidPrefixAfi, eidPrefix);
// sending the same byte stream -> map register second time
captor = ArgumentCaptor.forClass(AddMapping.class);
mapRegisterInvocationForCacheTest(eidPrefixAfi, eidPrefix);
inOrder.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
// mapping-keep-alive message should be generated
MapRegisterCacheTestUtil.afterSecondMapRegisterInvocationValidation(mockLispSouthboundPlugin, eidPrefixAfi, eidPrefix);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class HostInformationManagerTest method testScenarioPortDataFirst.
@Test
public void testScenarioPortDataFirst() {
HostInformationManager hostInformationManager = getDefaultHostInformationManager();
addPortData1(hostInformationManager);
Mockito.verify(lfmDbService, Mockito.times(0)).addMapping(Mockito.any(AddMappingInput.class));
addRlocData(hostInformationManager);
AddMappingInput desiredMappingRecord = createAddMappingInput(SAMPLE_RLOC, SAMPLE_EID_1);
Mockito.verify(lfmDbService).addMapping(desiredMappingRecord);
destroySingleton(hostInformationManager);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class HostInformationManagerTest method testScenarioRlocFirst.
@Test
public void testScenarioRlocFirst() {
HostInformationManager hostInformationManager = getDefaultHostInformationManager();
addRlocData(hostInformationManager);
Mockito.verify(lfmDbService, Mockito.times(0)).addMapping(Mockito.any(AddMappingInput.class));
addPortData1(hostInformationManager);
AddMappingInput desiredMappingRecord = createAddMappingInput(SAMPLE_RLOC, SAMPLE_EID_1);
Mockito.verify(lfmDbService).addMapping(desiredMappingRecord);
destroySingleton(hostInformationManager);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class LispMappingServiceTest method onAddMappingTest_noTransportAddress.
/**
* Tests {@link LispMappingService#onAddMapping} method with no TransportAddress.
*/
@Test
public void onAddMappingTest_noTransportAddress() {
final org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegister mapRegister = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegister.class);
final AddMapping addMapping = Mockito.mock(AddMapping.class);
final MapNotify mapNotify = new MapNotifyBuilder().setKeyId((short) 1).build();
Mockito.when(addMapping.getMapRegister()).thenReturn(mapRegister);
Mockito.when(mapRegister.getMappingRecordItem()).thenReturn(Lists.newArrayList(MAPPING_RECORD_ITEM_BUILDER.build()));
Mockito.when(tlsMapNotifyMock.get()).thenReturn(new MutablePair<>(mapNotify, null));
Mockito.when(addMapping.getTransportAddress()).thenReturn(TRANSPORT_ADDRESS_1);
// result
final SendMapNotifyInputBuilder smnib = new SendMapNotifyInputBuilder().setMapNotify(new org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder().setKeyId((short) 1).build()).setTransportAddress(TRANSPORT_ADDRESS);
lispMappingService.onAddMapping(addMapping);
Mockito.verify(odlLispSbService).sendMapNotify(smnib.build());
}
Aggregations