public class JsonVsCborTests extends ElasticsearchTestCase {
@Test
public void compareParsingTokens() throws IOException {
BytesStreamOutput xsonOs = new BytesStreamOutput();
XContentGenerator xsonGen = XContentFactory.xContent(XContentType.CBOR).createGenerator(xsonOs);
BytesStreamOutput jsonOs = new BytesStreamOutput();
XContentGenerator jsonGen = XContentFactory.xContent(XContentType.JSON).createGenerator(jsonOs);
xsonGen.writeStartObject();
jsonGen.writeStartObject();
xsonGen.writeStringField("test", "value");
jsonGen.writeStringField("test", "value");
xsonGen.writeArrayFieldStart("arr");
jsonGen.writeArrayFieldStart("arr");
xsonGen.writeNumber(1);
jsonGen.writeNumber(1);
xsonGen.writeNull();
jsonGen.writeNull();
xsonGen.writeEndArray();
jsonGen.writeEndArray();
xsonGen.writeEndObject();
jsonGen.writeEndObject();
xsonGen.close();
jsonGen.close();
verifySameTokens(XContentFactory.xContent(XContentType.JSON).createParser(jsonOs.bytes().toBytes()), XContentFactory.xContent(XContentType.CBOR).createParser(xsonOs.bytes().toBytes()));
}