public void testMultipleLargeStringsExceedingBufferSize() throws Exception
    {
        LinkedBuffer buffer = LinkedBuffer.allocate(256);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        WriteSession session = new WriteSession(buffer, out);
        String utf8OneByte = repeatChar('a', 1024);
        String utf8TwoBytes = repeatChar((char) 0x7ff, 1024 / 2);
        String utf8ThreeBytes = repeatChar((char) 0x800, 1024 / 3);

        writeToSession(utf8OneByte, utf8TwoBytes, utf8ThreeBytes, session, false);
        assertTrue(session.tail == session.head);
        // flush remaining
        LinkedBuffer.writeTo(out, buffer);
        // clear
        buffer.clear();

        byte[] data = out.toByteArray();

        LinkedBuffer buffer2 = LinkedBuffer.allocate(256);
        WriteSession session2 = new WriteSession(buffer2);

        writeToSession(utf8OneByte, utf8TwoBytes, utf8ThreeBytes, session2, false);

        byte[] data2 = session2.toByteArray();

        assertEquals(STRING.deser(data), STRING.deser(data2));
    }
Tests for streaming UTF-8 Encoding

@author David Yu
@created Sep 18, 2010
protostuff-api/src/test/java/io/protostuff/StreamedStringSerializerTest.java