use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap in project openflowplugin by opendaylight.
the class OpendaylightMeterStatisticsServiceImplTest method testGetMeterFeatures.
@Test
public void testGetMeterFeatures() throws Exception {
GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder().setNode(createNodeRef("unitProt:123"));
rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyMeterFeaturesCaseBuilder().setMultipartReplyMeterFeatures(new MultipartReplyMeterFeaturesBuilder().setBandTypes(new MeterBandTypeBitmap(true, false)).setCapabilities(new MeterFlags(true, false, false, false)).setMaxBands((short) 71).setMaxColor((short) 72).setMaxMeter(73L).build()).build()).build())).build();
final Future<RpcResult<GetMeterFeaturesOutput>> resultFuture = meterStatisticsService.getMeterFeatures(input.build());
Assert.assertTrue(resultFuture.isDone());
final RpcResult<GetMeterFeaturesOutput> rpcResult = resultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPMETERFEATURES, requestInput.getValue().getType());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMeterFeaturesSerialize.
@Test
public void testMeterFeaturesSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(11));
final MultipartReplyMeterFeaturesCaseBuilder meterFeaturesCase = new MultipartReplyMeterFeaturesCaseBuilder();
MultipartReplyMeterFeaturesBuilder meterFeatures = new MultipartReplyMeterFeaturesBuilder();
meterFeatures.setMaxMeter(1L);
meterFeatures.setBandTypes(new MeterBandTypeBitmap(true, false));
meterFeatures.setCapabilities(new MeterFlags(true, false, true, false));
meterFeatures.setMaxBands((short) 1);
meterFeatures.setMaxColor((short) 1);
meterFeaturesCase.setMultipartReplyMeterFeatures(meterFeatures.build());
builder.setMultipartReplyBody(meterFeaturesCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 30);
Assert.assertEquals("Wrong type", MultipartType.OFPMPMETERFEATURES.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyMeterFeaturesCase body = (MultipartReplyMeterFeaturesCase) message.getMultipartReplyBody();
MultipartReplyMeterFeatures messageOutput = body.getMultipartReplyMeterFeatures();
Assert.assertEquals("Wrong max meter", messageOutput.getMaxMeter().intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong band type", messageOutput.getBandTypes(), createMeterBandTypeBitmap(serializedBuffer.readInt()));
Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(), createMeterFlags(serializedBuffer.readShort()));
Assert.assertEquals("Wrong max bands", messageOutput.getMaxBands().shortValue(), serializedBuffer.readUnsignedByte());
Assert.assertEquals("Wrong max color", messageOutput.getMaxColor().shortValue(), serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(2);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap in project openflowplugin by opendaylight.
the class MultipartReplyMeterFeaturesTest method testMultipartReplyMeterFeatures.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyMeterFeatures() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 0B 00 01 00 00 00 00 " + // maxMeter
"00 00 00 0A " + // bandTypes
"00 00 00 06 " + // capabilities
"00 00 00 0F " + // maxBands, maxColor, padding
"07 08 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures();
Assert.assertEquals("Wrong maxMeter", 10, message.getMaxMeter().intValue());
Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, true), message.getBandTypes());
Assert.assertEquals("Wrong capabilities", new MeterFlags(true, true, true, true), message.getCapabilities());
Assert.assertEquals("Wrong maxBands", 7, message.getMaxBands().intValue());
Assert.assertEquals("Wrong maxColor", 8, message.getMaxColor().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap in project openflowplugin by opendaylight.
the class MultipartReplyMeterFeaturesTest method testMultipartReplyMeterFeatures2.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyMeterFeatures2() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 0B 00 01 00 00 00 00 " + // maxMeter
"00 00 00 09 " + // bandTypes
"00 00 00 00 " + // capabilities
"00 00 00 00 " + // maxBands, maxColor, padding
"03 04 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures();
Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue());
Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(false, false), message.getBandTypes());
Assert.assertEquals("Wrong capabilities", new MeterFlags(false, false, false, false), message.getCapabilities());
Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue());
Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtilTest method translateMeterFeatures.
@Test
public void translateMeterFeatures() {
final MultipartReply multipartReply = buildReply(MultipartType.OFPMPMETERFEATURES, new MultipartReplyMeterFeaturesCaseBuilder().setMultipartReplyMeterFeatures(new MultipartReplyMeterFeaturesBuilder().setMaxMeter(10L).setCapabilities(new MeterFlags(true, false, false, false)).setBandTypes(new MeterBandTypeBitmap(true, false)).build()).build());
dummyAssertReply(multipartReply);
}
Aggregations