Search in sources :

Example 6 with MultipartReplyTableFeaturesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testMultipartRequestTableFeaturesMessageFactory.

@Test
public void testMultipartRequestTableFeaturesMessageFactory() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(12));
    final MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
    final MultipartReplyTableFeaturesBuilder featuresBuilder = new MultipartReplyTableFeaturesBuilder();
    final List<TableFeatures> tableFeaturesList = new ArrayList<>();
    TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
    tableFeaturesBuilder.setTableId((short) 8);
    tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
    tableFeaturesBuilder.setMetadataMatch(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 });
    tableFeaturesBuilder.setMetadataWrite(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.OFPTFPTNEXTTABLES);
    NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
    List<NextTableIds> nextIds = new ArrayList<>();
    nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build());
    nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build());
    nextPropBuilder.setNextTableIds(nextIds);
    propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
    List<TableFeatureProperties> properties = new ArrayList<>();
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS);
    nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
    nextIds = new ArrayList<>();
    nextPropBuilder.setNextTableIds(nextIds);
    propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS);
    List<Instruction> insIds = new ArrayList<>();
    InstructionBuilder insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new WriteActionsCaseBuilder().build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
    insIds.add(insBuilder.build());
    InstructionRelatedTableFeaturePropertyBuilder insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
    insPropBuilder.setInstruction(insIds);
    propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS);
    insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
    insIds = new ArrayList<>();
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new WriteMetadataCaseBuilder().build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new ApplyActionsCaseBuilder().build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new MeterCaseBuilder().build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new ClearActionsCaseBuilder().build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
    insIds.add(insBuilder.build());
    insPropBuilder.setInstruction(insIds);
    propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
    properties.add(propBuilder.build());
    tableFeaturesBuilder.setTableFeatureProperties(properties);
    tableFeaturesList.add(tableFeaturesBuilder.build());
    tableFeaturesBuilder = new TableFeaturesBuilder();
    tableFeaturesBuilder.setTableId((short) 8);
    tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
    byte[] metadataMatch = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 };
    tableFeaturesBuilder.setMetadataMatch(metadataMatch);
    byte[] metadataWrite = new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 };
    tableFeaturesBuilder.setMetadataWrite(metadataWrite);
    tableFeaturesBuilder.setConfig(new TableConfig(true));
    tableFeaturesBuilder.setMaxEntries(67L);
    properties = new ArrayList<>();
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS);
    ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    List<Action> actions = new ArrayList<>();
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(new OutputActionCaseBuilder().build());
    actions.add(actionBuilder.build());
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS);
    actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    actions = new ArrayList<>();
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS);
    actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    actions = new ArrayList<>();
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS);
    actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    actions = new ArrayList<>();
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH);
    MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(InPhyPort.class);
    entriesBuilder.setHasMask(false);
    List<MatchEntry> entries = new ArrayList<>();
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(InPort.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(IpProto.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(IpEcn.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    tableFeaturesBuilder.setTableFeatureProperties(properties);
    tableFeaturesList.add(tableFeaturesBuilder.build());
    featuresBuilder.setTableFeatures(tableFeaturesList);
    caseBuilder.setMultipartReplyTableFeatures(featuresBuilder.build());
    builder.setMultipartReplyBody(caseBuilder.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 520);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLEFEATURES.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    Assert.assertEquals("Wrong length", 232, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong registry-id", 8, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(5);
    Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 32));
    byte[] metadataMatchOutput = new byte[metadataMatch.length];
    serializedBuffer.readBytes(metadataMatchOutput);
    Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatchOutput);
    serializedBuffer.skipBytes(64 - metadataMatch.length);
    byte[] metadataWriteOutput = new byte[metadataWrite.length];
    serializedBuffer.readBytes(metadataWriteOutput);
    Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWriteOutput);
    serializedBuffer.skipBytes(64 - metadataWrite.length);
    Assert.assertEquals("Wrong config", 1, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong max-entries", 65, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong property type", 2, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 6, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong next-registry-id", 1, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong next-registry-id", 2, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(2);
    Assert.assertEquals("Wrong property type", 3, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 0, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 3, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 1, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 1, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 24, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 2, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 6, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 5, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 1, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong length", 272, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong registry-id", 8, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(5);
    Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 32));
    metadataMatchOutput = new byte[metadataMatch.length];
    serializedBuffer.readBytes(metadataMatchOutput);
    serializedBuffer.skipBytes(64 - metadataMatch.length);
    Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatchOutput);
    metadataWriteOutput = new byte[metadataWrite.length];
    serializedBuffer.readBytes(metadataWriteOutput);
    serializedBuffer.skipBytes(64 - metadataWrite.length);
    Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWriteOutput);
    Assert.assertEquals("Wrong config", 1, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong max-entries", 67, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong property type", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 8, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property type", 5, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 6, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 7, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 8, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 2, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 4, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 0, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 4, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 10, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 12, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 13, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 14, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 20, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 1, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 18, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 1, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 15, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertTrue("Unread data", serializedBuffer.readableBytes() == 0);
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) NextTableIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) SetNwTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder) ArrayList(java.util.ArrayList) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) GotoTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder) NextTableRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) InstructionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder) ActionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) 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.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig) ClearActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder) MultipartReplyMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCaseBuilder) MeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder) WriteActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartReplyTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) NextTableIds(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds) OxmRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder) Test(org.junit.Test)

Example 7 with MultipartReplyTableFeaturesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method setTableFeatures.

private MultipartReplyTableFeaturesCase setTableFeatures(final ByteBuf input) {
    MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
    MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
    List<TableFeatures> features = new ArrayList<>();
    while (input.readableBytes() > 0) {
        TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
        final int length = input.readUnsignedShort();
        featuresBuilder.setTableId(input.readUnsignedByte());
        input.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
        featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH));
        byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(metadataMatch);
        featuresBuilder.setMetadataMatch(metadataMatch);
        byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(metadataWrite);
        featuresBuilder.setMetadataWrite(metadataWrite);
        featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
        featuresBuilder.setMaxEntries(input.readUnsignedInt());
        featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, length - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH));
        features.add(featuresBuilder.build());
    }
    builder.setTableFeatures(features);
    caseBuilder.setMultipartReplyTableFeatures(builder.build());
    return caseBuilder.build();
}
Also used : TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures) ArrayList(java.util.ArrayList) MultipartReplyTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder)

Example 8 with MultipartReplyTableFeaturesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder in project openflowplugin by opendaylight.

the class SingleLayerTableMultipartServiceTest method handleAndReply.

@Test
public void handleAndReply() throws Exception {
    mockSuccessfulFuture(Collections.singletonList(new MultipartReplyBuilder().setXid(XID).setMultipartReplyBody(new MultipartReplyTableFeaturesBuilder().setTableFeatures(Collections.singletonList(new TableFeaturesBuilder().setMaxEntries(MAX_ENTRIES).build())).build()).build()));
    final UpdateTableInput input = new UpdateTableInputBuilder().setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(Collections.singletonList(new TableFeaturesBuilder().setMaxEntries(MAX_ENTRIES).build())).build()).build();
    final Future<RpcResult<UpdateTableOutput>> rpcResultFuture = service.handleAndReply(input);
    final RpcResult<UpdateTableOutput> result = rpcResultFuture.get();
    assertTrue(result.isSuccessful());
    assertEquals(XID, result.getResult().getTransactionId().getValue().longValue());
}
Also used : UpdateTableOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder) UpdateTableInput(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput) UpdatedTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder) UpdateTableInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder) Test(org.junit.Test)

Example 9 with MultipartReplyTableFeaturesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder in project openflowplugin by opendaylight.

the class TableFeaturesResponseConvertorTest method test2.

/**
 * Incorrect / empty input test.
 */
@Test
public void test2() {
    MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
    List<TableFeatures> list = convert(builder.build());
    Assert.assertEquals("Returned list is not empty", 0, list.size());
}
Also used : TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) Test(org.junit.Test)

Example 10 with MultipartReplyTableFeaturesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder in project openflowplugin by opendaylight.

the class SalTableServiceImplTest method testUpdateTableSuccess.

@Test
public void testUpdateTableSuccess() throws ExecutionException, InterruptedException {
    Mockito.doAnswer((Answer<Void>) invocation -> {
        TableFeaturesBuilder tableFeaturesBld = new TableFeaturesBuilder().setTableId((short) 0).setName("Zafod").setMaxEntries(42L).setTableFeatureProperties(Collections.<TableFeatureProperties>emptyList());
        MultipartReplyTableFeaturesBuilder mpTableFeaturesBld = new MultipartReplyTableFeaturesBuilder().setTableFeatures(Collections.singletonList(tableFeaturesBld.build()));
        MultipartReplyTableFeaturesCaseBuilder mpBodyBld = new MultipartReplyTableFeaturesCaseBuilder().setMultipartReplyTableFeatures(mpTableFeaturesBld.build());
        MultipartReplyMessageBuilder mpResultBld = new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPTABLEFEATURES).setMultipartReplyBody(mpBodyBld.build()).setXid(21L);
        final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.success(Collections.singletonList((MultipartReply) mpResultBld.build())).build();
        handleResultFuture.set(rpcResult);
        return null;
    }).when(multiMessageCollector).endCollecting(Matchers.<EventIdentifier>any());
    final Future<RpcResult<UpdateTableOutput>> rpcResultFuture = salTableService.updateTable(prepareUpdateTable());
    Assert.assertNotNull(rpcResultFuture);
    verify(mockedRequestContextStack).createRequestContext();
}
Also used : UpdateTableInput(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ServiceMocking(org.opendaylight.openflowplugin.impl.services.ServiceMocking) UpdatedTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder) Matchers(org.mockito.Matchers) Mock(org.mockito.Mock) RpcProviderRegistry(org.opendaylight.controller.sal.binding.api.RpcProviderRegistry) MultipartWriterProviderFactory(org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory) MultipartReplyTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder) SettableFuture(com.google.common.util.concurrent.SettableFuture) Answer(org.mockito.stubbing.Answer) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) Future(java.util.concurrent.Future) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) ConvertorManagerFactory(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory) UpdateTableInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder) UpdateTableOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput) Test(org.junit.Test) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) Mockito.when(org.mockito.Mockito.when) FutureCallback(com.google.common.util.concurrent.FutureCallback) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) Mockito(org.mockito.Mockito) List(java.util.List) ConvertorManager(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) Assert(org.junit.Assert) Collections(java.util.Collections) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) MultipartReplyTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 MultipartReplyTableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder)7 ArrayList (java.util.ArrayList)6 TableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder)5 TableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures)5 MultipartReplyTableFeaturesCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder)4 MultipartReplyTableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures)4 BigInteger (java.math.BigInteger)3 TableConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig)3 TableFeatureProperties (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties)3 MultipartReplyTableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder)3 List (java.util.List)2 ActionRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder)2 InstructionRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder)2 NextTableRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder)2 OxmRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder)2 NextTableIds (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds)2 NextTableIdsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder)2 PushVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder)2 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)2