use of org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory in project openflowplugin by opendaylight.
the class MessageFactoryInitializer method registerMessageSerializers.
/**
* Registers message serializers into provided registry.
* @param serializerRegistry registry to be initialized with message serializers
*/
public static void registerMessageSerializers(SerializerRegistry serializerRegistry) {
CommonMessageRegistryHelper registryHelper;
// register OF v1.0 message serializers
registryHelper = new CommonMessageRegistryHelper(EncodeConstants.OF10_VERSION_ID, serializerRegistry);
registryHelper.registerSerializer(BarrierInput.class, new OF10BarrierInputMessageFactory());
registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory());
registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory());
registryHelper.registerSerializer(ExperimenterInput.class, new VendorInputMessageFactory());
registryHelper.registerSerializer(FlowModInput.class, new OF10FlowModInputMessageFactory());
registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory());
registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory());
registryHelper.registerSerializer(GetQueueConfigInput.class, new OF10QueueGetConfigInputMessageFactory());
registryHelper.registerSerializer(HelloInput.class, new OF10HelloInputMessageFactory());
registryHelper.registerSerializer(MultipartRequestInput.class, new OF10StatsRequestInputFactory());
registryHelper.registerSerializer(PacketOutInput.class, new OF10PacketOutInputMessageFactory());
registryHelper.registerSerializer(PortModInput.class, new OF10PortModInputMessageFactory());
registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory());
// register OF v1.3 message serializers
registryHelper = new CommonMessageRegistryHelper(EncodeConstants.OF13_VERSION_ID, serializerRegistry);
registryHelper.registerSerializer(BarrierInput.class, new BarrierInputMessageFactory());
registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory());
registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory());
registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory());
registryHelper.registerSerializer(FlowModInput.class, new FlowModInputMessageFactory());
registryHelper.registerSerializer(GetAsyncInput.class, new GetAsyncRequestMessageFactory());
registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory());
registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory());
registryHelper.registerSerializer(GetQueueConfigInput.class, new GetQueueConfigInputMessageFactory());
registryHelper.registerSerializer(GroupModInput.class, new GroupModInputMessageFactory(serializerRegistry.isGroupAddModEnabled()));
registryHelper.registerSerializer(HelloInput.class, new HelloInputMessageFactory());
registryHelper.registerSerializer(MeterModInput.class, new MeterModInputMessageFactory());
registryHelper.registerSerializer(MultipartRequestInput.class, new MultipartRequestInputFactory());
registryHelper.registerSerializer(PacketOutInput.class, new PacketOutInputMessageFactory());
registryHelper.registerSerializer(PortModInput.class, new PortModInputMessageFactory());
registryHelper.registerSerializer(RoleRequestInput.class, new RoleRequestInputMessageFactory());
registryHelper.registerSerializer(SetAsyncInput.class, new SetAsyncInputMessageFactory());
registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory());
registryHelper.registerSerializer(TableModInput.class, new TableModInputMessageFactory());
}
use of org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory in project openflowplugin by opendaylight.
the class OF10StatsRequestExperimenterTest method testExperimenter.
/**
* Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
*/
@Test
public void testExperimenter() throws Exception {
Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory();
multipartFactory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_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.checkHeaderV10(out, (byte) 16, 16);
Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
}
Aggregations