2 * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
\r
11 import io.netty.buffer.ByteBuf;
\r
13 import org.junit.Assert;
\r
14 import org.junit.Test;
\r
15 import org.opendaylight.openflowjava.util.ByteBufUtils;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
\r
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
\r
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
\r
25 * @author michal.polkorab
\r
28 public class AbstractInstructionDeserializerTest {
\r
31 * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different
\r
34 @Test(expected=IllegalStateException.class)
\r
35 public void test() {
\r
36 ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04");
\r
37 GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer();
\r
38 Instruction instruction = deserializer.deserializeHeader(buffer);
\r
39 Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType());
\r
41 buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04");
\r
42 instruction = deserializer.deserializeHeader(buffer);
\r
43 Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType());
\r
45 buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04");
\r
46 instruction = deserializer.deserializeHeader(buffer);
\r
47 Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType());
\r
49 buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04");
\r
50 instruction = deserializer.deserializeHeader(buffer);
\r
51 Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType());
\r
53 buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04");
\r
54 instruction = deserializer.deserializeHeader(buffer);
\r
55 Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType());
\r
57 buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04");
\r
58 instruction = deserializer.deserializeHeader(buffer);
\r
59 Assert.assertEquals("Wrong type", Meter.class, instruction.getType());
\r
61 buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04");
\r
62 instruction = deserializer.deserializeHeader(buffer);
\r
63 // exception expected
\r