diff --git a/core/src/test/java/org/elasticsearch/action/fieldstats/FieldStatsRequestTests.java b/core/src/test/java/org/elasticsearch/action/fieldstats/FieldStatsRequestTests.java index 72a3759cf7b..2592423e5a8 100644 --- a/core/src/test/java/org/elasticsearch/action/fieldstats/FieldStatsRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/fieldstats/FieldStatsRequestTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.action.fieldstats; import org.elasticsearch.common.bytes.BytesArray; -import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.StreamsUtils; @@ -39,7 +39,7 @@ public class FieldStatsRequestTests extends ESTestCase { StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/fieldstats/" + "fieldstats-index-constraints-request.json")); FieldStatsRequest request = new FieldStatsRequest(); - request.source(XContentFactory.xContent(data).createParser(data)); + request.source(createParser(JsonXContent.jsonXContent, data)); assertThat(request.getFields().length, equalTo(5)); assertThat(request.getFields()[0], equalTo("field1")); diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/BaseXContentTestCase.java b/core/src/test/java/org/elasticsearch/common/xcontent/BaseXContentTestCase.java index e1311483777..57e9e0d5216 100644 --- a/core/src/test/java/org/elasticsearch/common/xcontent/BaseXContentTestCase.java +++ b/core/src/test/java/org/elasticsearch/common/xcontent/BaseXContentTestCase.java @@ -21,6 +21,7 @@ package org.elasticsearch.common.xcontent; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; + import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.Constants; import org.elasticsearch.cluster.metadata.IndexMetaData; @@ -268,7 +269,7 @@ public abstract class BaseXContentTestCase extends ESTestCase { final byte[] randomBytes = randomBytes(); BytesReference bytes = builder().startObject().field("binary", randomBytes).endObject().bytes(); - XContentParser parser = xcontentType().xContent().createParser(bytes); + XContentParser parser = createParser(xcontentType().xContent(), bytes); assertSame(parser.nextToken(), Token.START_OBJECT); assertSame(parser.nextToken(), Token.FIELD_NAME); assertEquals(parser.currentName(), "binary"); @@ -284,7 +285,7 @@ public abstract class BaseXContentTestCase extends ESTestCase { final byte[] randomBytes = randomBytes(); BytesReference bytes = builder().startObject().field("binary").value(randomBytes).endObject().bytes(); - XContentParser parser = xcontentType().xContent().createParser(bytes); + XContentParser parser = createParser(xcontentType().xContent(), bytes); assertSame(parser.nextToken(), Token.START_OBJECT); assertSame(parser.nextToken(), Token.FIELD_NAME); assertEquals(parser.currentName(), "binary"); @@ -309,7 +310,7 @@ public abstract class BaseXContentTestCase extends ESTestCase { } builder.endObject(); - XContentParser parser = xcontentType().xContent().createParser(builder.bytes()); + XContentParser parser = createParser(xcontentType().xContent(), builder.bytes()); assertSame(parser.nextToken(), Token.START_OBJECT); assertSame(parser.nextToken(), Token.FIELD_NAME); assertEquals(parser.currentName(), "bin"); @@ -331,7 +332,7 @@ public abstract class BaseXContentTestCase extends ESTestCase { } builder.endObject(); - XContentParser parser = xcontentType().xContent().createParser(builder.bytes()); + XContentParser parser = createParser(xcontentType().xContent(), builder.bytes()); assertSame(parser.nextToken(), Token.START_OBJECT); assertSame(parser.nextToken(), Token.FIELD_NAME); assertEquals(parser.currentName(), "utf8"); @@ -349,7 +350,7 @@ public abstract class BaseXContentTestCase extends ESTestCase { final BytesReference random = new BytesArray(randomBytes()); XContentBuilder builder = builder().startObject().field("text", new Text(random)).endObject(); - XContentParser parser = xcontentType().xContent().createParser(builder.bytes()); + XContentParser parser = createParser(xcontentType().xContent(), builder.bytes()); assertSame(parser.nextToken(), Token.START_OBJECT); assertSame(parser.nextToken(), Token.FIELD_NAME); assertEquals(parser.currentName(), "text"); diff --git a/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java b/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java index b47dd42c3b6..01fc15e6f75 100644 --- a/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.threadpool; import org.elasticsearch.Version; -import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; @@ -27,9 +26,7 @@ import org.elasticsearch.common.unit.SizeValue; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; -import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -81,11 +78,7 @@ public class ThreadPoolSerializationTests extends ESTestCase { info.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); - BytesReference bytesReference = builder.bytes(); - Map map; - try (XContentParser parser = XContentFactory.xContent(bytesReference).createParser(bytesReference)) { - map = parser.map(); - } + Map map = XContentHelper.convertToMap(builder.bytes(), false).v2(); assertThat(map, hasKey("foo")); map = (Map) map.get("foo"); assertThat(map, hasKey("queue_size"));