add a test for overloaded method of builder and List

This commit is contained in:
kimchy 2010-11-18 02:25:22 +02:00
parent 282a7a5162
commit cf4f6decc4
1 changed files with 7 additions and 0 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.common.xcontent.builder; package org.elasticsearch.common.xcontent.builder;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.io.FastByteArrayOutputStream; import org.elasticsearch.common.io.FastByteArrayOutputStream;
import org.elasticsearch.common.io.FastCharArrayWriter; import org.elasticsearch.common.io.FastCharArrayWriter;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
@ -67,6 +68,12 @@ public class XContentBuilderTests {
assertThat(builder.string(), equalTo("{\"test\":\"value\"}")); assertThat(builder.string(), equalTo("{\"test\":\"value\"}"));
} }
@Test public void testOverloadedList() throws Exception {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.startObject().field("test", Lists.newArrayList("1", "2")).endObject();
assertThat(builder.string(), equalTo("{\"test\":[\"1\",\"2\"]}"));
}
@Test public void testWritingBinaryToStream() throws Exception { @Test public void testWritingBinaryToStream() throws Exception {
FastByteArrayOutputStream bos = new FastByteArrayOutputStream(); FastByteArrayOutputStream bos = new FastByteArrayOutputStream();