Fixed ipv6 address deserialization in match
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / util / MatchDeserializerTest.java
1 /*\r
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.openflowjava.protocol.impl.util;\r
9 \r
10 import io.netty.buffer.ByteBuf;\r
11 \r
12 import java.util.List;\r
13 \r
14 import org.junit.Assert;\r
15 import org.junit.Test;\r
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;\r
21 \r
22 /**\r
23  * @author michal.polkorab\r
24  *\r
25  */\r
26 public class MatchDeserializerTest {\r
27     \r
28     /**\r
29      * Testing match deserialization\r
30      */\r
31     @Test\r
32     public void testIpv4Address() {\r
33         ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03");\r
34         \r
35         List<MatchEntries> list = MatchDeserializer.createMatchEntry(buffer, 8);\r
36         MatchEntries entry = list.get(0);\r
37         Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"),\r
38                 entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
39     }\r
40     \r
41     /**\r
42      * Testing match deserialization\r
43      */\r
44     @Test\r
45     public void testIpv6Address() {\r
46         ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07");\r
47         \r
48         List<MatchEntries> list = MatchDeserializer.createMatchEntry(buffer, 20);\r
49         MatchEntries entry = list.get(0);\r
50         Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"),\r
51                 entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
52     }\r
53 \r
54 }\r