@Test public void testFormatTo_InitiallyWritesNull() throws Exception { final ReusableObjectMessage msg = new ReusableObjectMessage(); final StringBuilder sb = new StringBuilder(); msg.formatTo(sb); assertEquals("null", sb.toString()); }
@Test public void testFormatTo_WritesLatestSetString() throws Exception { final ReusableObjectMessage msg = new ReusableObjectMessage(); final StringBuilder sb = new StringBuilder(); msg.formatTo(sb); assertEquals("null", sb.toString()); sb.setLength(0); msg.set("abc"); msg.formatTo(sb); assertEquals("abc", sb.toString()); sb.setLength(0); msg.set("def"); msg.formatTo(sb); assertEquals("def", sb.toString()); sb.setLength(0); msg.set("xyz"); msg.formatTo(sb); assertEquals("xyz", sb.toString()); } }