public void testReallyLongString() throws Exception
    {
        LinkedBuffer lb = new LinkedBuffer(256);
        WriteSession session = new WriteSession(lb);

        // The motivation of this test is to make sure
        // that the serializer/deserializer can handle very large Strings.
        // DataInputStream only supports Strings up to Short.MAX_VALUE,
        // so we should make sure our implementation can support more than that.
        //
        // Ideally, we'd like to test all the way up to Integer.MAX_VALUE, but that
        // may be unfeasable in many test environments, so we will just do 3 * Short.MAX_VALUE,
        // which would overflow an unsigned short.

        StringBuilder sb = new StringBuilder(3 * Short.MAX_VALUE);
        for (int i = 0; i < 3 * Short.MAX_VALUE; i++)
        {
            sb.append(i % 10);
        }
        String bigString = sb.toString();

        StringSerializer.writeUTF8(bigString, session, lb);

        byte[] buffered = session.toByteArray();

        // We want to make sure it's our implementation
        // that can handle the large string
        assertEquals(bigString, STRING.deserCustomOnly(buffered));
    }
Tests for UTF-8 Encoding

@author David Yu
@created Jul 6, 2010
protostuff-api/src/test/java/io/protostuff/StringSerializerTest.java