2 * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
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
9 package org.opendaylight.openflowplugin.impl.protocol.serialization.match;
11 import static org.junit.Assert.assertArrayEquals;
12 import static org.junit.Assert.assertEquals;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
16 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
17 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder;
22 public class TcpFlagsEntrySerializerTest extends AbstractExperimenterMatchEntrySerializerTest {
25 public void testSerialize() throws Exception {
27 final byte[] tcpMask = new byte[] { 30, 30 };
29 final Match tcpFlagsMatch = new MatchBuilder()
30 .setTcpFlagsMatch(new TcpFlagsMatchBuilder()
32 .setTcpFlagsMask(ByteUtil.bytesToUnsignedShort(tcpMask))
36 assertMatch(tcpFlagsMatch, true, (out) -> {
37 assertEquals(out.readUnsignedShort(), tcp);
39 byte[] mask = new byte[2];
41 assertArrayEquals(mask, tcpMask);
44 final Match tcpFlagsMatchNoMask = new MatchBuilder()
45 .setTcpFlagsMatch(new TcpFlagsMatchBuilder()
50 assertMatch(tcpFlagsMatchNoMask, false, (out) -> assertEquals(out.readUnsignedShort(), tcp));
54 protected short getLength() {
55 return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
59 protected int getOxmFieldCode() {
60 return EncodeConstants.ONFOXM_ET_TCP_FLAGS;
64 protected int getOxmClassCode() {
65 return OxmMatchConstants.EXPERIMENTER_CLASS;
69 protected long getExperimenterId() {
70 return EncodeConstants.ONF_EXPERIMENTER_ID;