@Test public void testSerialize() { RoleReplyMessageFactory serializer = new RoleReplyMessageFactory(); SerializerRegistry registry = new NetIdeSerializerRegistryImpl(); registry.init(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24); Assert.assertEquals("Wrong role", message.getRole().getIntValue(), ControllerRole.forValue((int) serializedBuffer.readUnsignedInt()).getIntValue()); serializedBuffer.skipBytes(PADDING); byte[] genId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; serializedBuffer.readBytes(genId); Assert.assertEquals("Wrong generation ID", message.getGenerationId(), new BigInteger(1, genId)); }
@Override public void serialize(RoleRequestOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getRole().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeLong(message.getGenerationId().longValue()); ByteBufUtils.updateOFHeaderLength(outBuffer); }
RoleReplyMessageFactory implements OFSerializer<RoleRequestOutput> { @Override public void serialize(RoleRequestOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getRole().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeLong(message.getGenerationId().longValue()); ByteBufUtils.updateOFHeaderLength(outBuffer); } }
RoleReplyMessageFactory implements OFSerializer<RoleRequestOutput> { @Override public void serialize(RoleRequestOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getRole().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeLong(message.getGenerationId().longValue()); ByteBufUtils.updateOFHeaderLength(outBuffer); }  }
RoleReplyMessageFactory implements OFSerializer<RoleRequestOutput> { @Override public void serialize(RoleRequestOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getRole().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeLong(message.getGenerationId().longValue()); ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(RoleRequestOutput message, ByteBuf outBuffer); }
RoleReplyMessageFactory implements OFSerializer<RoleRequestOutput> { @Override public void serialize(RoleRequestOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getRole().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeLong(message.getGenerationId().longValue()); ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(RoleRequestOutput message, ByteBuf outBuffer);  }