use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig 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.table.types.rev131026.TableConfig 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.table.types.rev131026.TableConfig in project openflowplugin by opendaylight.
the class TableFeaturesConvertorTest method testToTableFeaturesRequest.
@Test
public void testToTableFeaturesRequest() throws Exception {
List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> tableFeaturesList = new ArrayList<>();
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder tableFeaturesBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder();
for (int i = 0; i < 10; i++) {
tableFeaturesBuilder.setTableId((short) i);
tableFeaturesBuilder.setName(String.format("table:%d", i));
tableFeaturesBuilder.setMetadataMatch(BigInteger.ONE);
tableFeaturesBuilder.setMetadataWrite(BigInteger.ONE);
tableFeaturesBuilder.setMaxEntries((long) 1 + 10 * i);
tableFeaturesBuilder.setConfig(new TableConfig(false));
tableFeaturesBuilder.setTableProperties(getTableProperties());
tableFeaturesList.add(tableFeaturesBuilder.build());
}
TableFeatures tableFeatures = new UpdatedTableBuilder().setTableFeatures(tableFeaturesList).build();
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
Optional<List<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>> tableFeaturesesOptional = convertorManager.convert(tableFeatures, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
assertNotNull(tableFeatures);
assertEquals(10, tableFeatures.getTableFeatures().size());
List<TableFeatureProperties> tableFeaturePropertieses = tableFeatures.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties();
assertEquals(AUGMENTATIONS_MAP.size() + 1, tableFeaturePropertieses.size());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss applyActionsMiss = null;
for (int i = 0; i < tableFeaturePropertieses.size(); i++) {
if (tableFeaturePropertieses.get(i).getTableFeaturePropType().getImplementedInterface().isAssignableFrom(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss.class)) {
applyActionsMiss = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss) tableFeaturePropertieses.get(i).getTableFeaturePropType();
break;
}
}
assertNotNull(applyActionsMiss);
assertEquals(ACTIONS.size(), applyActionsMiss.getApplyActionsMiss().getAction().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig in project openflowplugin by opendaylight.
the class TableModInputMessageFactoryTest method test.
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("09 00 00 00 00 00 00 01");
TableModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(deserializedMessage);
// Test Message
Assert.assertEquals("Wrong table id ", new TableId(9L), deserializedMessage.getTableId());
Assert.assertEquals("Wrong config ", new TableConfig(true), deserializedMessage.getConfig());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig in project openflowplugin by opendaylight.
the class TableFeaturesConvertor method convert.
@Override
public List<TableFeatures> convert(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures source, VersionConvertorData data) {
List<TableFeatures> ofTableFeaturesList = new ArrayList<>();
TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures salTableFeatures : source.getTableFeatures()) {
ofTableFeatures.setTableId(salTableFeatures.getTableId());
ofTableFeatures.setName(salTableFeatures.getName());
ofTableFeatures.setMetadataMatch(salTableFeatures.getMetadataMatch());
ofTableFeatures.setMetadataWrite(salTableFeatures.getMetadataWrite());
ofTableFeatures.setMaxEntries(salTableFeatures.getMaxEntries());
if (salTableFeatures.getConfig() != null) {
ofTableFeatures.setConfig(new TableConfig(salTableFeatures.getConfig().isDEPRECATEDMASK()));
}
ofTableFeatures.setTableFeatureProperties(toTableProperties(salTableFeatures.getTableProperties()));
ofTableFeaturesList.add(ofTableFeatures.build());
}
return ofTableFeaturesList;
}
Aggregations