use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromIpAddress_ipv4.
/**
* Tests {@link LispAddressUtil#addressFromIpAddress(IpAddress)} and {@link
* LispAddressUtil#addressTypeFromIpAddress(IpAddress)}
* methods with ipv4 address.
*/
@Test
public void addressFromIpAddress_ipv4() {
final IpAddress ipv4Address = new IpAddress(IPV4_ADDRESS_TEST);
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromIpAddress(ipv4Address);
assertEquals(Ipv4Afi.class, addressClass);
final Address address = LispAddressUtil.addressFromIpAddress(ipv4Address);
assertTrue(address instanceof Ipv4);
assertEquals(IPV4_ADDRESS_VALUE_TEST, ((Ipv4) address).getIpv4().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method convertToBinaryTest_eid.
/**
* Tests {@link LispAddressUtil#convertToBinary(Eid)} method with ipv4Prefix, ipv6Prefix, ipv4, ipv6.
*/
@Test
public void convertToBinaryTest_eid() {
final Eid ipv4PrefixEid = new EidBuilder().setAddress(IPV4_PREFIX).build();
final Eid ipv6PrefixEid = new EidBuilder().setAddress(IPV6_PREFIX).build();
final Eid ipv4 = new EidBuilder().setAddress(IPV4).build();
final Eid ipv6 = new EidBuilder().setAddress(IPV6).build();
Eid resultIpv4PrefixBinary = LispAddressUtil.convertToBinary(ipv4PrefixEid);
verifyToEidWithIpv4PrefixBinary(resultIpv4PrefixBinary, false, MASK_OK_TEST, Ipv4PrefixBinaryAfi.class);
Eid resultIpv6PrefixBinary = LispAddressUtil.convertToBinary(ipv6PrefixEid);
verifyToEidWithIpv6PrefixBinary(resultIpv6PrefixBinary, false, MASK_OK_TEST, Ipv6PrefixBinaryAfi.class);
Eid resultIpv4Binary = LispAddressUtil.convertToBinary(ipv4);
verifyToEidWithIpv4Binary(resultIpv4Binary, false);
Eid resultIpv6Binary = LispAddressUtil.convertToBinary(ipv6);
verifyToEidWithIpv6Binary(resultIpv6Binary, false);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method binaryAddressFromInet_ipv4.
/**
* Tests {@link LispAddressUtil#binaryAddressFromInet(InetAddress)} and
* {@link LispAddressUtil#binaryAddressTypeFromInet(InetAddress)} methods with ipv4 address.
*/
@Test
public void binaryAddressFromInet_ipv4() throws UnknownHostException {
final InetAddress ipv4InetAddress = Inet4Address.getByAddress(IPV4_ADDRESS_BYTES_A_TEST);
Class<? extends LispAddressFamily> addressClass = LispAddressUtil.binaryAddressTypeFromInet(ipv4InetAddress);
assertEquals(Ipv4BinaryAfi.class, addressClass);
final Address address = LispAddressUtil.binaryAddressFromInet(ipv4InetAddress);
assertTrue(address instanceof Ipv4Binary);
assertArrayEquals(IPV4_ADDRESS_BYTES_A_TEST, ((Ipv4Binary) address).getIpv4Binary().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method toRloc.
/**
* Tests:
* - {@link LispAddressUtil#toRloc(InetAddress)}
* - {@link LispAddressUtil#toRloc(Ipv4Address)}
* - {@link LispAddressUtil#toRloc(Ipv6Address)}
* - {@link LispAddressUtil#toRloc(SimpleAddress)}
* methods.
*/
@Test
public void toRloc() throws UnknownHostException {
InetAddress ipv4AddressInet = Inet4Address.getByAddress(IPV4_ADDRESS_BYTES_A_TEST);
final Rloc rlocFromInetAddress = LispAddressUtil.toRloc(ipv4AddressInet);
assertEquals(Ipv4BinaryAfi.class, rlocFromInetAddress.getAddressType());
assertEquals(IPV4_ADDRESS_BINARY_TEST, ((Ipv4Binary) rlocFromInetAddress.getAddress()).getIpv4Binary());
final Rloc rlocFromIpv4Address = LispAddressUtil.toRloc(IPV4_ADDRESS_TEST);
assertEquals(Ipv4Afi.class, rlocFromIpv4Address.getAddressType());
assertEquals(IPV4_ADDRESS_VALUE_TEST, ((Ipv4) rlocFromIpv4Address.getAddress()).getIpv4().getValue());
final Rloc rlocFromIpv6Address = LispAddressUtil.toRloc(IPV6_ADDRESS_TEST);
assertEquals(Ipv6Afi.class, rlocFromIpv6Address.getAddressType());
assertEquals(IPV6_ADDRESS_VALUE_TEST, ((Ipv6) rlocFromIpv6Address.getAddress()).getIpv6().getValue());
final Rloc rlocFromSimpleAddress = LispAddressUtil.toRloc(SIMPLE_ADDRESS_IPV4_TEST);
assertEquals(Ipv4BinaryAfi.class, rlocFromSimpleAddress.getAddressType());
assertEquals(IPV4_ADDRESS_BINARY_TEST, ((Ipv4Binary) rlocFromSimpleAddress.getAddress()).getIpv4Binary());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4 in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method convertFromBinaryTest_eid.
/**
* Tests {@link LispAddressUtil#convertToBinary(Eid)} method with ipv4Prefix, ipv6Prefix, ipv4, ipv6.
*/
@Test
public void convertFromBinaryTest_eid() {
final Eid resultIpv4Prefix = LispAddressUtil.convertFromBinary(IPV4_ADDRESS_PREFIX_BINARY_EID_1);
verifyToEidWithIpv4Prefix(resultIpv4Prefix, false, MASK_OK_TEST, Ipv4PrefixAfi.class);
final Eid resultIpv6Prefix = LispAddressUtil.convertFromBinary(IPV6_ADDRESS_PREFIX_BINARY_EID_1);
verifyToEidWithIpv6Prefix(resultIpv6Prefix, false, MASK_OK_TEST, Ipv6PrefixAfi.class);
final Eid resultIpv4 = LispAddressUtil.convertFromBinary(IPV4_ADDRESS_BINARY_EID);
verifyToEidWithIpv4(resultIpv4, false);
final Eid resultIpv6 = LispAddressUtil.convertFromBinary(IPV6_ADDRESS_BINARY_EID);
verifyToEidWithIpv6(resultIpv6, false);
}
Aggregations