Search in sources :

Example 26 with MultipartReplyMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactoryTest method testDesc.

/**
 * Testing OF10StatsReplyMessageFactory (Desc) for correct deserialization.
 */
@Test
public void testDesc() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00");
    String mfrDesc = "Manufacturer description";
    byte[] mfrDescBytes = new byte[256];
    mfrDescBytes = mfrDesc.getBytes();
    bb.writeBytes(mfrDescBytes);
    bb.writeZero(DESC_STR_LEN - mfrDescBytes.length);
    String hwDesc = "Hardware description";
    byte[] hwDescBytes = new byte[256];
    hwDescBytes = hwDesc.getBytes();
    bb.writeBytes(hwDescBytes);
    bb.writeZero(DESC_STR_LEN - hwDescBytes.length);
    String swDesc = "Software description";
    byte[] swDescBytes = new byte[256];
    swDescBytes = swDesc.getBytes();
    bb.writeBytes(swDescBytes);
    bb.writeZero(DESC_STR_LEN - swDescBytes.length);
    String serialNum = "SN0123456789";
    byte[] serialNumBytes = new byte[32];
    serialNumBytes = serialNum.getBytes();
    bb.writeBytes(serialNumBytes);
    bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length);
    String dpDesc = "switch3 in room 3120";
    byte[] dpDescBytes = new byte[256];
    dpDescBytes = dpDesc.getBytes();
    bb.writeBytes(dpDescBytes);
    bb.writeZero(DESC_STR_LEN - dpDescBytes.length);
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 0, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue());
    MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyDesc message = messageCase.getMultipartReplyDesc();
    Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc());
    Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc());
    Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc());
    Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum());
    Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());
    Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase) MultipartReplyDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc) Test(org.junit.Test)

Example 27 with MultipartReplyMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactoryTest method testTable.

/**
 * Testing OF10StatsReplyMessageFactory (Table) for correct deserialization.
 */
@Test
public void testTable() {
    ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 " + "08 00 00 00 4A 41 4D 45 53 20 42 4F 4E 44 00 00 00 00 00 00 00 00 00 " + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + "00 00 00 30 00 00 00 10 FF 01 01 01 01 01 01 01 FF 01 01 01 01 01 01 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyTable message = messageCase.getMultipartReplyTable();
    Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());
    Assert.assertEquals("Wrong name", "JAMES BOND", message.getTableStats().get(0).getName());
    Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false), message.getTableStats().get(0).getWildcards());
    Assert.assertEquals("Wrong src-mask", 32, message.getTableStats().get(0).getNwSrcMask().intValue());
    Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue());
    Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue());
    Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
    Assert.assertEquals("Wrong lookupCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getTableStats().get(0).getLookupCount());
    Assert.assertEquals("Wrong matchedCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 }), message.getTableStats().get(0).getMatchedCount());
    Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MultipartReplyTable(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable) BigInteger(java.math.BigInteger) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 28 with MultipartReplyMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage 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());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) MeterBandTypeBitmap(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase) Test(org.junit.Test)

Example 29 with MultipartReplyMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage 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());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) MeterBandTypeBitmap(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase) Test(org.junit.Test)

Example 30 with MultipartReplyMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.

the class OF10StatsReplyExperimenterTest method test.

/**
 * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation.
 */
@Test
public void test() {
    Mockito.when(registry.getDeserializer(Matchers.<MessageCodeKey>any())).thenReturn(vendorDeserializer);
    OF10StatsReplyMessageFactory factory = new OF10StatsReplyMessageFactory();
    factory.injectDeserializerRegistry(registry);
    ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " + // expID
    "00 00 00 01");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    Mockito.verify(vendorDeserializer).deserialize(bb);
}
Also used : OF10StatsReplyMessageFactory(org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)61 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)61 ByteBuf (io.netty.buffer.ByteBuf)56 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)24 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)23 BigInteger (java.math.BigInteger)13 DeviceContext (org.opendaylight.openflowplugin.api.openflow.device.DeviceContext)5 MultipartReplyGroupDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase)5 MultipartReplyGroupDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc)5 DataContainer (org.opendaylight.yangtools.yang.binding.DataContainer)5 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags)4 MultipartReplyFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)4 MultipartReplyFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow)4 FlowStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats)4 MeterBandTypeBitmap (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap)3 MultipartReplyAggregateCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase)3 MultipartReplyMeterFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)3 MultipartReplyPortDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase)3 MultipartReplyPortStatsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase)3 MultipartReplyQueueCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase)3