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