a51cc1226be3830187f746f13e2f105370bef337
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / match / OxmVlanVidDeserializerTest.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.VlanVidMatchEntry;\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
20 \r
21 /**\r
22  * @author michal.polkorab\r
23  *\r
24  */\r
25 public class OxmVlanVidDeserializerTest {\r
26 \r
27     /**\r
28      * Tests {@link OxmVlanVidDeserializer#deserialize(ByteBuf)}\r
29      */\r
30     @Test\r
31     public void test() {\r
32         ByteBuf buffer = BufferHelper.buildBuffer("80 00 0C 02 20 0A");\r
33 \r
34         buffer.skipBytes(4); // skip XID\r
35         OxmVlanVidDeserializer deserializer = new OxmVlanVidDeserializer();\r
36         MatchEntries entry = deserializer.deserialize(buffer);\r
37 \r
38         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass());\r
39         Assert.assertEquals("Wrong entry field", VlanVid.class, entry.getOxmMatchField());\r
40         Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask());\r
41         Assert.assertEquals("Wrong entry value", 10,\r
42                 entry.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue());\r
43         Assert.assertEquals("Wrong entry value", false, \r
44                 entry.getAugmentation(VlanVidMatchEntry.class).isCfiBit());\r
45     }\r
46 }