Search in sources :

Example 1 with InstructionDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey in project openflowplugin by opendaylight.

the class CodeKeyMakerFactoryTest method testExperimenterInstructionKeyMaker.

/**
 * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)}.
 */
@Test
public void testExperimenterInstructionKeyMaker() {
    CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
    Assert.assertNotNull("Null key maker", keyMaker);
    ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01");
    // skip XID
    buffer.skipBytes(4);
    MessageCodeKey codeKey = keyMaker.make(buffer);
    Assert.assertNotNull("Null key", codeKey);
    Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 65535, 1L), codeKey);
    Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes());
}
Also used : MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) ByteBuf(io.netty.buffer.ByteBuf) InstructionDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey) Test(org.junit.Test)

Example 2 with InstructionDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey in project openflowplugin by opendaylight.

the class CodeKeyMakerFactoryTest method testInstructionKeyMaker.

/**
 * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)}.
 */
@Test
public void testInstructionKeyMaker() {
    CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
    Assert.assertNotNull("Null key maker", keyMaker);
    ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 08");
    // skip XID
    buffer.skipBytes(4);
    MessageCodeKey codeKey = keyMaker.make(buffer);
    Assert.assertNotNull("Null key", codeKey);
    Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0, null), codeKey);
    Assert.assertEquals("Buffer index modified", 4, buffer.readableBytes());
}
Also used : MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) ByteBuf(io.netty.buffer.ByteBuf) InstructionDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 InstructionDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey)2 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)2