Search in sources :

Example 61 with MessageCodeKey

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

the class DefaultDeserializerFactoryTest method testHeaderVersions.

/**
 * Test correct version after deserialization for all supported OF versions.
 * @param versions supported OF versions
 * @param buffer byte buffer to deserialze
 */
protected void testHeaderVersions(final List<Byte> versions, final ByteBuf buffer) {
    for (short version : versions) {
        ByteBuf bb = buffer.copy();
        OFDeserializer<T> serializer = registry.getDeserializer(new MessageCodeKey(version, messageCodeKey.getMsgType(), messageCodeKey.getClazz()));
        T builtByFactory = BufferHelper.deserialize(serializer, bb);
        BufferHelper.checkHeader((OfHeader) builtByFactory, version);
    }
}
Also used : MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) ByteBuf(io.netty.buffer.ByteBuf)

Example 62 with MessageCodeKey

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

the class ExperimenterIdDeserializerKeyTest method testEquals.

/**
 * Test ExperimenterIdDeserializerKey equals - additional test.
 */
@Test
public void testEquals() {
    ExperimenterIdDeserializerKey key1 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0L, ExperimenterMessage.class);
    Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
    MessageCodeKey mk = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EXPERIMENTER_VALUE, ExperimenterMessage.class);
    Assert.assertFalse("Wrong equal to different class.", key1.equals(mk));
    ExperimenterIdDeserializerKey key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class);
    Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2));
}
Also used : MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) ExperimenterIdDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey) Test(org.junit.Test)

Example 63 with MessageCodeKey

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

the class MessageCodeKeyTest method testToString.

/**
 * Test MessageCodeKey toString().
 */
@Test
public void testToString() {
    MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class);
    Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" + ".opendaylight.openflow.protocol.rev130731.BarrierInput msgType: 4", key1.toString());
}
Also used : MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) Test(org.junit.Test)

Example 64 with MessageCodeKey

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

the class MessageCodeKeyTest method testEquals.

/**
 * Test MessageCodeKey equals - additional test.
 */
@Test
public void testEquals() {
    MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class);
    Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
    Assert.assertFalse("Wrong equal to null.", key1.equals(null));
    Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
    key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null);
    MessageCodeKey key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class);
    Assert.assertFalse("Wrong equal by clazz.", key1.equals(key2));
    key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null);
    Assert.assertTrue("Wrong equal by clazz.", key1.equals(key2));
}
Also used : MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) Test(org.junit.Test)

Example 65 with MessageCodeKey

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

the class MultipartRequestInputMessageFactory method setFlow.

private MultipartRequestFlowCase setFlow(ByteBuf input) {
    final MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
    MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder();
    flowBuilder.setTableId(input.readUnsignedByte());
    input.skipBytes(FLOW_PADDING_1);
    flowBuilder.setOutPort(input.readUnsignedInt());
    flowBuilder.setOutGroup(input.readUnsignedInt());
    input.skipBytes(FLOW_PADDING_2);
    byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    input.readBytes(cookie);
    flowBuilder.setCookie(new BigInteger(1, cookie));
    final byte[] cookieMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    input.readBytes(cookieMask);
    flowBuilder.setCookieMask(new BigInteger(1, cookieMask));
    OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
    flowBuilder.setMatch(matchDeserializer.deserialize(input));
    caseBuilder.setMultipartRequestFlow(flowBuilder.build());
    return caseBuilder.build();
}
Also used : MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) MultipartRequestFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder) MultipartRequestFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder) BigInteger(java.math.BigInteger) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match)

Aggregations

MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)85 Before (org.junit.Before)52 DeserializerRegistryImpl (org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl)52 DeserializerRegistry (org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry)51 Test (org.junit.Test)16 ByteBuf (io.netty.buffer.ByteBuf)10 BigInteger (java.math.BigInteger)8 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match)7 MatchV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)7 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)4 ArrayList (java.util.ArrayList)4 ActionDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey)4 CodeKeyMaker (org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker)4 ExperimenterActionDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey)3 MatchEntryDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey)3 ExperimenterIdDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey)2 InstructionDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey)2 TypeToClassKey (org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey)2 DefaultDeserializerFactoryTest (org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest)2 MessageCodeExperimenterKey (org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MessageCodeExperimenterKey)2