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();
}
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());
}
Aggregations