use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader in project openflowplugin by opendaylight.
the class MeterMessageDeserializerTest method deserialize.
@Test
public void deserialize() throws Exception {
// Message type
buffer.writeByte(TYPE);
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
buffer.writeInt(XID);
buffer.writeShort(COMMAND.getIntValue());
buffer.writeShort(ByteBufUtils.fillBitMask(0, IS_KBPS, IS_PKTPS, IS_BURST, IS_STATS));
buffer.writeInt(ID);
// Drop band
buffer.writeShort(1);
buffer.writeInt(DROP_RATE);
buffer.writeInt(DROP_BURST);
buffer.writeZero(PADDING_IN_METER_BAND_DROP_HEADER);
// Dscp remark band
buffer.writeShort(2);
buffer.writeInt(DSCP_RATE);
buffer.writeInt(DSCP_BURST);
buffer.writeByte(DSCP_PREC);
buffer.writeZero(PADDING_IN_METER_BAND_DSCP_HEADER);
final MeterMessage message = (MeterMessage) getFactory().deserialize(buffer, EncodeConstants.OF13_VERSION_ID);
assertEquals(message.getXid().intValue(), XID);
assertEquals(message.getCommand().getIntValue(), COMMAND.getIntValue());
assertEquals(message.getFlags().isMeterBurst(), IS_BURST);
assertEquals(message.getFlags().isMeterKbps(), IS_KBPS);
assertEquals(message.getFlags().isMeterPktps(), IS_PKTPS);
assertEquals(message.getFlags().isMeterStats(), IS_STATS);
assertEquals(message.getMeterId().getValue().intValue(), ID);
final List<MeterBandHeader> meterBandHeader = message.getMeterBandHeaders().getMeterBandHeader();
assertEquals(meterBandHeader.size(), 2);
// Drop band
final MeterBandHeader dropHeader = meterBandHeader.get(0);
assertEquals(Drop.class, dropHeader.getBandType().getImplementedInterface());
assertTrue(dropHeader.getMeterBandTypes().getFlags().isOfpmbtDrop());
final Drop drop = Drop.class.cast(dropHeader.getBandType());
assertEquals(DROP_RATE, drop.getDropRate().intValue());
assertEquals(DROP_BURST, drop.getDropBurstSize().intValue());
// Dscp band
final MeterBandHeader dscpHeader = meterBandHeader.get(1);
assertEquals(DscpRemark.class, dscpHeader.getBandType().getImplementedInterface());
assertTrue(dscpHeader.getMeterBandTypes().getFlags().isOfpmbtDscpRemark());
final DscpRemark dscpRemark = DscpRemark.class.cast(dscpHeader.getBandType());
assertEquals(DSCP_RATE, dscpRemark.getDscpRemarkRate().intValue());
assertEquals(DSCP_BURST, dscpRemark.getDscpRemarkBurstSize().intValue());
assertEquals(buffer.readableBytes(), 0);
}
Aggregations