AlertSerializer extends ProtocolMessageSerializer<AlertMessage> { @Override public byte[] serializeProtocolMessageContent() { LOGGER.debug("Serializing AlertMessage"); writeLevel(msg); writeDescription(msg); return getAlreadySerialized(); } AlertSerializer(AlertMessage message, ProtocolVersion version); @Override byte[] serializeProtocolMessageContent();  }
@Test public void testSerializeProtocolMessageContent() { AlertMessage message = new AlertMessage(); message.setLevel(level); message.setDescription(description); message.setCompleteResultingMessage(expectedPart); AlertSerializer serializer = new AlertSerializer(message, ProtocolVersion.TLS12); assertArrayEquals(expectedPart, serializer.serialize()); }