ClientHelloSerializer extends HelloMessageSerializer<ClientHelloMessage> { @Override public byte[] serializeHandshakeMessageContent() { LOGGER.debug("Serializing ClientHelloMessage"); writeProtocolVersion(); writeRandom(); writeSessionIDLength(); writeSessionID(); if (version.isDTLS()) { if (msg.getCookie() != null) { appendByte(msg.getCookieLength().getValue()); appendBytes(msg.getCookie().getValue()); } else { appendByte(Byte.valueOf((byte) 0)); } } writeCipherSuiteLength(msg); writeCipherSuites(msg); writeCompressionLength(msg); writeCompressions(msg); if (hasExtensionLengthField()) { writeExtensionLength(msg); if (hasExtensions()) { writeExtensionBytes(msg); } } return getAlreadySerialized(); } ClientHelloSerializer(ClientHelloMessage message, ProtocolVersion version); @Override byte[] serializeHandshakeMessageContent();  }
@Test public void testSerializeHandshakeMessageContent() { ClientHelloMessage clientMessage = new ClientHelloMessage(); clientMessage.setLength(length); clientMessage.setType(type.getValue()); clientMessage.setCipherSuiteLength(cipherSuitesLength); clientMessage.setCipherSuites(cipherSuites); clientMessage.setCompressionLength(compressionsLength); clientMessage.setCompressions(compressions); if (cookie != null) { clientMessage.setCookie(cookie); } if (cookieLength != null) { clientMessage.setCookieLength(cookieLength); } if (extensionBytes != null) { clientMessage.setExtensionBytes(extensionBytes); } clientMessage.setExtensionsLength(extensionLength); clientMessage.setSessionId(sessionID); clientMessage.setSessionIdLength(sessionIdLength); clientMessage.setCompleteResultingMessage(expectedPart); clientMessage.setUnixTime(unixtime); clientMessage.setRandom(random); clientMessage.setProtocolVersion(protocolVersion); ClientHelloSerializer serializer = new ClientHelloSerializer(clientMessage, version); assertArrayEquals(expectedPart, serializer.serialize()); }