PSKKeyExchangeModesExtensionSerializer extends ExtensionSerializer<PSKKeyExchangeModesExtensionMessage> { @Override public byte[] serializeExtensionContent() { LOGGER.debug("Serializing PSKKeyExchangeModesExtensionMessage"); writeKeyExchangeModesListLength(msg); writeKeyExchangeModesListBytes(msg); return getAlreadySerialized(); } PSKKeyExchangeModesExtensionSerializer(PSKKeyExchangeModesExtensionMessage message); @Override byte[] serializeExtensionContent();  }
@Test public void testSerializeExtensionContent() { PSKKeyExchangeModesExtensionMessage validMsg = new PSKKeyExchangeModesExtensionMessage(); validMsg.setKeyExchangeModesListLength(2); validMsg.setKeyExchangeModesListBytes(new byte[] { 1, 0 }); assertArrayEquals(new byte[] { 2, 1, 0 }, new PSKKeyExchangeModesExtensionSerializer(validMsg).serializeExtensionContent()); PSKKeyExchangeModesExtensionMessage invalidEmptyMsg = new PSKKeyExchangeModesExtensionMessage(); invalidEmptyMsg.setKeyExchangeModesListLength(0); invalidEmptyMsg.setKeyExchangeModesListBytes(new byte[0]); assertArrayEquals(new byte[] { 0 }, new PSKKeyExchangeModesExtensionSerializer(invalidEmptyMsg).serializeExtensionContent()); }