use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testFlowBody.
private static void testFlowBody(MultipartReplyBody body, ByteBuf output) {
MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body;
MultipartReplyFlow flow = flowCase.getMultipartReplyFlow();
FlowStats flowStats = flow.getFlowStats().get(0);
Assert.assertEquals("Wrong length", 176, output.readShort());
Assert.assertEquals("Wrong Table ID", flowStats.getTableId().intValue(), output.readUnsignedByte());
output.skipBytes(1);
Assert.assertEquals("Wrong duration sec", flowStats.getDurationSec().intValue(), output.readInt());
Assert.assertEquals("Wrong duration nsec", flowStats.getDurationNsec().intValue(), output.readInt());
Assert.assertEquals("Wrong priority", flowStats.getPriority().intValue(), output.readShort());
Assert.assertEquals("Wrong idle timeout", flowStats.getIdleTimeout().intValue(), output.readShort());
Assert.assertEquals("Wrong hard timeout", flowStats.getHardTimeout().intValue(), output.readShort());
output.skipBytes(6);
Assert.assertEquals("Wrong cookie", flowStats.getCookie().longValue(), output.readLong());
Assert.assertEquals("Wrong Packet count", flowStats.getPacketCount().longValue(), output.readLong());
Assert.assertEquals("Wrong Byte count", flowStats.getByteCount().longValue(), output.readLong());
Assert.assertEquals("Wrong match type", 1, output.readUnsignedShort());
output.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
Assert.assertEquals("Wrong oxm class", 0x8000, output.readUnsignedShort());
short fieldAndMask = output.readUnsignedByte();
Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
output.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
Assert.assertEquals("Wrong oxm value", 42, output.readUnsignedInt());
Assert.assertEquals("Wrong oxm class", 0x8000, output.readUnsignedShort());
fieldAndMask = output.readUnsignedByte();
Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
output.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
Assert.assertEquals("Wrong oxm value", 4, output.readUnsignedByte());
output.skipBytes(7);
Assert.assertEquals("Wrong instruction type", 1, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction table-id", 5, output.readUnsignedByte());
output.skipBytes(3);
Assert.assertEquals("Wrong instruction type", 2, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 24, output.readUnsignedShort());
output.skipBytes(4);
byte[] actual = new byte[8];
output.readBytes(actual);
Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", ByteBufUtils.bytesToHexString(actual));
actual = new byte[8];
output.readBytes(actual);
Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", ByteBufUtils.bytesToHexString(actual));
Assert.assertEquals("Wrong instruction type", 5, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
output.skipBytes(4);
Assert.assertEquals("Wrong instruction type", 6, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction meter-id", 42, output.readUnsignedInt());
Assert.assertEquals("Wrong instruction type", 3, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 32, output.readUnsignedShort());
output.skipBytes(4);
Assert.assertEquals("Wrong action type", 0, output.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, output.readUnsignedShort());
Assert.assertEquals("Wrong action type", 45, output.readUnsignedInt());
Assert.assertEquals("Wrong action type", 55, output.readUnsignedShort());
output.skipBytes(6);
Assert.assertEquals("Wrong action type", 23, output.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
Assert.assertEquals("Wrong action type", 64, output.readUnsignedByte());
output.skipBytes(3);
Assert.assertEquals("Wrong instruction type", 4, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 24, output.readUnsignedShort());
output.skipBytes(4);
Assert.assertEquals("Wrong action type", 17, output.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
Assert.assertEquals("Wrong action ethertype", 14, output.readUnsignedShort());
output.skipBytes(2);
Assert.assertEquals("Wrong action type", 27, output.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
output.skipBytes(4);
Assert.assertTrue("Not all data were read", output.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project openflowplugin by opendaylight.
the class MultipartRequestTableFeaturesTest method testMultipartRequestTableFeaturesExperimenter.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestTableFeaturesExperimenter() throws Exception {
MultipartRequestInputFactory factory = new MultipartRequestInputFactory();
factory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(12));
builder.setFlags(new MultipartRequestFlags(true));
TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
tableFeaturesBuilder.setTableId((short) 8);
tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }));
tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }));
tableFeaturesBuilder.setConfig(new TableConfig(true));
tableFeaturesBuilder.setMaxEntries(65L);
TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);
ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
List<TableFeatureProperties> properties = new ArrayList<>();
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);
expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
expBuilder.setExperimenter(new ExperimenterId(43L));
propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
properties.add(propBuilder.build());
tableFeaturesBuilder.setTableFeatureProperties(properties);
List<TableFeatures> tableFeaturesList = new ArrayList<>();
tableFeaturesList.add(tableFeaturesBuilder.build());
MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder();
featuresBuilder.setTableFeatures(tableFeaturesList);
MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 80);
Assert.assertEquals("Wrong type", 12, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort());
out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
Assert.assertEquals("Wrong length", 64, out.readUnsignedShort());
Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte());
out.skipBytes(5);
Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(out, 32));
byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
out.readBytes(metadataMatch);
Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatch);
byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
out.readBytes(metadataWrite);
Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWrite);
Assert.assertEquals("Wrong config", 8, out.readUnsignedInt());
Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt());
Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class), Matchers.any(ByteBuf.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata in project openflowplugin by opendaylight.
the class MultipartReplyTableFeaturesTest method testMultipartReplyTableFeatures.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyTableFeatures() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 0C 00 00 00 00 00 00 " + // first table feature
"00 40 01 00 00 00 00 00 " + // length, tableId, padding
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + //
"00 00 00 00 00 00 00 00 00 00 00 00 00 " + // name
"00 00 00 00 00 00 00 01 " + // metadata match
"00 00 00 00 00 00 00 02 " + // metadata write
"00 00 00 00 " + // config
"00 00 00 2A " + // second table feature
"00 40 02 00 00 00 00 00 " + // length, tableId, padding
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00" + // name
" 00 00 00 00 00 00 00 00 00 00 00 00 00 " + // metadata match
"00 00 00 00 00 00 00 03 " + // metadata write
"00 00 00 00 00 00 00 04 " + // config
"00 00 00 03 " + // max entries
"00 00 00 2B");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size());
TableFeatures feature = message.getTableFeatures().get(0);
Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, feature.getMetadataMatch());
Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
feature = message.getTableFeatures().get(1);
Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 3 }, feature.getMetadataMatch());
Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 4 }, feature.getMetadataWrite());
Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK());
Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue());
}
Aggregations