diff options
author | Jay Modi <jaymode@users.noreply.github.com> | 2017-05-25 12:51:44 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-25 12:51:44 -0600 |
commit | f60f79f3618c616999d2390637fad0755bbe53ae (patch) | |
tree | 96b12fde05922356578ef624a1555137bd0a23be /core/src/test/java/org/elasticsearch/action/admin/indices/mapping | |
parent | fab6b00ca718c82e5fd8e044f60e8a8a2f151e32 (diff) |
Put mapping and index template requests do not need content type detection for 5.3.0+ (#24835)
This change cleans up some missed TODOs for content type detection on the source of put mapping and
put index template requests. In 5.3.0 and newer versions, the source is always JSON so the content
type detection is not needed. The TODOs were missed after the change was backported to 5.3.
Relates #24798
Diffstat (limited to 'core/src/test/java/org/elasticsearch/action/admin/indices/mapping')
-rw-r--r-- | core/src/test/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestTests.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestTests.java index 2870b04fdb..69b82e232d 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestTests.java @@ -81,14 +81,19 @@ public class PutMappingRequestTests extends ESTestCase { request.source(mapping, XContentType.YAML); assertEquals(XContentHelper.convertToJson(new BytesArray(mapping), false, XContentType.YAML), request.source()); - BytesStreamOutput bytesStreamOutput = new BytesStreamOutput(); - request.writeTo(bytesStreamOutput); - StreamInput in = StreamInput.wrap(bytesStreamOutput.bytes().toBytesRef().bytes); - PutMappingRequest serialized = new PutMappingRequest(); - serialized.readFrom(in); + final Version version = randomFrom(Version.CURRENT, Version.V_5_3_0, Version.V_5_3_1, Version.V_5_3_2, Version.V_5_4_0); + try (BytesStreamOutput bytesStreamOutput = new BytesStreamOutput()) { + bytesStreamOutput.setVersion(version); + request.writeTo(bytesStreamOutput); + try (StreamInput in = StreamInput.wrap(bytesStreamOutput.bytes().toBytesRef().bytes)) { + in.setVersion(version); + PutMappingRequest serialized = new PutMappingRequest(); + serialized.readFrom(in); - String source = serialized.source(); - assertEquals(XContentHelper.convertToJson(new BytesArray(mapping), false, XContentType.YAML), source); + String source = serialized.source(); + assertEquals(XContentHelper.convertToJson(new BytesArray(mapping), false, XContentType.YAML), source); + } + } } public void testSerializationBwc() throws IOException { |