use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice in project openflowplugin by opendaylight.
the class VendorInputMessageFactoryTest method test.
/**
* Tests {@link VendorInputMessageFactory#serialize(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
* .protocol.rev130731.ExperimenterOfMessage, ByteBuf)}.
*/
@Test
public void test() {
Mockito.when(registry.getSerializer(Matchers.<MessageTypeKey<?>>any())).thenReturn(serializer);
VendorInputMessageFactory factory = new VendorInputMessageFactory();
factory.injectSerializerRegistry(registry);
final ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(12345L);
builder.setExperimenter(new ExperimenterId(42L));
builder.setExpType(84L);
builder.setExperimenterDataOfChoice(vendorData);
ExperimenterInput experimenterInput = builder.build();
Mockito.when(registry.getSerializer(Matchers.<ExperimenterIdSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(foundSerializer);
factory.serialize(experimenterInput, buffer);
Mockito.verify(foundSerializer, Mockito.times(1)).serialize(experimenterInput.getExperimenterDataOfChoice(), buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method setExperimenter.
private MultipartReplyExperimenterCase setExperimenter(final ByteBuf input) {
final long expId = input.readUnsignedInt();
final long expType = input.readUnsignedInt();
final OFDeserializer<ExperimenterDataOfChoice> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, expType));
final MultipartReplyExperimenterBuilder mpExperimenterBld = new MultipartReplyExperimenterBuilder().setExperimenter(new ExperimenterId(expId)).setExpType(expType).setExperimenterDataOfChoice(deserializer.deserialize(input));
final MultipartReplyExperimenterCaseBuilder mpReplyExperimenterCaseBld = new MultipartReplyExperimenterCaseBuilder().setMultipartReplyExperimenter(mpExperimenterBld.build());
return mpReplyExperimenterCaseBld.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice in project openflowplugin by opendaylight.
the class MultipartRequestInputFactory method serializeExperimenterBody.
private void serializeExperimenterBody(final MultipartRequestInput message, final ByteBuf outBuffer) {
MultipartRequestExperimenterCase expCase = (MultipartRequestExperimenterCase) message.getMultipartRequestBody();
MultipartRequestExperimenter experimenter = expCase.getMultipartRequestExperimenter();
final long expId = experimenter.getExperimenter().getValue().longValue();
final long expType = experimenter.getExpType().longValue();
// write experimenterId and type
outBuffer.writeInt((int) expId);
outBuffer.writeInt((int) expType);
// serialize experimenter data
OFSerializer<ExperimenterDataOfChoice> serializer = registry.getSerializer(ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey(EncodeConstants.OF13_VERSION_ID, expId, expType));
serializer.serialize(experimenter.getExperimenterDataOfChoice(), outBuffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice 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.experimenter.core.ExperimenterDataOfChoice in project openflowplugin by opendaylight.
the class MultipartRequestExperimenterTest method testExperimenter.
/**
* Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
*/
@Test
public void testExperimenter() throws Exception {
Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory();
multipartFactory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.OFPMPEXPERIMENTER);
builder.setFlags(new MultipartRequestFlags(false));
final MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
expBuilder.setExpType(21L);
expBuilder.setExperimenterDataOfChoice(vendorData);
caseBuilder.setMultipartRequestExperimenter(expBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 24);
Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
}
Aggregations