Search in sources :

Example 1 with OxmRelatedTableFeaturePropertyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder in project openflowplugin by opendaylight.

the class TableFeaturesResponseConvertorTest method testWithMPTableFeatureWithProperties.

/**
 * Test correct input.
 */
@Test
public void testWithMPTableFeatureWithProperties() {
    TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
    featuresBuilder.setTableId((short) 5);
    featuresBuilder.setName("Aloha");
    byte[] metaMatch = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 };
    featuresBuilder.setMetadataMatch(metaMatch);
    byte[] metaWrite = new byte[] { 8, 9, 10, 11, 12, 13, 14, 15 };
    featuresBuilder.setMetadataWrite(metaWrite);
    featuresBuilder.setConfig(new TableConfig(false));
    featuresBuilder.setMaxEntries(42L);
    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<>();
    nextIds.add(new NextTableIdsBuilder().setTableId((short) 3).build());
    nextPropBuilder.setNextTableIds(nextIds);
    propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS);
    /* -------------------------------------------------- */
    List<Action> actions = new ArrayList<>();
    WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createSetNwSrcAction());
    actions.add(actionBuilder.build());
    writeActionsBuilder.setAction(actions);
    WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
    writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
    InstructionBuilder insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(writeActionsCaseBuilder.build());
    List<Instruction> insIds = new ArrayList<>();
    insIds.add(insBuilder.build());
    /* -------------------------------------------------- */
    insBuilder = new InstructionBuilder();
    GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
    GotoTableBuilder gotoTableBuilder = new GotoTableBuilder();
    gotoCaseBuilder.setGotoTable(gotoTableBuilder.build());
    insBuilder.setInstructionChoice(gotoCaseBuilder.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();
    WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
    WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
    writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
    insBuilder.setInstructionChoice(writeMetadataCaseBuilder.build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
    ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
    applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
    insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
    MeterBuilder meterBuilder = new MeterBuilder();
    meterCaseBuilder.setMeter(meterBuilder.build());
    insBuilder.setInstructionChoice(meterCaseBuilder.build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
    insBuilder.setInstructionChoice(clearActionsCaseBuilder.build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    GotoTableCaseBuilder gotoCaseBuilder2 = new GotoTableCaseBuilder();
    GotoTableBuilder gotoTableBuilder2 = new GotoTableBuilder();
    gotoCaseBuilder2.setGotoTable(gotoTableBuilder2.build());
    insBuilder.setInstructionChoice(gotoCaseBuilder2.build());
    insIds.add(insBuilder.build());
    insPropBuilder.setInstruction(insIds);
    propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
    properties.add(propBuilder.build());
    featuresBuilder.setTableFeatureProperties(properties);
    List<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> features = new ArrayList<>();
    features.add(featuresBuilder.build());
    featuresBuilder = new TableFeaturesBuilder();
    featuresBuilder.setTableId((short) 6);
    featuresBuilder.setName("Mahalo");
    byte[] metaMatch2 = new byte[] { 8, 9, 10, 11, 12, 13, 14, 15 };
    featuresBuilder.setMetadataMatch(metaMatch2);
    byte[] metaWrite2 = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 };
    featuresBuilder.setMetadataWrite(metaWrite2);
    featuresBuilder.setConfig(new TableConfig(false));
    featuresBuilder.setMaxEntries(24L);
    /* -------------------------------------------------- */
    properties = new ArrayList<>();
    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());
    // [0]
    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());
    // [1]
    properties.add(propBuilder.build());
    /* -------------------------------------------------- */
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(VlanVid.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    // [2]
    properties.add(propBuilder.build());
    /* -------------------------------------------------- */
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(VlanPcp.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(TcpSrc.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    // [3]
    properties.add(propBuilder.build());
    /* -------------------------------------------------- */
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(UdpSrc.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(UdpDst.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    // [4]
    properties.add(propBuilder.build());
    /* -------------------------------------------------- */
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(EthSrc.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(EthDst.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    // [5]
    properties.add(propBuilder.build());
    /* -------------------------------------------------- */
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS);
    actions = new ArrayList<>();
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createSetNwSrcAction());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createSetNwSrcAction());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createSetNwSrcAction());
    actions.add(actionBuilder.build());
    ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    // [6]
    properties.add(propBuilder.build());
    /* -------------------------------------------------- */
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS);
    actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    actions = new ArrayList<>();
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createGroupAction());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createCopyTtlInCase());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createCopyTtlOutCase());
    actions.add(actionBuilder.build());
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    // [7]
    properties.add(propBuilder.build());
    /* -------------------------------------------------- */
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS);
    actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    actions = new ArrayList<>();
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createSetMplsTtlCase());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createDecMplsTtlCase());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(pushVlanCase());
    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<>();
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createPopVlanCase());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createPushPbbCase());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(createEmptySetFieldCase());
    actions.add(actionBuilder.build());
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    properties.add(propBuilder.build());
    /* -------------------------------------------------- */
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    /* -------------------------------------------------- */
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    /* -------------------------------------------------- */
    featuresBuilder.setTableFeatureProperties(properties);
    features.add(featuresBuilder.build());
    MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
    builder.setTableFeatures(features);
    List<TableFeatures> list = convert(builder.build());
    Assert.assertEquals("Returned empty list", 2, list.size());
    TableFeatures feature = list.get(0);
    Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue());
    Assert.assertEquals("Wrong name", "Aloha", feature.getName());
    Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch), feature.getMetadataMatch());
    Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite), feature.getMetadataWrite());
    Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
    Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue());
    Assert.assertEquals("Wrong properties", 4, feature.getTableProperties().getTableFeatureProperties().size());
    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties property = feature.getTableProperties().getTableFeatureProperties().get(0);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.NextTable", property.getTableFeaturePropType().getImplementedInterface().getName());
    NextTable propType = (NextTable) property.getTableFeaturePropType();
    List<Short> ids = propType.getTables().getTableIds();
    Assert.assertEquals("Wrong next table-id size", 2, ids.size());
    Assert.assertEquals("Wrong next-registry-id", 1, ids.get(0).intValue());
    Assert.assertEquals("Wrong next-registry-id", 2, ids.get(1).intValue());
    property = feature.getTableProperties().getTableFeatureProperties().get(1);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
    NextTableMiss propType2 = (NextTableMiss) property.getTableFeaturePropType();
    ids = propType2.getTablesMiss().getTableIds();
    Assert.assertEquals("Wrong next table-id size", 1, ids.size());
    Assert.assertEquals("Wrong next-registry-id", 3, ids.get(0).intValue());
    property = feature.getTableProperties().getTableFeatureProperties().get(2);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.Instructions", property.getTableFeaturePropType().getImplementedInterface().getName());
    Instructions propType3 = (Instructions) property.getTableFeaturePropType();
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> instructionIds = propType3.getInstructions().getInstruction();
    Assert.assertEquals("Wrong instruction-ids size", 2, instructionIds.size());
    Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.WriteActionsCase", instructionIds.get(0).getInstruction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.GoToTableCase", instructionIds.get(1).getInstruction().getImplementedInterface().getName());
    property = feature.getTableProperties().getTableFeatureProperties().get(3);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
    InstructionsMiss propType4 = (InstructionsMiss) property.getTableFeaturePropType();
    instructionIds = propType4.getInstructionsMiss().getInstruction();
    Assert.assertEquals("Wrong instruction-ids size", 5, instructionIds.size());
    Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.WriteMetadataCase", instructionIds.get(0).getInstruction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.ApplyActionsCase", instructionIds.get(1).getInstruction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.MeterCase", instructionIds.get(2).getInstruction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.ClearActionsCase", instructionIds.get(3).getInstruction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.GoToTableCase", instructionIds.get(4).getInstruction().getImplementedInterface().getName());
    feature = list.get(1);
    Assert.assertEquals("Wrong table-id", 6, feature.getTableId().intValue());
    Assert.assertEquals("Wrong name", "Mahalo", feature.getName());
    Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch2), feature.getMetadataMatch());
    Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite2), feature.getMetadataWrite());
    Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
    Assert.assertEquals("Wrong max-entries", 24, feature.getMaxEntries().intValue());
    Assert.assertEquals("Wrong properties", 12, feature.getTableProperties().getTableFeatureProperties().size());
    property = feature.getTableProperties().getTableFeatureProperties().get(0);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.Match", property.getTableFeaturePropType().getImplementedInterface().getName());
    Match propType5 = (Match) property.getTableFeaturePropType();
    List<SetFieldMatch> fieldMatch = propType5.getMatchSetfield().getSetFieldMatch();
    Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.InPhyPort", fieldMatch.get(0).getMatchType().getName());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.InPort", fieldMatch.get(1).getMatchType().getName());
    property = feature.getTableProperties().getTableFeatureProperties().get(1);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield", property.getTableFeaturePropType().getImplementedInterface().getName());
    ApplySetfield propType6 = (ApplySetfield) property.getTableFeaturePropType();
    fieldMatch = propType6.getApplySetfield().getSetFieldMatch();
    Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto", fieldMatch.get(0).getMatchType().getName());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn", fieldMatch.get(1).getMatchType().getName());
    property = feature.getTableProperties().getTableFeatureProperties().get(2);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield", property.getTableFeaturePropType().getImplementedInterface().getName());
    WriteSetfield propType7 = (WriteSetfield) property.getTableFeaturePropType();
    fieldMatch = propType7.getWriteSetfield().getSetFieldMatch();
    Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr", fieldMatch.get(0).getMatchType().getName());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid", fieldMatch.get(1).getMatchType().getName());
    property = feature.getTableProperties().getTableFeatureProperties().get(3);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
    WriteSetfieldMiss propType8 = (WriteSetfieldMiss) property.getTableFeaturePropType();
    fieldMatch = propType8.getWriteSetfieldMiss().getSetFieldMatch();
    Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp", fieldMatch.get(0).getMatchType().getName());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc", fieldMatch.get(1).getMatchType().getName());
    property = feature.getTableProperties().getTableFeatureProperties().get(4);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
    ApplySetfieldMiss propType9 = (ApplySetfieldMiss) property.getTableFeaturePropType();
    fieldMatch = propType9.getApplySetfieldMiss().getSetFieldMatch();
    Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc", fieldMatch.get(0).getMatchType().getName());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst", fieldMatch.get(1).getMatchType().getName());
    property = feature.getTableProperties().getTableFeatureProperties().get(5);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards", property.getTableFeaturePropType().getImplementedInterface().getName());
    Wildcards propType10 = (Wildcards) property.getTableFeaturePropType();
    fieldMatch = propType10.getWildcardSetfield().getSetFieldMatch();
    Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc", fieldMatch.get(0).getMatchType().getName());
    Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst", fieldMatch.get(1).getMatchType().getName());
    property = feature.getTableProperties().getTableFeatureProperties().get(6);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions", property.getTableFeaturePropType().getImplementedInterface().getName());
    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions propType11 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions) property.getTableFeaturePropType();
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = propType11.getApplyActions().getAction();
    Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase", actionsList.get(0).getAction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase", actionsList.get(1).getAction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase", actionsList.get(2).getAction().getImplementedInterface().getName());
    property = feature.getTableProperties().getTableFeatureProperties().get(7);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss propType12 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss) property.getTableFeaturePropType();
    actionsList = propType12.getApplyActionsMiss().getAction();
    Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase", actionsList.get(0).getAction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase", actionsList.get(1).getAction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase", actionsList.get(2).getAction().getImplementedInterface().getName());
    property = feature.getTableProperties().getTableFeatureProperties().get(8);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions", property.getTableFeaturePropType().getImplementedInterface().getName());
    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions propType13 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions) property.getTableFeaturePropType();
    actionsList = propType13.getWriteActions().getAction();
    Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase", actionsList.get(0).getAction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase", actionsList.get(1).getAction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase", actionsList.get(2).getAction().getImplementedInterface().getName());
    property = feature.getTableProperties().getTableFeatureProperties().get(9);
    Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss propType14 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss) property.getTableFeaturePropType();
    actionsList = propType14.getWriteActionsMiss().getAction();
    Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase", actionsList.get(0).getAction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase", actionsList.get(1).getAction().getImplementedInterface().getName());
    Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase", actionsList.get(2).getAction().getImplementedInterface().getName());
}
Also used : 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) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) WriteSetfieldMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) ApplySetfieldMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss) 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) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder) NextTable(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable) WriteActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder) WriteActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder) 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) InstructionsMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss) Instructions(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions) SetFieldMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch) ApplySetfield(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield) GotoTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder) BigInteger(java.math.BigInteger) Wildcards(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards) OxmRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder) MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) 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) SetMplsTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlActionBuilder) SetNwSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder) SetFieldActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) PushPbbActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder) 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) WriteMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder) SetFieldMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match) InstructionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder) ActionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder) 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) ClearActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder) MeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder) NextTableMiss(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss) NextTableIds(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds) WriteSetfield(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield) Test(org.junit.Test)

Example 2 with OxmRelatedTableFeaturePropertyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder in project openflowplugin by opendaylight.

the class MultipartRequestInputMessageFactory method createTableFeaturesProperties.

private List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
    List<TableFeatureProperties> properties = new ArrayList<>();
    int tableFeaturesLength = length;
    while (tableFeaturesLength > 0) {
        int propStartIndex = input.readerIndex();
        TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder();
        TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort());
        builder.setType(type);
        int propertyLength = input.readUnsignedShort();
        int paddingRemainder = propertyLength % EncodeConstants.PADDING;
        tableFeaturesLength -= propertyLength;
        if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS) || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
            InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
            CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
            List<Instruction> instructions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
            insBuilder.setInstruction(instructions);
            builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES) || type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {
            propertyLength -= COMMON_PROPERTY_LENGTH;
            NextTableRelatedTableFeaturePropertyBuilder tableBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
            List<NextTableIds> ids = new ArrayList<>();
            while (propertyLength > 0) {
                NextTableIdsBuilder nextTableIdsBuilder = new NextTableIdsBuilder();
                nextTableIdsBuilder.setTableId(input.readUnsignedByte());
                ids.add(nextTableIdsBuilder.build());
                propertyLength--;
            }
            tableBuilder.setNextTableIds(ids);
            builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, tableBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONS) || type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
            ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
            CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
            List<Action> actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
            actionBuilder.setAction(actions);
            builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH) || type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS) || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELD) || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD) || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
            OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
            CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
            List<MatchEntry> entries = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry);
            oxmBuilder.setMatchEntry(entries);
            builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
        } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER) || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {
            long expId = input.readUnsignedInt();
            input.readerIndex(propStartIndex);
            OFDeserializer<TableFeatureProperties> propDeserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId));
            TableFeatureProperties expProp = propDeserializer.deserialize(input);
            properties.add(expProp);
            continue;
        }
        if (paddingRemainder != 0) {
            input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
            tableFeaturesLength -= EncodeConstants.PADDING - paddingRemainder;
        }
        properties.add(builder.build());
    }
    return properties;
}
Also used : TableFeaturesPropType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) NextTableIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder) OxmRelatedTableFeatureProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ArrayList(java.util.ArrayList) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) NextTableRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder) NextTableRelatedTableFeatureProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty) InstructionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder) ActionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder) TableFeaturePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder) CodeKeyMaker(org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker) List(java.util.List) ArrayList(java.util.ArrayList) OxmRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder)

Example 3 with OxmRelatedTableFeaturePropertyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder in project openflowplugin by opendaylight.

the class MultipartRequestTableFeaturesInputMessageFactoryTest method createTableFeatureProperties.

public List<TableFeatureProperties> createTableFeatureProperties() {
    final List<TableFeatureProperties> list = new ArrayList<>();
    TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder();
    builder.setType(TableFeaturesPropType.forValue(0));
    InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
    insBuilder.setInstruction(createInstructions());
    builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
    list.add(builder.build());
    builder = new TableFeaturePropertiesBuilder();
    builder.setType(TableFeaturesPropType.forValue(2));
    NextTableRelatedTableFeaturePropertyBuilder nextBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
    nextBuilder.setNextTableIds(createNextTableIds());
    builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextBuilder.build());
    list.add(builder.build());
    builder = new TableFeaturePropertiesBuilder();
    builder.setType(TableFeaturesPropType.forValue(4));
    ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    actionBuilder.setAction(createAction());
    builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
    list.add(builder.build());
    builder = new TableFeaturePropertiesBuilder();
    builder.setType(TableFeaturesPropType.forValue(8));
    OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    oxmBuilder.setMatchEntry(createMatchEntries());
    builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    list.add(builder.build());
    return list;
}
Also used : InstructionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder) ActionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder) TableFeaturePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ArrayList(java.util.ArrayList) NextTableRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder) OxmRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder)

Example 4 with OxmRelatedTableFeaturePropertyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder 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 5 with OxmRelatedTableFeaturePropertyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder in project openflowplugin by opendaylight.

the class MultipartRequestTableFeaturesTest method testMultipartRequestTableFeaturesMessageFactory.

/**
 * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
 */
@Test
public void testMultipartRequestTableFeaturesMessageFactory() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setType(MultipartType.forValue(12));
    builder.setFlags(new MultipartRequestFlags(true));
    final MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
    final MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder();
    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.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);
    List<TableFeatures> tableFeaturesList = new ArrayList<>();
    tableFeaturesList.add(tableFeaturesBuilder.build());
    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(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.setMultipartRequestTableFeatures(featuresBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    multipartFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 18, 296);
    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", 120, 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());
    Assert.assertEquals("Wrong property type", 2, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 6, out.readUnsignedShort());
    Assert.assertEquals("Wrong next-registry-id", 1, out.readUnsignedByte());
    Assert.assertEquals("Wrong next-registry-id", 2, out.readUnsignedByte());
    out.skipBytes(2);
    Assert.assertEquals("Wrong property type", 3, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertEquals("Wrong property type", 0, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertEquals("Wrong property type", 1, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 24, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong length", 160, out.readUnsignedShort());
    Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte());
    out.skipBytes(5);
    Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(out, 32));
    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);
    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", 67, out.readUnsignedInt());
    Assert.assertEquals("Wrong property type", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong property type", 5, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertEquals("Wrong property type", 6, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertEquals("Wrong property type", 7, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertEquals("Wrong property type", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort());
    Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 2, out.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte());
    Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 0, out.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte());
    out.skipBytes(4);
    Assert.assertEquals("Wrong property type", 10, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertEquals("Wrong property type", 12, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertEquals("Wrong property type", 13, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertEquals("Wrong property type", 14, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort());
    Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 20, out.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte());
    Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 18, out.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte());
    out.skipBytes(4);
    Assert.assertEquals("Wrong property type", 15, out.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertTrue("Unread data", out.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) 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) 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) MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) 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) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder) 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) 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) MeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) 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) 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) 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) NextTableIds(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds) BigInteger(java.math.BigInteger) OxmRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder) MultipartRequestInputFactoryTest(org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)7 OxmRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder)7 ActionRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder)6 InstructionRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder)6 NextTableRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder)6 TableFeatureProperties (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties)6 TableFeaturePropertiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder)6 NextTableIdsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder)5 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)5 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction)5 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)4 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)4 Test (org.junit.Test)3 NextTableIds (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds)3 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)3 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder)3 ClearActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder)3 GotoTableCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder)3 MeterCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder)3 WriteActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder)3