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