2 * Copyright (c) 2014 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.openflowjava.protocol.impl.deserialization.instruction;
11 import io.netty.buffer.ByteBuf;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.util.ByteBufUtils;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
25 * @author michal.polkorab
28 public class AbstractInstructionDeserializerTest {
31 * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different
36 ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04");
37 Instruction instruction = new GoToTableInstructionDeserializer().deserializeHeader(buffer);
38 Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof GotoTableCase);
40 buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04");
41 instruction = new WriteMetadataInstructionDeserializer().deserializeHeader(buffer);
42 Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof WriteMetadataCase);
44 buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04");
45 instruction = new WriteActionsInstructionDeserializer().deserializeHeader(buffer);
46 Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof WriteActionsCase);
48 buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04");
49 instruction = new ApplyActionsInstructionDeserializer().deserializeHeader(buffer);
50 Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof ApplyActionsCase);
52 buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04");
53 instruction = new ClearActionsInstructionDeserializer().deserializeHeader(buffer);
54 Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof ClearActionsCase);
56 buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04");
57 instruction = new MeterInstructionDeserializer().deserializeHeader(buffer);
58 Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof MeterCase);