Merge "Add Match entry serializers"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / match / ArpOpEntrySerializerTest.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
9 package org.opendaylight.openflowplugin.impl.protocol.serialization.match;
10
11 import static org.junit.Assert.assertEquals;
12
13 import org.junit.Test;
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
15 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
19
20 public class ArpOpEntrySerializerTest extends AbstractMatchEntrySerializerTest {
21
22     @Test
23     public void testSerialize() throws Exception {
24         final int arpOp = 42;
25
26         final Match arpOpMatch = new MatchBuilder()
27                 .setLayer3Match(new ArpMatchBuilder()
28                         .setArpOp(arpOp)
29                         .build())
30                 .build();
31
32         assertMatch(arpOpMatch, false, (out) -> assertEquals(out.readShort(), arpOp));
33     }
34
35     @Override
36     protected short getLength() {
37         return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
38     }
39
40     @Override
41     protected int getOxmFieldCode() {
42         return OxmMatchConstants.ARP_OP;
43     }
44
45     @Override
46     protected int getOxmClassCode() {
47         return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
48     }
49
50 }