X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fdeserialization%2Finstruction%2FAbstractInstructionDeserializerTest.java;h=b7a76b4262b43f0404e1be367aa90b892f4b8ec1;hb=519a86d1ddcfb8f0fe264174e62e5424e1efba1f;hp=dcfbe924261c71b1a0624862caa4c9c6d326429a;hpb=3dda40723d3799a818bcad9b5eddc725ae63d946;p=openflowjava.git diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java index dcfbe924..b7a76b42 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class AbstractInstructionDeserializerTest { - - /** - * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different - * instruction types - */ - @Test(expected=IllegalStateException.class) - public void test() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04"); - GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer(); - Instruction instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", Meter.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04"); - instruction = deserializer.deserializeHeader(buffer); - // exception expected - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class AbstractInstructionDeserializerTest { + + /** + * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different + * instruction types + */ + @Test(expected=IllegalStateException.class) + public void test() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04"); + GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer(); + Instruction instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", Meter.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04"); + instruction = deserializer.deserializeHeader(buffer); + // exception expected + } } \ No newline at end of file