Example usage for io.netty.buffer ByteBuf readShort

List of usage examples for io.netty.buffer ByteBuf readShort

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf readShort.

Prototype

public abstract short readShort();

Source Link

Document

Gets a 16-bit short integer at the current readerIndex and increases the readerIndex by 2 in this buffer.

Usage

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java

License:Open Source License

/**
 * @throws Exception//from w w  w  .  j a v  a  2s.  c  o  m
 * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
 */
@Test
public void testMultipartRequestExperimenterMessageFactory() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setType(MultipartType.forValue(0xffff));
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setMultipartRequestBody(createRequestExperimenter());
    MultipartRequestInput message = builder.build();

    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
    factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);

    BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
    Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
    out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
    Assert.assertEquals("Wrong experimenterBody", message.getMultipartRequestBody(),
            decodeRequestExperimenter(out));
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java

License:Open Source License

/**
 * @throws Exception//from  www .  j  a  va2 s .com
 * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
 */
@Test
public void testMultipartRequestDescMessageFactory() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setType(MultipartType.forValue(0));
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setMultipartRequestBody(createRequestDesc());
    MultipartRequestInput message = builder.build();

    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance();
    factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);

    BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
    Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FeaturesReplyMessageFactoryTest.java

License:Open Source License

@Test
public void testSerialize() throws Exception {
    GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setDatapathId(BigInteger.valueOf(1L));
    builder.setBuffers(1L);//from   ww  w .j  a v a2 s  .c o  m
    builder.setTables((short) 1);
    builder.setCapabilitiesV10(new CapabilitiesV10(true, false, true, false, true, false, true, false));
    builder.setActionsV10(new ActionTypeV10(true, false, true, false, true, false, true, false, true, false,
            true, false, true));
    builder.setPhyPort(createPorts());
    GetFeaturesOutput message = builder.build();

    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 80);
    Assert.assertEquals("Wrong datapath id", message.getDatapathId().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong n buffers", message.getBuffers().longValue(),
            serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong n tables", message.getTables().shortValue(),
            serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(3);
    Assert.assertEquals("Wrong capabilities", message.getCapabilitiesV10(),
            createCapabilities(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", message.getActionsV10(), createActionsV10(serializedBuffer.readInt()));
    PhyPort port = message.getPhyPort().get(0);
    Assert.assertEquals("Wrong port No", port.getPortNo().intValue(), serializedBuffer.readShort());
    byte[] address = new byte[6];
    serializedBuffer.readBytes(address);
    Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(),
            new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
    byte[] name = new byte[16];
    serializedBuffer.readBytes(name);
    Assert.assertEquals("Wrong name", port.getName(), new String(name).trim());
    Assert.assertEquals("Wrong config", port.getConfigV10(), createPortConfig(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong state", port.getStateV10(), createPortState(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong current", port.getCurrentFeaturesV10(),
            createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong advertised", port.getAdvertisedFeaturesV10(),
            createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong supported", port.getSupportedFeaturesV10(),
            createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong peer", port.getPeerFeaturesV10(),
            createPortFeatures(serializedBuffer.readInt()));

}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PortStatusMessageFactoryTest.java

License:Open Source License

@Test
public void testSerialize() throws Exception {
    PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setReason(PortReason.forValue(1));
    builder.setPortNo(1L);//www.  ja v  a2 s  .c  om
    builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
    builder.setName("Port name");
    builder.setConfigV10(new PortConfigV10(true, false, true, false, true, false, true));
    builder.setStateV10(new PortStateV10(true, false, true, false, true, false, true, false));
    builder.setCurrentFeaturesV10(
            new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
    builder.setAdvertisedFeaturesV10(
            new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
    builder.setSupportedFeaturesV10(
            new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
    builder.setPeerFeaturesV10(
            new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
    PortStatusMessage message = builder.build();

    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 64);
    Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(7);
    Assert.assertEquals("Wrong port No", message.getPortNo().intValue(), serializedBuffer.readShort());
    byte[] address = new byte[6];
    serializedBuffer.readBytes(address);
    Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(),
            new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
    byte[] name = new byte[16];
    serializedBuffer.readBytes(name);
    Assert.assertEquals("Wrong name", message.getName(), new String(name).trim());
    Assert.assertEquals("Wrong config", message.getConfigV10(), createPortConfig(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong state", message.getStateV10(), createPortState(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong current", message.getCurrentFeaturesV10(),
            createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong advertised", message.getAdvertisedFeaturesV10(),
            createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong supported", message.getSupportedFeaturesV10(),
            createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong peer", message.getPeerFeaturesV10(),
            createPortFeatures(serializedBuffer.readInt()));
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigReplyMessageFactoryTest.java

License:Open Source License

@Test
public void testSerialize() throws Exception {
    GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setPort(new PortNumber(1L));
    builder.setQueues(createQueues());/*  w ww.  ja  v a 2 s  .  c o m*/
    GetQueueConfigOutput message = builder.build();

    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 40);
    Assert.assertEquals("Wrong port", message.getPort().getValue().longValue(), serializedBuffer.readShort());
    serializedBuffer.skipBytes(6);
    Assert.assertEquals("Wrong queue Id", message.getQueues().get(0).getQueueId().getValue().longValue(),
            serializedBuffer.readInt());
    Assert.assertEquals("Wrong length", 24, serializedBuffer.readShort());
    serializedBuffer.skipBytes(2);
    List<QueueProperty> properties = message.getQueues().get(0).getQueueProperty();
    Assert.assertEquals("Wrong property", properties.get(0).getProperty().getIntValue(),
            serializedBuffer.readShort());
    Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort());
    serializedBuffer.skipBytes(4);
    RateQueueProperty rateQueueProperty = properties.get(0).getAugmentation(RateQueueProperty.class);
    Assert.assertEquals("Wrong rate", rateQueueProperty.getRate().intValue(), serializedBuffer.readShort());
    serializedBuffer.skipBytes(6);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactoryTest.java

License:Open Source License

@Test
public void testDescBodySerialize() throws Exception {
    MultipartReplyMessageBuilder builder;
    builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(0));
    MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder();
    MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder();
    desc.setMfrDesc("Test");
    desc.setHwDesc("Test");
    desc.setSwDesc("Test");
    desc.setSerialNum("12345");
    desc.setDpDesc("Test");
    descCase.setMultipartReplyDesc(desc.build());
    builder.setMultipartReplyBody(descCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 1068);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPDESC.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(),
            createMultipartRequestFlags(serializedBuffer.readShort()));
    Assert.assertEquals("Wrong desc body", message.getMultipartReplyBody(), decodeDescBody(serializedBuffer));
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactoryTest.java

License:Open Source License

@Test
public void testFlowBodySerialize() throws Exception {
    MultipartReplyMessageBuilder builder;
    builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(1));
    MultipartReplyFlowCaseBuilder flowCase = new MultipartReplyFlowCaseBuilder();
    MultipartReplyFlowBuilder flow = new MultipartReplyFlowBuilder();
    flow.setFlowStats(createFlowStats());
    flowCase.setMultipartReplyFlow(flow.build());
    builder.setMultipartReplyBody(flowCase.build());
    MultipartReplyMessage message = builder.build();

    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 108);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPFLOW.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(),
            createMultipartRequestFlags(serializedBuffer.readShort()));
    FlowStats flowStats = flow.getFlowStats().get(0);
    Assert.assertEquals("Wrong length", 96, serializedBuffer.readShort());
    Assert.assertEquals("Wrong Table ID", flowStats.getTableId().intValue(),
            serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(1);//from w  w  w .  j  a v a 2s.  c  o m
    Assert.assertEquals("Wrong wildcards", 3678463, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong inPort", 58, serializedBuffer.readUnsignedShort());
    byte[] dlSrc = new byte[6];
    serializedBuffer.readBytes(dlSrc);
    Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
    byte[] dlDst = new byte[6];
    serializedBuffer.readBytes(dlDst);
    Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst));
    Assert.assertEquals("Wrong dlVlan", 18, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong dlVlanPcp", 5, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(1);
    Assert.assertEquals("Wrong dlType", 42, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong nwTos", 4, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong nwProto", 7, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(2);
    Assert.assertEquals("Wrong nwSrc", 134744072, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong nwDst", 269488144, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong tpSrc", 6653, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong tpDst", 6633, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong duration sec", flowStats.getDurationSec().intValue(),
            serializedBuffer.readInt());
    Assert.assertEquals("Wrong duration nsec", flowStats.getDurationNsec().intValue(),
            serializedBuffer.readInt());
    Assert.assertEquals("Wrong priority", flowStats.getPriority().intValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong idle timeout", flowStats.getIdleTimeout().intValue(),
            serializedBuffer.readShort());
    Assert.assertEquals("Wrong hard timeout", flowStats.getHardTimeout().intValue(),
            serializedBuffer.readShort());
    serializedBuffer.skipBytes(6);
    Assert.assertEquals("Wrong cookie", flowStats.getCookie().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong Packet count", flowStats.getPacketCount().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong Byte count", flowStats.getByteCount().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong port", 42, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong maxlength", 50, serializedBuffer.readUnsignedShort());
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactoryTest.java

License:Open Source License

@Test
public void testAggregateBodySerialize() throws Exception {
    MultipartReplyMessageBuilder builder;
    builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(2));
    MultipartReplyAggregateCaseBuilder aggregateCase = new MultipartReplyAggregateCaseBuilder();
    MultipartReplyAggregateBuilder aggregate = new MultipartReplyAggregateBuilder();
    aggregate.setPacketCount(BigInteger.valueOf(1234L));
    aggregate.setByteCount(BigInteger.valueOf(1234L));
    aggregate.setFlowCount(1L);/*w ww . j  a va 2s .c o  m*/
    aggregateCase.setMultipartReplyAggregate(aggregate.build());
    builder.setMultipartReplyBody(aggregateCase.build());
    MultipartReplyMessage message = builder.build();

    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 36);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPAGGREGATE.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(),
            createMultipartRequestFlags(serializedBuffer.readShort()));
    Assert.assertEquals("Wrong Packet count", 1234L, serializedBuffer.readLong());
    Assert.assertEquals("Wrong Byte count", 1234L, serializedBuffer.readLong());
    Assert.assertEquals("Wrong flow count", 1L, serializedBuffer.readInt());
    serializedBuffer.skipBytes(4);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactoryTest.java

License:Open Source License

@Test
public void testTableBodySerialize() throws Exception {
    MultipartReplyMessageBuilder builder;
    builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(3));
    MultipartReplyTableCaseBuilder tableCase = new MultipartReplyTableCaseBuilder();
    MultipartReplyTableBuilder table = new MultipartReplyTableBuilder();
    table.setTableStats(createTableStats());
    tableCase.setMultipartReplyTable(table.build());
    builder.setMultipartReplyBody(tableCase.build());
    MultipartReplyMessage message = builder.build();

    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 60);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLE.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(),
            createMultipartRequestFlags(serializedBuffer.readShort()));
    Assert.assertEquals("Wrong table id", 1, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(3);/*  w w w  . j  av  a2 s  .  c o m*/
    Assert.assertEquals("Wrong name", "Table name",
            ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 16));
    Assert.assertEquals("Wrong wildcards", 3145983, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong max entries", 1L, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong active count", 1L, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong lookup count", 1234L, serializedBuffer.readLong());
    Assert.assertEquals("Wrong matched count", 1234L, serializedBuffer.readLong());
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactoryTest.java

License:Open Source License

@Test
public void testPortStatsBodySerialize() throws Exception {
    MultipartReplyMessageBuilder builder;
    builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(4));
    MultipartReplyPortStatsCaseBuilder portStatsCase = new MultipartReplyPortStatsCaseBuilder();
    MultipartReplyPortStatsBuilder portStats = new MultipartReplyPortStatsBuilder();
    portStats.setPortStats(createPortStats());
    portStatsCase.setMultipartReplyPortStats(portStats.build());
    builder.setMultipartReplyBody(portStatsCase.build());
    MultipartReplyMessage message = builder.build();

    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 118);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTSTATS.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(),
            createMultipartRequestFlags(serializedBuffer.readShort()));
    MultipartReplyPortStatsCase body = (MultipartReplyPortStatsCase) message.getMultipartReplyBody();
    MultipartReplyPortStats messageOutput = body.getMultipartReplyPortStats();
    PortStats portStatsOutput = messageOutput.getPortStats().get(0);
    Assert.assertEquals("Wrong port no", portStatsOutput.getPortNo().intValue(), serializedBuffer.readInt());
    serializedBuffer.skipBytes(6);/*w  ww .j ava2s . com*/
    Assert.assertEquals("Wrong rx packets", portStatsOutput.getRxPackets().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong tx packets", portStatsOutput.getTxPackets().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong rx bytes", portStatsOutput.getRxBytes().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong tx bytes", portStatsOutput.getTxBytes().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong rx dropped", portStatsOutput.getRxDropped().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong tx dropped", portStatsOutput.getTxDropped().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong rx errors", portStatsOutput.getRxErrors().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong tx errors", portStatsOutput.getTxErrors().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong rx frame err", portStatsOutput.getRxFrameErr().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong rx over err", portStatsOutput.getRxOverErr().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong rx crc err", portStatsOutput.getRxCrcErr().longValue(),
            serializedBuffer.readLong());
    Assert.assertEquals("Wrong collisions", portStatsOutput.getCollisions().longValue(),
            serializedBuffer.readLong());
}