@Test public void testSerialize() { OF10PacketInMessageFactory serializer = new OF10PacketInMessageFactory(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(message, serializedBuffer); BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 34); Assert.assertEquals("Wrong buffer id", message.getBufferId().longValue(), serializedBuffer.readUnsignedInt()); Assert.assertEquals("Wrong total len", message.getTotalLen().intValue(), serializedBuffer.readUnsignedShort()); Assert.assertEquals("Wrong port in", message.getInPort().intValue(), serializedBuffer.readUnsignedShort()); Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte()); serializedBuffer.skipBytes(1); Assert.assertArrayEquals("Wrong data", message.getData(), serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); }
@Override public void serialize(PacketInMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeShort(message.getTotalLen().intValue()); outBuffer.writeShort(message.getInPort()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); byte[] data = message.getData(); if (data != null) { outBuffer.writeBytes(data); } ByteBufUtils.updateOFHeaderLength(outBuffer); }
OF10PacketInMessageFactory implements OFSerializer<PacketInMessage> { @Override public void serialize(PacketInMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeShort(message.getTotalLen().intValue()); outBuffer.writeShort(message.getInPort()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); byte[] data = message.getData(); if (data != null) { outBuffer.writeBytes(data); } ByteBufUtils.updateOFHeaderLength(outBuffer); } }
OF10PacketInMessageFactory implements OFSerializer<PacketInMessage> { @Override public void serialize(PacketInMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeShort(message.getTotalLen().intValue()); outBuffer.writeShort(message.getInPort()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); byte[] data = message.getData(); if (data != null) { outBuffer.writeBytes(data); } ByteBufUtils.updateOFHeaderLength(outBuffer); }  }
OF10PacketInMessageFactory implements OFSerializer<PacketInMessage> { @Override public void serialize(PacketInMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeShort(message.getTotalLen().intValue()); outBuffer.writeShort(message.getInPort()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); byte[] data = message.getData(); if (data != null) { outBuffer.writeBytes(data); } ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(PacketInMessage message, ByteBuf outBuffer); }
OF10PacketInMessageFactory implements OFSerializer<PacketInMessage> { @Override public void serialize(PacketInMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeShort(message.getTotalLen().intValue()); outBuffer.writeShort(message.getInPort()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); byte[] data = message.getData(); if (data != null) { outBuffer.writeBytes(data); } ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(PacketInMessage message, ByteBuf outBuffer);  }