use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDesc in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method serializeDescBody.
private void serializeDescBody(MultipartReplyBody body, ByteBuf outBuffer) {
MultipartReplyDescCase descCase = (MultipartReplyDescCase) body;
MultipartReplyDesc desc = descCase.getMultipartReplyDesc();
write256String(desc.getMfrDesc(), outBuffer);
write256String(desc.getHwDesc(), outBuffer);
write256String(desc.getSwDesc(), outBuffer);
write32String(desc.getSerialNum(), outBuffer);
write256String(desc.getDpDesc(), outBuffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDesc in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMultipartReplyDescBody.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyDescBody() {
ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 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(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDesc 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDesc in project openflowplugin by opendaylight.
the class MultipartReplyDescDeserializerTest method deserialize.
@Test
public void deserialize() throws Exception {
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
buffer.writeBytes(MANUFACTURER.getBytes());
buffer.writeZero(DESC_STR_LEN - MANUFACTURER.length());
buffer.writeBytes(HARDWARE.getBytes());
buffer.writeZero(DESC_STR_LEN - HARDWARE.length());
buffer.writeBytes(SOFTWARE.getBytes());
buffer.writeZero(DESC_STR_LEN - SOFTWARE.length());
buffer.writeBytes(SERIAL_NUMBER.getBytes());
buffer.writeZero(SERIAL_NUM_LEN - SERIAL_NUMBER.length());
buffer.writeBytes(DESCRIPTION.getBytes());
buffer.writeZero(DESC_STR_LEN - DESCRIPTION.length());
final MultipartReplyDesc reply = (MultipartReplyDesc) deserializeMultipart(buffer);
assertEquals(MANUFACTURER, reply.getManufacturer().trim());
assertEquals(HARDWARE, reply.getHardware().trim());
assertEquals(SOFTWARE, reply.getSoftware().trim());
assertEquals(SERIAL_NUMBER, reply.getSerialNumber().trim());
assertEquals(DESCRIPTION, reply.getDescription().trim());
assertEquals(0, buffer.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDesc in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeDescBody.
private void serializeDescBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
MultipartReplyDescCase descCase = (MultipartReplyDescCase) body;
MultipartReplyDesc desc = descCase.getMultipartReplyDesc();
write256String(desc.getMfrDesc(), outBuffer);
write256String(desc.getHwDesc(), outBuffer);
write256String(desc.getSwDesc(), outBuffer);
write32String(desc.getSerialNum(), outBuffer);
write256String(desc.getDpDesc(), outBuffer);
}
Aggregations