[TEST] Remove content type auto-detection while parsing request body in REST tests
This commit is contained in:
parent
b8e2d12b23
commit
04aaedc083
|
@ -24,10 +24,9 @@ import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.collect.Tuple;
|
import org.elasticsearch.common.collect.Tuple;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentLocation;
|
import org.elasticsearch.common.xcontent.XContentLocation;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestExecutionContext;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestExecutionContext;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
|
||||||
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponseException;
|
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponseException;
|
||||||
|
@ -118,9 +117,7 @@ public class DoSection implements ExecutableSection {
|
||||||
} else if (token.isValue()) {
|
} else if (token.isValue()) {
|
||||||
if ("body".equals(paramName)) {
|
if ("body".equals(paramName)) {
|
||||||
String body = parser.text();
|
String body = parser.text();
|
||||||
XContentType bodyContentType = XContentFactory.xContentType(body);
|
XContentParser bodyParser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, body);
|
||||||
XContentParser bodyParser = XContentFactory.xContent(bodyContentType).createParser(
|
|
||||||
NamedXContentRegistry.EMPTY, body);
|
|
||||||
//multiple bodies are supported e.g. in case of bulk provided as a whole string
|
//multiple bodies are supported e.g. in case of bulk provided as a whole string
|
||||||
while(bodyParser.nextToken() != null) {
|
while(bodyParser.nextToken() != null) {
|
||||||
apiCallSection.addBody(bodyParser.mapOrdered());
|
apiCallSection.addBody(bodyParser.mapOrdered());
|
||||||
|
|
Loading…
Reference in New Issue