UnsyncStringWriter extends Writer { @Override public UnsyncStringWriter append(char c) { write(c); return this; } UnsyncStringWriter();  UnsyncStringWriter(boolean useStringBundler);  UnsyncStringWriter(boolean useStringBundler, int initialCapacity);  UnsyncStringWriter(int initialCapacity); @Override UnsyncStringWriter append(char c); @Override UnsyncStringWriter append(CharSequence charSequence); @Override UnsyncStringWriter append(
		CharSequence charSequence, int start, int end); @Override void close(); @Override void flush(); StringBuilder getStringBuilder(); StringBundler getStringBundler(); void reset(); @Override String toString(); @Override void write(char[] chars); @Override void write(char[] chars, int offset, int length); @Override void write(int c); @Override void write(String string); @Override void write(String string, int offset, int length);  }
@Test public void testAppendChar() throws Exception { UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(false); StringBuilder stringBuilder = (StringBuilder)_stringBuilderField.get( unsyncStringWriter); Assert.assertNotNull(stringBuilder); Assert.assertNull(_stringBundlerField.get(unsyncStringWriter)); unsyncStringWriter.append('a'); Assert.assertEquals(1, stringBuilder.length()); Assert.assertEquals('a', stringBuilder.charAt(0)); unsyncStringWriter.append('b'); Assert.assertEquals(2, stringBuilder.length()); Assert.assertEquals('a', stringBuilder.charAt(0)); Assert.assertEquals('b', stringBuilder.charAt(1)); unsyncStringWriter = new UnsyncStringWriter(); StringBundler stringBundler = (StringBundler)_stringBundlerField.get( unsyncStringWriter); Assert.assertNull(_stringBuilderField.get(unsyncStringWriter)); Assert.assertNotNull(stringBundler); unsyncStringWriter.append('a'); Assert.assertEquals(1, stringBundler.index()); Assert.assertEquals("a", stringBundler.stringAt(0)); unsyncStringWriter.append('b'); Assert.assertEquals(2, stringBundler.index()); Assert.assertEquals("a", stringBundler.stringAt(0)); Assert.assertEquals("b", stringBundler.stringAt(1)); }
@Test public void testAppendCharSequence() throws Exception { UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(false); StringBuilder stringBuilder = (StringBuilder)_stringBuilderField.get( unsyncStringWriter); Assert.assertNotNull(stringBuilder); Assert.assertNull(_stringBundlerField.get(unsyncStringWriter)); unsyncStringWriter.append(new StringBuilder("ab"), 0, 2); Assert.assertEquals(2, stringBuilder.length()); Assert.assertEquals('a', stringBuilder.charAt(0)); Assert.assertEquals('b', stringBuilder.charAt(1)); unsyncStringWriter.append(new StringBuilder("cd")); Assert.assertEquals(4, stringBuilder.length()); Assert.assertEquals('a', stringBuilder.charAt(0)); Assert.assertEquals('b', stringBuilder.charAt(1)); Assert.assertEquals('c', stringBuilder.charAt(2)); Assert.assertEquals('d', stringBuilder.charAt(3)); unsyncStringWriter = new UnsyncStringWriter(); StringBundler stringBundler = (StringBundler)_stringBundlerField.get( unsyncStringWriter); Assert.assertNull(_stringBuilderField.get(unsyncStringWriter)); Assert.assertNotNull(stringBundler); unsyncStringWriter.append(new StringBuilder("ab")); Assert.assertEquals(1, stringBundler.index()); Assert.assertEquals("ab", stringBundler.stringAt(0)); unsyncStringWriter.append(new StringBuilder("cd")); Assert.assertEquals(2, stringBundler.index()); Assert.assertEquals("ab", stringBundler.stringAt(0)); Assert.assertEquals("cd", stringBundler.stringAt(1)); }