Search in sources :

Example 16 with ExperimenterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.

the class MultipartRequestTableFeaturesTest method testMultipartRequestTableFeaturesExperimenter.

/**
 * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
 */
@Test
public void testMultipartRequestTableFeaturesExperimenter() throws Exception {
    MultipartRequestInputFactory factory = new MultipartRequestInputFactory();
    factory.injectSerializerRegistry(mockRegistry);
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setType(MultipartType.forValue(12));
    builder.setFlags(new MultipartRequestFlags(true));
    TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
    tableFeaturesBuilder.setTableId((short) 8);
    tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
    tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }));
    tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }));
    tableFeaturesBuilder.setConfig(new TableConfig(true));
    tableFeaturesBuilder.setMaxEntries(65L);
    TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);
    ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
    expBuilder.setExperimenter(new ExperimenterId(42L));
    propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
    List<TableFeatureProperties> properties = new ArrayList<>();
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);
    expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
    expBuilder.setExperimenter(new ExperimenterId(43L));
    propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
    properties.add(propBuilder.build());
    tableFeaturesBuilder.setTableFeatureProperties(properties);
    List<TableFeatures> tableFeaturesList = new ArrayList<>();
    tableFeaturesList.add(tableFeaturesBuilder.build());
    MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder();
    featuresBuilder.setTableFeatures(tableFeaturesList);
    MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
    caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 18, 80);
    Assert.assertEquals("Wrong type", 12, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort());
    out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
    Assert.assertEquals("Wrong length", 64, out.readUnsignedShort());
    Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte());
    out.skipBytes(5);
    Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(out, 32));
    byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(metadataMatch);
    Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatch);
    byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(metadataWrite);
    Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWrite);
    Assert.assertEquals("Wrong config", 8, out.readUnsignedInt());
    Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt());
    Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class), Matchers.any(ByteBuf.class));
}
Also used : ExperimenterIdTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeaturePropertyBuilder) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ArrayList(java.util.ArrayList) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder) MultipartRequestTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder) 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) MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder) MultipartRequestTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder) TableFeaturePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures) BigInteger(java.math.BigInteger) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) MultipartRequestInputFactoryTest(org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest) Test(org.junit.Test)

Example 17 with ExperimenterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId 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 18 with ExperimenterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.

the class OF13SetFieldActionSerializerTest method test.

/**
 * Test identify ExperimenterClass serializer.
 */
@Test
public void test() {
    OF13SetFieldActionSerializer ser = new OF13SetFieldActionSerializer();
    ser.injectSerializerRegistry(registry);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder = new ActionBuilder();
    long experimenterId = 12L;
    ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder();
    ExperimenterBuilder expBuilder = new ExperimenterBuilder();
    expBuilder.setExperimenter(new ExperimenterId(experimenterId));
    expCaseBuilder.setExperimenter(expBuilder.build());
    MatchEntryBuilder meb = new MatchEntryBuilder();
    meb.setOxmClass(ExperimenterClass.class);
    meb.setOxmMatchField(OxmMatchFieldClass.class);
    meb.setMatchEntryValue(expCaseBuilder.build());
    List<MatchEntry> matchEntry = new ArrayList<>();
    MatchEntry me = meb.build();
    matchEntry.add(me);
    SetFieldCaseBuilder caseBuilder = new SetFieldCaseBuilder();
    SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
    setFieldBuilder.setMatchEntry(matchEntry);
    caseBuilder.setSetFieldAction(setFieldBuilder.build());
    actionBuilder.setActionChoice(caseBuilder.build());
    MatchEntrySerializerKey<?, ?> key = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, ExperimenterClass.class, OxmMatchFieldClass.class);
    key.setExperimenterId(experimenterId);
    registry.registerSerializer(key, serializerMock);
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    ser.serialize(actionBuilder.build(), out);
    Mockito.verify(serializerMock, Mockito.times(1)).serialize((MatchEntry) Mockito.anyObject(), (ByteBuf) Mockito.anyObject());
    int lenght = out.readableBytes();
    Assert.assertEquals("Wrong - bad field code", ActionConstants.SET_FIELD_CODE, out.readUnsignedShort());
    Assert.assertEquals("Wrong - bad lenght", lenght, out.readUnsignedShort());
}
Also used : SetFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) SetFieldActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) ArrayList(java.util.ArrayList) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) ExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder) SetFieldActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder) MatchEntrySerializerKey(org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey) ExperimenterIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder) Test(org.junit.Test)

Example 19 with ExperimenterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.

the class ExperimenterInputMessageFactoryTest method testV13.

/**
 * Testing of {@link ExperimenterInputMessageFactory} for correct serializer
 * lookup and serialization.
 */
@Test
public void testV13() throws Exception {
    startUp(false);
    ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setExperimenter(new ExperimenterId(42L));
    builder.setExpType(21L);
    builder.setExperimenterDataOfChoice(vendorData);
    ExperimenterInput input = builder.build();
    Mockito.when(registry.getSerializer((ExperimenterIdSerializerKey<?>) Matchers.any())).thenReturn(serializer);
    expFactory.serialize(input, out);
    Mockito.verify(serializer, Mockito.times(1)).serialize(input.getExperimenterDataOfChoice(), out);
}
Also used : ExperimenterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder) 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 20 with ExperimenterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.

the class LearnCodecTest method createAction.

private Action createAction() {
    ExperimenterId experimenterId = new ExperimenterId(NiciraConstants.NX_VENDOR_ID);
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setExperimenterId(experimenterId);
    final ActionLearnBuilder actionLearnBuilder = new ActionLearnBuilder();
    NxActionLearnBuilder nxActionLearnBuilder = new NxActionLearnBuilder();
    nxActionLearnBuilder.setIdleTimeout(1);
    nxActionLearnBuilder.setHardTimeout(2);
    nxActionLearnBuilder.setPriority(3);
    nxActionLearnBuilder.setCookie(BigInteger.valueOf(4));
    nxActionLearnBuilder.setFlags(5);
    nxActionLearnBuilder.setTableId((short) 6);
    nxActionLearnBuilder.setFinIdleTimeout(7);
    nxActionLearnBuilder.setFinHardTimeout(8);
    nxActionLearnBuilder.setFlowMods(createFlowMods());
    actionLearnBuilder.setNxActionLearn(nxActionLearnBuilder.build());
    actionBuilder.setActionChoice(actionLearnBuilder.build());
    return actionBuilder.build();
}
Also used : NxActionLearnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.NxActionLearnBuilder) ActionLearnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionLearnBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) NxActionLearnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.NxActionLearnBuilder)

Aggregations

ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)37 Test (org.junit.Test)14 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)13 ExperimenterDataOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)9 ByteBuf (io.netty.buffer.ByteBuf)6 ExperimenterIdCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder)5 ExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder)5 ExperimenterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput)5 ExperimenterInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder)5 ArrayList (java.util.ArrayList)4 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)4 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)3 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)3 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)3 MatchEntrySerializerKey (org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey)2 MultipartRequestInputFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory)2 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)2 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)2 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)2 BigInteger (java.math.BigInteger)1