ExtendedRandomExtensionSerializer extends ExtensionSerializer<ExtendedRandomExtensionMessage> { @Override public byte[] serializeExtensionContent() { writeExtendedRandomLength(message); writeExtendedRandom(message); return getAlreadySerialized(); } ExtendedRandomExtensionSerializer(ExtendedRandomExtensionMessage message); @Override byte[] serializeExtensionContent();  }
@Test public void testSerializeExtensionContent() { message = new ExtendedRandomExtensionMessage(); message.setExtensionType(extensionType.getValue()); message.setExtensionLength(extensionLength); message.setExtendedRandom(extendedRandom); message.setExtendedRandomLength(extendedRandom.length); ExtendedRandomExtensionSerializer serializer = new ExtendedRandomExtensionSerializer(message); assertArrayEquals(expectedBytes, serializer.serialize()); }