use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter in project openflowplugin by opendaylight.
the class BundleControlFactoryTest method testDeserializeWithProperties.
@Test
public void testDeserializeWithProperties() {
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf(// bundle ID
"00 00 00 01 " + // type
"00 05 " + // flags
"00 02 " + // type 1
"ff ff " + // length 1
"00 0c " + // experimenter ID 1
"00 00 00 01 " + // experimenter type 1
"00 00 00 02 " + // experimenter data 1
"00 00 00 00 " + // type 2
"00 00 " + // length 2
"00 04 " + // data 2
"00 00 00 00");
Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(experimenterPropertyDeserializer);
((DeserializerRegistryInjector) factory).injectDeserializerRegistry(registry);
BundleControlOnf builtByFactory = factory.deserialize(buffer);
Assert.assertEquals(1, builtByFactory.getOnfControlGroupingData().getBundleId().getValue().intValue());
BundleFlags flags = new BundleFlags(false, true);
Assert.assertEquals("Wrong atomic flag", flags.isAtomic(), builtByFactory.getOnfControlGroupingData().getFlags().isAtomic());
Assert.assertEquals("Wrong ordered flag", flags.isOrdered(), builtByFactory.getOnfControlGroupingData().getFlags().isOrdered());
Assert.assertEquals("Wrong type", BundleControlType.ONFBCTCOMMITREPLY, builtByFactory.getOnfControlGroupingData().getType());
BundleProperty property = builtByFactory.getOnfControlGroupingData().getBundleProperty().get(0);
Assert.assertEquals("Wrong bundle property type", BundlePropertyType.ONFETBPTEXPERIMENTER, property.getType());
BundlePropertyExperimenter experimenterProperty = (BundlePropertyExperimenter) property.getBundlePropertyEntry();
Assert.assertEquals("Wrong experimenter ID", 1, experimenterProperty.getExperimenter().getValue().intValue());
Assert.assertEquals("Wrong experimenter type", 2, experimenterProperty.getExpType().longValue());
Mockito.verify(experimenterPropertyDeserializer, Mockito.times(1)).deserialize(buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter in project openflowplugin by opendaylight.
the class MultipartRequestInputFactory method serializeExperimenterBody.
private void serializeExperimenterBody(final MultipartRequestInput message, final ByteBuf outBuffer) {
MultipartRequestExperimenterCase expCase = (MultipartRequestExperimenterCase) message.getMultipartRequestBody();
MultipartRequestExperimenter experimenter = expCase.getMultipartRequestExperimenter();
final long expId = experimenter.getExperimenter().getValue().longValue();
final long expType = experimenter.getExpType().longValue();
// write experimenterId and type
outBuffer.writeInt((int) expId);
outBuffer.writeInt((int) expType);
// serialize experimenter data
OFSerializer<ExperimenterDataOfChoice> serializer = registry.getSerializer(ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey(EncodeConstants.OF13_VERSION_ID, expId, expType));
serializer.serialize(experimenter.getExperimenterDataOfChoice(), outBuffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter in project openflowplugin by opendaylight.
the class TableFeaturesConvertor method toTableProperties.
private static List<TableFeatureProperties> toTableProperties(final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties tableProperties) {
if (tableProperties == null) {
return Collections.emptyList();
}
List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(tableProperties.getTableFeatureProperties());
for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties property : sortedTableProperties) {
TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType propType = property.getTableFeaturePropType();
setTableFeatureProperty(propType);
if (propType instanceof Instructions) {
setTableFeatureProperty((Instructions) propType, propBuilder);
} else if (propType instanceof InstructionsMiss) {
setTableFeatureProperty((InstructionsMiss) propType, propBuilder);
} else if (propType instanceof NextTable) {
setTableFeatureProperty((NextTable) propType, propBuilder);
} else if (propType instanceof NextTableMiss) {
setTableFeatureProperty((NextTableMiss) propType, propBuilder);
} else if (propType instanceof WriteActions) {
setTableFeatureProperty((WriteActions) propType, propBuilder);
} else if (propType instanceof WriteActionsMiss) {
setTableFeatureProperty((WriteActionsMiss) propType, propBuilder);
} else if (propType instanceof ApplyActions) {
setTableFeatureProperty((ApplyActions) propType, propBuilder);
} else if (propType instanceof ApplyActionsMiss) {
setTableFeatureProperty((ApplyActionsMiss) propType, propBuilder);
} else if (propType instanceof Match) {
setTableFeatureProperty((Match) propType, propBuilder);
} else if (propType instanceof Wildcards) {
setTableFeatureProperty((Wildcards) propType, propBuilder);
} else if (propType instanceof WriteSetfield) {
setTableFeatureProperty((WriteSetfield) propType, propBuilder);
} else if (propType instanceof WriteSetfieldMiss) {
setTableFeatureProperty((WriteSetfieldMiss) propType, propBuilder);
} else if (propType instanceof ApplySetfield) {
setTableFeatureProperty((ApplySetfield) propType, propBuilder);
} else if (propType instanceof ApplySetfieldMiss) {
setTableFeatureProperty((ApplySetfieldMiss) propType, propBuilder);
}
// Experimenter and Experimenter miss Table features are unhandled
ofTablePropertiesList.add(propBuilder.build());
}
return ofTablePropertiesList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter in project openflowplugin by opendaylight.
the class BundleControlFactoryTest method testSerialize.
private void testSerialize(final boolean withProperty) {
final OnfControlGroupingDataBuilder dataBuilder = new OnfControlGroupingDataBuilder();
dataBuilder.setBundleId(new BundleId(1L));
dataBuilder.setType(BundleControlType.ONFBCTOPENREQUEST);
dataBuilder.setFlags(new BundleFlags(true, true));
if (withProperty) {
dataBuilder.setBundleProperty(new ArrayList<>(Collections.singleton(BundleTestUtils.createExperimenterProperty(propertyExperimenterData))));
Mockito.when(registry.getSerializer(Matchers.any())).thenReturn(propertySerializer);
((SerializerRegistryInjector) factory).injectSerializerRegistry(registry);
}
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(new BundleControlOnfBuilder().setOnfControlGroupingData(dataBuilder.build()).build(), out);
Assert.assertEquals("Wrong bundle ID", 1L, out.readUnsignedInt());
Assert.assertEquals("Wrong type", BundleControlType.ONFBCTOPENREQUEST.getIntValue(), out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 3, out.readUnsignedShort());
if (withProperty) {
Assert.assertEquals("Wrong property type", BundlePropertyType.ONFETBPTEXPERIMENTER.getIntValue(), out.readUnsignedShort());
// length
out.readUnsignedShort();
Assert.assertEquals("Wrong experimenter ID", 1, out.readUnsignedInt());
Assert.assertEquals("Wrong experimenter type", 2, out.readUnsignedInt());
Mockito.verify(propertySerializer, Mockito.times(1)).serialize(propertyExperimenterData, out);
} else {
Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMultipartReplyGroupDescBody04.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
* Test covers bodies of actions NW TTL, Experimenter.
*/
@Test
public void testMultipartReplyGroupDescBody04() {
ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 " + // len
"00 30 " + // type
"01 " + // pad
"00 " + // groupId
"00 00 00 08 " + // bucketLen
"00 28 " + // bucketWeight
"00 06 " + // bucketWatchPort
"00 00 00 05 " + // bucketWatchGroup
"00 00 00 04 " + // bucketPad
"00 00 00 00 " + // nwTTlType
"00 17 " + // nwTTlLen
"00 08 " + // nwTTlnwTTL
"0E " + // nwTTlPad
"00 00 00 " + // setFieldType
"00 19 " + // setFieldLen
"00 10 " + // setFieldOXMClass
"80 00 " + // setFieldOXMField
"00 " + // setFieldOXMLength
"04 " + // setFieldPort
"00 00 00 FF " + "00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue());
Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue());
Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
Assert.assertTrue("Wrong nwTTlType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice() instanceof SetNwTtlCase);
Assert.assertEquals("Wrong nwTTlnwTTL", 14, ((SetNwTtlCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice()).getSetNwTtlAction().getNwTtl().intValue());
Assert.assertTrue("Wrong setFieldType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1).getActionChoice() instanceof SetFieldCase);
Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1).getActionChoice()).getSetFieldAction().getMatchEntry().get(0).getOxmClass());
Assert.assertEquals("Wrong setFieldOXMField", InPort.class, ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1).getActionChoice()).getSetFieldAction().getMatchEntry().get(0).getOxmMatchField());
MatchEntry entry = ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1).getActionChoice()).getSetFieldAction().getMatchEntry().get(0);
Assert.assertEquals("Wrong setFieldOXMValue", 255, ((InPortCase) entry.getMatchEntryValue()).getInPort().getPortNumber().getValue().intValue());
}
Aggregations