Search in sources :

Example 6 with ExperimenterMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage in project openflowplugin by opendaylight.

the class ExperimenterMessageFactory method deserialize.

@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public ExperimenterMessage deserialize(ByteBuf message) {
    Objects.requireNonNull(deserializerRegistry);
    final long xid = message.readUnsignedInt();
    final long expId = message.readUnsignedInt();
    final long expType = message.readUnsignedInt();
    OFDeserializer<ExperimenterDataOfChoice> deserializer = deserializerRegistry.getDeserializer(ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, expType));
    final ExperimenterDataOfChoice vendorData = deserializer.deserialize(message);
    ExperimenterMessageBuilder messageBld = new ExperimenterMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(xid).setExperimenter(new ExperimenterId(expId)).setExpType(expType).setExperimenterDataOfChoice(vendorData);
    return messageBld.build();
}
Also used : ExperimenterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 7 with ExperimenterMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage in project openflowplugin by opendaylight.

the class ExperimenterMessageFactoryTest method test.

/**
 * Test deserializer lookup correctness.
 */
@Test
public void test() {
    when(registry.getDeserializer(any(ExperimenterIdDeserializerKey.class))).thenReturn(deserializer);
    when(deserializer.deserialize(any(ByteBuf.class))).thenReturn(message);
    ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 02 03 00 00 00 10 00 00 00 20");
    factory.injectDeserializerRegistry(registry);
    ExperimenterMessage deserializedMessage = factory.deserialize(buffer);
    Assert.assertEquals("Wrong return value", message, deserializedMessage.getExperimenterDataOfChoice());
    Assert.assertEquals("ByteBuf index moved", 0, buffer.readableBytes());
}
Also used : ExperimenterMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterIdDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey) Test(org.junit.Test)

Aggregations

ExperimenterMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder)5 Test (org.junit.Test)4 ExperimenterDataOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)4 ExperimenterMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 MessageTypeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey)2 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)2 ByteBuf (io.netty.buffer.ByteBuf)1 NotificationPublishService (org.opendaylight.controller.md.sal.binding.api.NotificationPublishService)1 ExperimenterIdDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey)1 ConvertorMessageFromOFJava (org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava)1 ExtensionConverterProvider (org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider)1 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)1 MessagePath (org.opendaylight.openflowplugin.extension.api.path.MessagePath)1 ExperimenterMessageFromDev (org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.ExperimenterMessageFromDev)1 ExperimenterMessageFromDevBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.ExperimenterMessageFromDevBuilder)1 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)1 EchoRequestMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder)1 ErrorMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder)1 FlowRemovedMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder)1