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.ApplyActions;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
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
34 @Test(expected=IllegalStateException.class)
36 ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04");
37 GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer();
38 Instruction instruction = deserializer.deserializeHeader(buffer);
39 Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType());
41 buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04");
42 instruction = deserializer.deserializeHeader(buffer);
43 Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType());
45 buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04");
46 instruction = deserializer.deserializeHeader(buffer);
47 Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType());
49 buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04");
50 instruction = deserializer.deserializeHeader(buffer);
51 Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType());
53 buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04");
54 instruction = deserializer.deserializeHeader(buffer);
55 Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType());
57 buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04");
58 instruction = deserializer.deserializeHeader(buffer);
59 Assert.assertEquals("Wrong type", Meter.class, instruction.getType());
61 buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04");
62 instruction = deserializer.deserializeHeader(buffer);