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