use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder in project lispflowmapping by opendaylight.
the class MapRequestUtilTest method selectItrRlocTest_Ipv6Binary.
/**
* Tests {@link MapRequestUtil#selectItrRloc} method with Ipv6Binary.
*/
@Test
public void selectItrRlocTest_Ipv6Binary() {
final ItrRlocBuilder itrRloc = new ItrRlocBuilder().setRloc(new RlocBuilder().setAddress(IPV6_ADDRESS_BINARY).build());
final MapRequest request = new MapRequestBuilder().setItrRloc(Lists.newArrayList(itrRloc.build())).build();
// expected result
InetAddress expectedResult = InetAddresses.forString(IPV6_STRING);
// result
InetAddress result = MapRequestUtil.selectItrRloc(request);
assertEquals(expectedResult, result);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder in project lispflowmapping by opendaylight.
the class MapRequestUtilTest method selectItrRlocTest_Ipv4.
/**
* Tests {@link MapRequestUtil#selectItrRloc} method with Ipv4.
*/
@Test
public void selectItrRlocTest_Ipv4() {
final ItrRlocBuilder itrRloc = new ItrRlocBuilder().setRloc(new RlocBuilder().setAddress(IPV4_ADDRESS).build());
final MapRequest request = new MapRequestBuilder().setItrRloc(Lists.newArrayList(itrRloc.build())).build();
// expected result
InetAddress expectedResult = InetAddresses.forString(IPV4_STRING);
// result
InetAddress result = MapRequestUtil.selectItrRloc(request);
assertEquals(expectedResult, result);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder 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.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder 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.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder in project lispflowmapping by opendaylight.
the class LispAddressUtil method convertToBinary.
public static Rloc convertToBinary(Rloc rloc) {
Pair<Class<? extends LispAddressFamily>, Address> converted = convertToBinary(rloc.getAddress());
if (converted.getRight() == null) {
return rloc;
}
RlocBuilder rb = new RlocBuilder(rloc);
rb.setAddressType(converted.getLeft());
rb.setAddress(converted.getRight());
return rb.build();
}
Aggregations