@Test
  public void sendWriteCompositeMessagesTest() throws Exception {
    short savedVersion = MessageFormatRecord.headerVersionToUse;
    if (blobFormatVersion == MessageFormatRecord.Blob_Version_V1) {
      return;
    }

    String putFormat1 = PutMessageFormatBlobV1InputStream.class.getSimpleName();
    String putFormat2 = PutMessageFormatInputStream.class.getSimpleName();
    short headerFormatV1 = MessageFormatRecord.Message_Header_Version_V1;
    short headerFormatV2 = MessageFormatRecord.Message_Header_Version_V2;
    short headerFormatV3 = MessageFormatRecord.Message_Header_Version_V3;

    byte[][] blob = {TestUtils.getRandomBytes(1000), TestUtils.getRandomBytes(2000), TestUtils.getRandomBytes(10000),
        TestUtils.getRandomBytes(20000), TestUtils.getRandomBytes(40000)};
    byte[][] userMetadata =
        {TestUtils.getRandomBytes(200), TestUtils.getRandomBytes(400), TestUtils.getRandomBytes(2000),
            TestUtils.getRandomBytes(4000), TestUtils.getRandomBytes(8000)};
    StoreKey[] storeKeys = {new MockId("64"), new MockId("32"), new MockId("16"), new MockId("08"), new MockId("04")};
    ByteBuffer[] encryptionKeys =
        {ByteBuffer.wrap(TestUtils.getRandomBytes(64)), ByteBuffer.wrap(TestUtils.getRandomBytes(128)),
            ByteBuffer.wrap(TestUtils.getRandomBytes(256)), ByteBuffer.wrap(TestUtils.getRandomBytes(512)),
            ByteBuffer.wrap(TestUtils.getRandomBytes(1024))};
    String putFormat1s[] = {putFormat1, putFormat1, putFormat1, putFormat1, putFormat1};
    String putFormat2s[] = {putFormat2, putFormat2, putFormat2, putFormat2, putFormat2};
    String putFormatComposite1[] = {putFormat1, putFormat2, putFormat2, putFormat2, putFormat1};
    String putFormatComposite2[] = {putFormat2, putFormat1, putFormat1, putFormat2, putFormat2};

    short headerFormat1s[] = {headerFormatV1, headerFormatV1, headerFormatV1, headerFormatV1, headerFormatV1};
    short headerFormat2s[] = {headerFormatV2, headerFormatV2, headerFormatV2, headerFormatV2, headerFormatV2};
    short headerFormat3s[] = {headerFormatV3, headerFormatV3, headerFormatV3, headerFormatV3, headerFormatV3};
    short headerFormatComposite1[] = {headerFormatV1, headerFormatV2, headerFormatV2, headerFormatV1, headerFormatV1};
    short headerFormatComposite2[] = {headerFormatV2, headerFormatV1, headerFormatV1, headerFormatV2, headerFormatV2};
    short headerFormatComposite3[] = {headerFormatV3, headerFormatV2, headerFormatV2, headerFormatV3, headerFormatV3};

    doSendWriteCompositeMessagesTest(blob, userMetadata, storeKeys, encryptionKeys, putFormat1s, headerFormat1s);
    doSendWriteCompositeMessagesTest(blob, userMetadata, storeKeys, encryptionKeys, putFormat2s, headerFormat1s);
    doSendWriteCompositeMessagesTest(blob, userMetadata, storeKeys, encryptionKeys, putFormat2s, headerFormat2s);
    doSendWriteCompositeMessagesTest(blob, userMetadata, storeKeys, encryptionKeys, putFormat2s, headerFormat3s);
    doSendWriteCompositeMessagesTest(blob, userMetadata, storeKeys, encryptionKeys, putFormat2s,
        headerFormatComposite1);
    doSendWriteCompositeMessagesTest(blob, userMetadata, storeKeys, encryptionKeys, putFormat2s,
        headerFormatComposite2);
    doSendWriteCompositeMessagesTest(blob, userMetadata, storeKeys, encryptionKeys, putFormat2s,
        headerFormatComposite3);
    doSendWriteCompositeMessagesTest(blob, userMetadata, storeKeys, encryptionKeys, putFormatComposite1,
        headerFormatComposite1);
    doSendWriteCompositeMessagesTest(blob, userMetadata, storeKeys, encryptionKeys, putFormatComposite2,
        headerFormatComposite2);

    MessageFormatRecord.headerVersionToUse = savedVersion;
  }
Tests involving multiple messages in a single Send involving different combinations of header format versions, put
formats and encryption keys.
ambry-messageformat/src/test/java/com/github/ambry/messageformat/MessageFormatSendTest.java