b0f78bc3bf3a45ba39afc663b06e49f8b24fc928
[lispflowmapping.git] / mappingservice / implementation / src / test / java / org / opendaylight / lispflowmapping / implementation / serializer / address / LispIpv6AddressTest.java
1 /*
2  * Copyright (c) 2014 Contextream, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.lispflowmapping.implementation.serializer.address;
10
11 import static org.junit.Assert.assertEquals;
12
13 import org.junit.Test;
14 import org.opendaylight.lispflowmapping.implementation.util.LispAFIConvertor;
15 import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
16 import org.opendaylight.lispflowmapping.type.AddressFamilyNumberEnum;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.lispaddress.lispaddresscontainer.address.ipv6.Ipv6Address;
18
19 public class LispIpv6AddressTest extends BaseTestCase {
20
21     @Test
22     public void constructor__Name() throws Exception {
23         Ipv6Address ip = (Ipv6Address) LispAFIConvertor.asIPv6AfiAddress("0:0:0:0:0:0:0:0");
24
25         assertEquals(AddressFamilyNumberEnum.IP6.getIanaCode(), ip.getAfi().shortValue());
26         assertEquals(18, LispAddressSerializer.getInstance().getAddressSize(ip));
27         assertEquals("0:0:0:0:0:0:0:0", ip.getIpv6Address().getValue());
28     }
29
30     @Test
31     public void constructor__Buffer() throws Exception {
32         Ipv6Address ip = (Ipv6Address) LispAFIConvertor.asIPv6AfiAddress("0:0:0:0:0:0:0:1");
33
34         assertEquals(AddressFamilyNumberEnum.IP6.getIanaCode(), ip.getAfi().shortValue());
35         assertEquals(18, LispAddressSerializer.getInstance().getAddressSize(ip));
36         assertEquals("0:0:0:0:0:0:0:1", ip.getIpv6Address().getValue());
37     }
38 }