49b11872931ff30e5141d7522f75ba60149ec618
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / match / OxmIpv6ExtHdrDeserializerTest.java
1 /*\r
2  * Copyright (c) 2014 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 \r
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
10 \r
11 import io.netty.buffer.ByteBuf;\r
12 \r
13 import org.junit.Assert;\r
14 import org.junit.Test;\r
15 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry;\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
22 \r
23 /**\r
24  * @author michal.polkorab\r
25  *\r
26  */\r
27 public class OxmIpv6ExtHdrDeserializerTest {\r
28 \r
29     /**\r
30      * Tests {@link OxmIpv6ExtHdrDeserializer#deserialize(ByteBuf)}\r
31      */\r
32     @Test\r
33     public void test() {\r
34         ByteBuf buffer = BufferHelper.buildBuffer("80 00 4E 02 01 FF");\r
35 \r
36         buffer.skipBytes(4); // skip XID\r
37         OxmIpv6ExtHdrDeserializer deserializer = new OxmIpv6ExtHdrDeserializer();\r
38         MatchEntries entry = deserializer.deserialize(buffer);\r
39 \r
40         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass());\r
41         Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry.getOxmMatchField());\r
42         Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask());\r
43         Assert.assertEquals("Wrong entry value",\r
44                 new Ipv6ExthdrFlags(true, true, true, true, true, true, true, true, true),\r
45                 entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField());\r
46         Assert.assertEquals("Wrong entry mask", null, entry.getAugmentation(MaskMatchEntry.class));\r
47         Assert.assertTrue("Unread data", buffer.readableBytes() == 0);\r
48     }\r
49 }