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.deserialization.action;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
14 import io.netty.buffer.ByteBuf;
15 import io.netty.buffer.UnpooledByteBufAllocator;
16 import org.junit.Test;
17 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
18 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
19 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
20 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
21 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
25 public class SetFieldActionDeserializerTest extends AbstractActionDeserializerTest {
28 public void testDeserialize() throws Exception {
29 final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
30 final int portNum = 0xfffffffa;
32 in.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
33 in.writeByte(OxmMatchConstants.IN_PORT << 1);
34 in.writeByte(EncodeConstants.SIZE_OF_INT_IN_BYTES);
36 in.writeZero(EncodeConstants.SIZE_OF_INT_IN_BYTES);
38 final Action action = deserializeAction(in);
39 assertTrue(action instanceof SetFieldCase);
42 .getPortLogicalName(EncodeConstants.OF13_VERSION_ID, BinContent.intToUnsignedLong(portNum)),
43 ((SetFieldCase) action).getSetField().getInPort().getValue());
44 assertEquals(0, in.readableBytes());
48 protected short getType() {
49 return ActionConstants.SET_FIELD_CODE;
53 protected short getLength() {
54 return ActionConstants.GENERAL_ACTION_LENGTH;