Search in sources :

Example 1 with MapReplyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder in project lispflowmapping by opendaylight.

the class MapReplySerializationTest method serialize__MultipleRecordsWithoutRLOCs.

@Test
public void serialize__MultipleRecordsWithoutRLOCs() throws Exception {
    MapReplyBuilder mrBuilder = new MapReplyBuilder();
    mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
    recordBuilder.setEid(LispAddressUtil.asIpv6PrefixEid("0:0:0:0:0:0:0:8/128"));
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
    recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("8.2.4.5/32"));
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
    ByteBuffer packet = MapReplySerializer.getInstance().serialize(mrBuilder.build());
    assertEquals(2, packet.get(3));
    // EID in first record
    packet.position(24);
    byte[] expected = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 };
    byte[] actual = new byte[16];
    packet.get(actual);
    ArrayAssert.assertEquals(expected, actual);
    // EID in second record
    packet.position(packet.position() + 12);
    assertEquals(0x08020405, packet.getInt());
}
Also used : MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 2 with MapReplyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder in project lispflowmapping by opendaylight.

the class MapReplySerializationTest method serialize__EidRecordDefaultAction.

@Test
public void serialize__EidRecordDefaultAction() throws Exception {
    MapReplyBuilder mrBuilder = new MapReplyBuilder();
    mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
    recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"));
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
    ByteBuffer packet = MapReplySerializer.getInstance().serialize(mrBuilder.build());
    packet.position(18);
    // MapReplyAction.NoAction
    assertHexEquals((byte) 0x00, packet.get());
}
Also used : MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 3 with MapReplyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder in project lispflowmapping by opendaylight.

the class MapReplySerializationTest method serialize__EidRecordFields.

@Test
public void serialize__EidRecordFields() throws Exception {
    MapReplyBuilder mrBuilder = new MapReplyBuilder();
    mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    MappingRecordBuilder eidToLocator1 = new MappingRecordBuilder();
    eidToLocator1.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"));
    eidToLocator1.setRecordTtl(7);
    eidToLocator1.setAction(Action.SendMapRequest);
    eidToLocator1.setAuthoritative(true);
    eidToLocator1.setMapVersion((short) 3072);
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(eidToLocator1.build()).build());
    MappingRecordBuilder eidToLocator2 = new MappingRecordBuilder();
    eidToLocator2.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.7/32"));
    eidToLocator2.setRecordTtl(1000000);
    eidToLocator2.setAction(Action.Drop);
    eidToLocator2.setAuthoritative(false);
    eidToLocator2.setMapVersion((short) 29);
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(eidToLocator2.build()).build());
    ByteBuffer packet = MapReplySerializer.getInstance().serialize(mrBuilder.build());
    // First record
    packet.position(12);
    assertEquals(7, packet.getInt());
    // skip Locator Count & Mask-len
    packet.position(packet.position() + 2);
    assertHexEquals((byte) 0x50, packet.get());
    // skip Reserved byte
    packet.position(packet.position() + 1);
    assertEquals((short) 3072, packet.getShort());
    // Second record
    packet.position(packet.position() + 6);
    assertEquals(1000000, packet.getInt());
    // skip Locator Count & Mask-len
    packet.position(packet.position() + 2);
    assertHexEquals((byte) 0x60, packet.get());
    // skip Reserved byte
    packet.position(packet.position() + 1);
    assertEquals((short) 29, packet.getShort());
}
Also used : MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 4 with MapReplyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder in project lispflowmapping by opendaylight.

the class LispMappingServiceTest method onRequestMappingTest.

/**
 * Tests {@link LispMappingService#onRequestMapping} method.
 */
@Test
public void onRequestMappingTest() {
    final RequestMapping requestMapping = Mockito.mock(RequestMapping.class);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest mapRequest = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest.class);
    final MapReply mapReply = new MapReplyBuilder().build();
    Mockito.when(requestMapping.getMapRequest()).thenReturn(mapRequest);
    Mockito.when(requestMapping.getTransportAddress()).thenReturn(TRANSPORT_ADDRESS_1);
    Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
    Mockito.when(tlsMapReplyMock.get()).thenReturn(mapReply);
    // result
    final SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder().setMapReply(new MapReplyBuilder(mapReply).build()).setTransportAddress(TRANSPORT_ADDRESS_1);
    lispMappingService.onRequestMapping(requestMapping);
    Mockito.verify(odlLispSbService).sendMapReply(smrib.build());
}
Also used : SendMapReplyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyInputBuilder) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) RequestMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.RequestMapping) XtrRequestMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrRequestMapping) Test(org.junit.Test)

Example 5 with MapReplyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder in project lispflowmapping by opendaylight.

the class LispMappingServiceTest method handleMapRequestTest.

/**
 * Tests {@link LispMappingService#handleMapRequest} method.
 */
@Test
public void handleMapRequestTest() {
    final MapRequest mapRequest = Mockito.mock(MapRequest.class);
    final MapReply mapReply = new MapReplyBuilder().build();
    Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
    Mockito.when(tlsMapRequestMock.get()).thenReturn(null);
    Mockito.when(tlsMapReplyMock.get()).thenReturn(mapReply);
    final MapReply result = lispMappingService.handleMapRequest(mapRequest);
    Mockito.verify(tlsMapRequestMock).set(null);
    Mockito.verify(tlsMapRequestMock).get();
    Mockito.verifyNoMoreInteractions(tlsMapRequestMock);
    Mockito.verify(mapResolverMock).handleMapRequest(mapRequest);
    Mockito.verify(tlsMapReplyMock).set(Mockito.any(MapReply.class));
    Mockito.verify(tlsMapReplyMock).get();
    assertEquals(result, mapReply);
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequest) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) Test(org.junit.Test)

Aggregations

MapReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)19 Test (org.junit.Test)16 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)15 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)15 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)8 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)8 ByteBuffer (java.nio.ByteBuffer)7 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)7 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)4 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)3 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)3 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)3 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)3 ItrRlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder)3 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)3 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)3 ArrayList (java.util.ArrayList)2 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 EidItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem)2