static int encodeTrailingString(
        final UnsafeBuffer encodingBuffer, final int offset, final int remainingCapacity, final String value)
    {
        final int maxLength = remainingCapacity - SIZE_OF_INT;
        if (value.length() <= maxLength)
        {
            return encodingBuffer.putStringAscii(offset, value, LITTLE_ENDIAN);
        }
        else
        {
            encodingBuffer.putInt(offset, maxLength, LITTLE_ENDIAN);
            encodingBuffer.putStringWithoutLengthAscii(offset + SIZE_OF_INT, value, 0, maxLength - 3);
            encodingBuffer.putStringWithoutLengthAscii(offset + SIZE_OF_INT + maxLength - 3, "...");
            return remainingCapacity;
        }
    }
@Test
    void encodeTrailingStringAsAsciiWhenPayloadExceedsMaxMessageSizeWithoutHeader()
    {
        final int offset = 23;
        final int remainingCapacity = 59;
        final char[] chars = new char[100];
        fill(chars, 'x');
        final String value = new String(chars);

        final int encodedLength = encodeTrailingString(buffer, offset, remainingCapacity, value);

        assertEquals(remainingCapacity, encodedLength);
        assertEquals(value.substring(0, remainingCapacity - SIZE_OF_INT - 3) + "...",
            buffer.getStringAscii(offset));
    }