Remove EncodeConstants.SIZE_OF_{BYTE,SHORT,INT,LONG}_IN_BYTES
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / deserialization / match / UdpDestinationPortEntryDeserializerTest.java
1 /*
2  * Copyright (c) 2016 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.openflowplugin.impl.protocol.deserialization.match;
9
10 import static org.junit.Assert.assertEquals;
11
12 import io.netty.buffer.ByteBuf;
13 import io.netty.buffer.UnpooledByteBufAllocator;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
17
18 public class UdpDestinationPortEntryDeserializerTest extends AbstractMatchEntryDeserializerTest {
19     @Test
20     public void deserializeEntry() {
21         final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
22         final int port = 22;
23
24         writeHeader(in, false);
25         in.writeShort(port);
26
27         assertEquals(port, ((UdpMatch) deserialize(in).getLayer4Match()).getUdpDestinationPort().getValue()
28                 .intValue());
29         assertEquals(0, in.readableBytes());
30     }
31
32     @Override
33     protected int getOxmClassCode() {
34         return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
35     }
36
37     @Override
38     protected int getOxmFieldCode() {
39         return OxmMatchConstants.UDP_DST;
40     }
41
42     @Override
43     protected int getValueLength() {
44         return Short.BYTES;
45     }
46 }