RecordLayer { public abstract List<AbstractRecord> parseRecordsSoftly(byte[] rawBytes);  abstract List<AbstractRecord> parseRecords(byte[] rawBytes); abstract List<AbstractRecord> parseRecordsSoftly(byte[] rawBytes); abstract void decryptAndDecompressRecord(AbstractRecord records); abstract byte[] prepareRecords(byte[] data, ProtocolMessageType contentType, List<AbstractRecord> records); abstract void setRecordCipher(RecordCipher cipher); abstract void updateEncryptionCipher(); abstract void updateDecryptionCipher(); abstract RecordCipher getEncryptorCipher(); abstract RecordCipher getDecryptorCipher(); abstract AbstractRecord getFreshRecord(); abstract void updateCompressor(); abstract void updateDecompressor();  }
@Test public void testParseRecordsSoftly() { byte[] unparsedRecord = { 0x16, 0x03, 0x03, 0x00, 0x0A, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 }; byte[] unparsedBlob = { 0x16, 0x03, 0x03, 0x00, 0x1A, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 }; byte[] unparsedRecordThenBlob = new byte[unparsedRecord.length + unparsedBlob.length]; System.arraycopy(unparsedRecord, 0, unparsedRecordThenBlob, 0, unparsedRecord.length); System.arraycopy(unparsedBlob, 0, unparsedRecordThenBlob, unparsedRecord.length, unparsedBlob.length); byte[] unparsedBlobThenRecord = new byte[unparsedRecord.length + unparsedBlob.length]; System.arraycopy(unparsedBlob, 0, unparsedBlobThenRecord, 0, unparsedBlob.length); System.arraycopy(unparsedRecord, 0, unparsedBlobThenRecord, unparsedBlob.length, unparsedRecord.length); List<AbstractRecord> records = new LinkedList<>(); records = recordHandler.parseRecordsSoftly(unparsedRecord); assertArrayEquals(unparsedRecord, records.get(0).getCompleteRecordBytes().getOriginalValue()); assertEquals(ProtocolMessageType.HANDSHAKE, records.get(0).getContentMessageType()); records = recordHandler.parseRecordsSoftly(unparsedBlob); assertArrayEquals(unparsedBlob, records.get(0).getCompleteRecordBytes().getOriginalValue()); assertEquals(ProtocolMessageType.UNKNOWN, records.get(0).getContentMessageType()); records = recordHandler.parseRecordsSoftly(unparsedRecordThenBlob); assertArrayEquals(unparsedRecord, records.get(0).getCompleteRecordBytes().getOriginalValue()); assertEquals(ProtocolMessageType.HANDSHAKE, records.get(0).getContentMessageType()); assertArrayEquals(unparsedBlob, records.get(1).getCompleteRecordBytes().getOriginalValue()); assertEquals(ProtocolMessageType.UNKNOWN, records.get(1).getContentMessageType()); records = recordHandler.parseRecordsSoftly(unparsedBlobThenRecord); assertArrayEquals(unparsedBlobThenRecord, records.get(0).getCompleteRecordBytes().getOriginalValue()); assertEquals(ProtocolMessageType.UNKNOWN, records.get(0).getContentMessageType()); }