use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 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.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project lispflowmapping by opendaylight.
the class MaskUtilTest method normalizeTest_withIpv4.
/**
* Tests {@link MaskUtil#normalize} method with Ipv4.
*/
@Test
public void normalizeTest_withIpv4() {
// input ip: 1.2.3.0
final Eid result = MaskUtil.normalize(EID_IPV4);
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix resultPrefix = (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix) result.getAddress();
// expected result
final String expectedResult = "1.2.3.0" + MASK_1;
assertEquals(expectedResult, resultPrefix.getIpv4Prefix().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 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.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project lispflowmapping by opendaylight.
the class ExplicitLocatorPathSerializerTest method serialize__Simple.
@Test
public void serialize__Simple() throws Exception {
List<Hop> hops = new ArrayList<Hop>();
hops.add(new HopBuilder().setAddress(SimpleAddressBuilder.getDefaultInstance("170.187.204.221")).build());
hops.add(new HopBuilder().setAddress(SimpleAddressBuilder.getDefaultInstance("17.34.51.68")).build());
ExplicitLocatorPathBuilder elpb = new ExplicitLocatorPathBuilder();
elpb.setHop(hops);
RlocBuilder rb = new RlocBuilder();
rb.setAddressType(ExplicitLocatorPathLcaf.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.ExplicitLocatorPathBuilder().setExplicitLocatorPath(elpb.build()).build());
ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(rb.build()));
LispAddressSerializer.getInstance().serialize(buf, rb.build());
ByteBuffer expectedBuf = hexToByteBuffer(//
"40 03 00 00 " + //
"0A 00 00 10 " + // IPv4
"00 00 00 01 AA BB CC DD " + // IPv4
"00 00 00 01 11 22 33 44");
ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project lispflowmapping by opendaylight.
the class InstanceIdSerializerTest method deserialize__Simple.
@Test
public void deserialize__Simple() throws Exception {
Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer(//
"40 03 00 00 " + //
"02 20 00 0A " + // instance ID
"00 BB CC DD " + // AFI=1, IP=0x11223344
"00 01 11 22 33 44"), new LispAddressSerializerContext(null));
assertEquals(Ipv4BinaryAfi.class, address.getAddressType());
Ipv4Binary ipv4 = (Ipv4Binary) address.getAddress();
assertArrayEquals(new byte[] { 0x11, 0x22, 0x33, 0x44 }, ipv4.getIpv4Binary().getValue());
assertEquals(0x00BBCCDD, address.getVirtualNetworkId().getValue().longValue());
}
Aggregations