2 * Copyright (c) 2017 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.multipart.tablefeatures;
11 import static org.junit.Assert.assertEquals;
13 import com.google.common.collect.ImmutableList;
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.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfieldBuilder;
26 public class MatchTablePropertySerializerTest extends AbstractTablePropertySerializerTest {
29 public void testSerialize() {
30 final Match property = new MatchBuilder()
31 .setMatchSetfield(new MatchSetfieldBuilder()
32 .setSetFieldMatch(ImmutableList
33 .<SetFieldMatch>builder()
34 .add(new SetFieldMatchBuilder()
35 .setMatchType(ArpOp.class)
42 assertProperty(property, out -> {
43 assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS);
44 assertEquals(out.readUnsignedByte(), OxmMatchConstants.ARP_OP << 1);
45 out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); // Skip match entry length
50 protected Class<? extends TableFeaturePropType> getClazz() {
55 protected int getType() {
56 return TableFeaturesPropType.OFPTFPTMATCH.getIntValue();