Search in sources :

Example 11 with MeterBandHeader

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);
}
Also used : DscpRemark(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemark) MeterMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterMessage) MeterBandHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader) Drop(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop) Test(org.junit.Test) AbstractDeserializerTest(org.opendaylight.openflowplugin.impl.protocol.deserialization.AbstractDeserializerTest)

Aggregations

MeterBandHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)10 ArrayList (java.util.ArrayList)8 MeterBandType (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType)8 DscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder)8 MeterBandHeadersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder)8 MeterBandHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder)8 MeterBandTypesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder)8 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags)6 DscpRemark (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemark)6 Experimenter (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter)6 Drop (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop)5 DropBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder)5 Test (org.junit.Test)4 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)4 ExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.ExperimenterBuilder)4 MeterBandHeaders (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeaders)4 ExperimenterIdMeterBand (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand)4 MeterBand (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand)4 MeterBandDropCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase)4 MeterBandDscpRemarkCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase)4