Merge "Mdsal utils bundle"
[netvirt.git] / plugin-mdsal-adapter / src / test / java / org / opendaylight / ovsdb / plugin / md / UtilsTest.java
1 package org.opendaylight.ovsdb.plugin.md;
2
3 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
4
5 import org.junit.Assert;
6 import org.junit.Test;
7
8 import java.net.Inet4Address;
9 import java.net.Inet6Address;
10 import java.net.InetAddress;
11 import java.net.UnknownHostException;
12
13 public class UtilsTest {
14
15     static final String IPV4_ADDRESS = "10.10.10.10";
16     static final String IPV6_ADDRESS = "2001:db8:0:0:0:ff00:42:8329";
17
18     @Test
19     public void testConvertIpAddress() throws UnknownHostException {
20
21         InetAddress addressV4 = Inet4Address.getByName(IPV4_ADDRESS);
22         InetAddress addressV6 = Inet6Address.getByName(IPV6_ADDRESS);
23
24         IpAddress ipAddresV4 = Utils.convertIpAddress(addressV4);
25         IpAddress ipAddresV6 = Utils.convertIpAddress(addressV6);
26
27         Assert.assertEquals(IPV4_ADDRESS, ipAddresV4.getIpv4Address().getValue());
28         Assert.assertEquals(IPV6_ADDRESS, ipAddresV6.getIpv6Address().getValue());
29     }
30 }