public void checkVarDelimitedBoundry(int initialGap, int secondWriteSize) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    int bufferSize = BUF_SIZE;
    final LinkedBuffer lb = new LinkedBuffer(bufferSize);
    WriteSession session = new WriteSession(lb, bufferSize);

    // Should fill up the buffer with initialGap byte(s) left
    StreamedStringSerializer.writeUTF8(repeatChar('a', bufferSize - initialGap), session, out, lb);

    // Write a string of length secondWriteSize that should be larger
    // than the next buffer size
    assertTrue(secondWriteSize > bufferSize);
    StreamedStringSerializer.writeUTF8VarDelimited(
        repeatChar('a', secondWriteSize), session, out, lb);
  }
  static void checkVarDelimited(String str, int size, int stringLen) throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    LinkedBuffer lb = new LinkedBuffer(BUF_SIZE);
    WriteSession session = new WriteSession(lb);
    StreamedStringSerializer.writeUTF8VarDelimited(str, session, out, lb);
    LinkedBuffer.writeTo(out, lb);

    byte[] buf = out.toByteArray();

    assertTrue(buf.length == stringLen + size);

    int len = readRawVarint32(buf, 0);
    assertTrue(len == stringLen);

    print("total len: " + buf.length);
  }