Search in sources :

Example 11 with ExperimenterDataOfChoice

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);
}
Also used : ExperimenterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) ExperimenterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput) Test(org.junit.Test)

Example 12 with ExperimenterDataOfChoice

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();
}
Also used : MultipartReplyExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCaseBuilder) 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) MultipartReplyExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder)

Example 13 with ExperimenterDataOfChoice

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);
}
Also used : MultipartRequestExperimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) MultipartRequestExperimenterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase)

Example 14 with ExperimenterDataOfChoice

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();
}
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 15 with ExperimenterDataOfChoice

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);
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder) MultipartRequestExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) MultipartRequestInputFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Aggregations

ExperimenterDataOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)16 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)7 Test (org.junit.Test)5 MessageTypeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey)5 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)5 ExperimenterMessageOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice)5 ByteBuf (io.netty.buffer.ByteBuf)3 ExperimenterMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder)3 MultipartRequestExperimenterCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder)3 MultipartRequestExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 ConvertorMessageFromOFJava (org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava)2 TypeVersionKey (org.opendaylight.openflowplugin.extension.api.TypeVersionKey)2 ConverterNotFoundException (org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException)2 MessagePath (org.opendaylight.openflowplugin.extension.api.path.MessagePath)2 ServiceException (org.opendaylight.openflowplugin.impl.services.util.ServiceException)2 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)2 ExperimenterInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 ArrayList (java.util.ArrayList)1