use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiListBuilder in project lispflowmapping by opendaylight.
the class AfiListSerializerTest method serialize__Simple.
@Test
public void serialize__Simple() throws Exception {
AfiListBuilder listBuilder = new AfiListBuilder();
List<SimpleAddress> addressList = new ArrayList<SimpleAddress>();
addressList.add(SimpleAddressBuilder.getDefaultInstance("170.187.204.221"));
addressList.add(SimpleAddressBuilder.getDefaultInstance("1122:3344:1122:3344:1122:3344:1122:3344"));
listBuilder.setAddressList(addressList);
RlocBuilder rb = new RlocBuilder();
rb.setAddressType(AfiListLcaf.class);
rb.setVirtualNetworkId(null);
rb.setAddress((Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AfiListBuilder().setAfiList(listBuilder.build()).build());
ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(rb.build()));
LispAddressSerializer.getInstance().serialize(buf, rb.build());
ByteBuffer expectedBuf = hexToByteBuffer(//
"40 03 00 00 " + //
"01 00 00 18 " + // IPv4
"00 01 AA BB CC DD " + "00 02 11 22 33 44 11 22 33 44 11 22 33 44 11 22 33 44");
ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiListBuilder in project lispflowmapping by opendaylight.
the class AfiListSerializerTest method serialize__NoAddresses.
@Test
public void serialize__NoAddresses() throws Exception {
AfiListBuilder listBuilder = new AfiListBuilder();
List<SimpleAddress> addressList = new ArrayList<SimpleAddress>();
listBuilder.setAddressList(addressList);
RlocBuilder rb = new RlocBuilder();
rb.setAddressType(AfiListLcaf.class);
rb.setVirtualNetworkId(null);
rb.setAddress((Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AfiListBuilder().setAfiList(listBuilder.build()).build());
ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(rb.build()));
LispAddressSerializer.getInstance().serialize(buf, rb.build());
ByteBuffer expectedBuf = hexToByteBuffer(//
"40 03 00 00 " + "01 00 00 00");
ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiListBuilder in project lispflowmapping by opendaylight.
the class AfiListSerializerTest method equals__Simple.
@Test
public void equals__Simple() throws Exception {
final SimpleAddress ip1 = SimpleAddressBuilder.getDefaultInstance("0:0:0:0:0:0:0:1");
final SimpleAddress ip2 = SimpleAddressBuilder.getDefaultInstance("0:0:0:0:0:0:0:2");
AfiListBuilder listBuilder = new AfiListBuilder().setAddressList(new ArrayList<SimpleAddress>());
listBuilder.getAddressList().add(ip1);
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiList address1 = listBuilder.build();
listBuilder.setAddressList(new ArrayList<SimpleAddress>());
listBuilder.getAddressList().add(ip1);
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiList address2 = listBuilder.build();
listBuilder.setAddressList(new ArrayList<SimpleAddress>());
listBuilder.getAddressList().add(ip2);
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiList address3 = listBuilder.build();
assertEquals(address1, address2);
Assert.assertNotEquals(address2, address3);
Assert.assertNotEquals(address1, address3);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiListBuilder in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAndQuery__ListLCAF.
public void registerAndQuery__ListLCAF() throws SocketTimeoutException {
cleanUP();
String macString = "01:02:03:04:05:06";
String ipString = "10.20.255.30";
List<SimpleAddress> addresses = new ArrayList<SimpleAddress>();
addresses.add(new SimpleAddress(new IpAddress(new Ipv4Address(ipString))));
addresses.add(new SimpleAddress(new MacAddress(macString)));
AfiListBuilder listbuilder = new AfiListBuilder();
listbuilder.setAddressList(addresses);
EidBuilder eb = new EidBuilder();
eb.setAddressType(AfiListLcaf.class);
eb.setVirtualNetworkId(null);
eb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AfiListBuilder().setAfiList(listbuilder.build()).build());
MapReply reply = registerAddressAndQuery(eb.build());
Eid receivedAddress = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
assertEquals(AfiListLcaf.class, receivedAddress.getAddressType());
AfiList listAddrFromNetwork = (AfiList) receivedAddress.getAddress();
SimpleAddress receivedAddr1 = (SimpleAddress) listAddrFromNetwork.getAfiList().getAddressList().get(0);
SimpleAddress receivedAddr2 = (SimpleAddress) listAddrFromNetwork.getAfiList().getAddressList().get(1);
assertNotNull(receivedAddr1.getIpAddress().getIpv4Address());
assertNotNull(receivedAddr2.getMacAddress());
assertEquals(macString, receivedAddr2.getMacAddress().getValue());
assertEquals(ipString, receivedAddr1.getIpAddress().getIpv4Address().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiListBuilder in project lispflowmapping by opendaylight.
the class AfiListSerializer method deserializeData.
private Address deserializeData(ByteBuffer buffer, short lcafLength, LispAddressSerializerContext ctx) {
List<SimpleAddress> addresses = new ArrayList<SimpleAddress>();
short length = lcafLength;
while (length > 0) {
SimpleAddress address = SimpleAddressSerializer.getInstance().deserialize(buffer, ctx);
length -= SimpleAddressSerializer.getInstance().getAddressSize(address);
addresses.add(address);
}
return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AfiListBuilder().setAfiList(new AfiListBuilder().setAddressList(addresses).build()).build();
}
Aggregations