Skip to content

Commit 65ce227

Browse files
javannamartijnvg
authored andcommitted
Adapt to upstream changes made to AbstractStreamableXContentTestCase (elastic#2117)
1 parent b5f2813 commit 65ce227

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

server/src/test/java/org/elasticsearch/persistent/PersistentTasksCustomMetaDataTests.java

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
import org.elasticsearch.cluster.metadata.MetaData.Custom;
2626
import org.elasticsearch.common.ParseField;
2727
import org.elasticsearch.common.UUIDs;
28+
import org.elasticsearch.common.bytes.BytesReference;
2829
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
2930
import org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry;
3031
import org.elasticsearch.common.io.stream.Writeable;
3132
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
3233
import org.elasticsearch.common.xcontent.ToXContent;
33-
import org.elasticsearch.common.xcontent.XContentBuilder;
3434
import org.elasticsearch.common.xcontent.XContentFactory;
3535
import org.elasticsearch.common.xcontent.XContentParser;
3636
import org.elasticsearch.common.xcontent.XContentType;
@@ -40,8 +40,8 @@
4040
import org.elasticsearch.persistent.PersistentTasksCustomMetaData.Builder;
4141
import org.elasticsearch.persistent.PersistentTasksCustomMetaData.PersistentTask;
4242
import org.elasticsearch.persistent.TestPersistentTasksPlugin.Status;
43-
import org.elasticsearch.persistent.TestPersistentTasksPlugin.TestPersistentTasksExecutor;
4443
import org.elasticsearch.persistent.TestPersistentTasksPlugin.TestParams;
44+
import org.elasticsearch.persistent.TestPersistentTasksPlugin.TestPersistentTasksExecutor;
4545

4646
import java.io.IOException;
4747
import java.util.ArrayList;
@@ -127,27 +127,13 @@ protected PersistentTasksCustomMetaData doParseInstance(XContentParser parser) t
127127
return PersistentTasksCustomMetaData.fromXContent(parser);
128128
}
129129

130+
/*
130131
@Override
131132
protected XContentBuilder toXContent(Custom instance, XContentType contentType) throws IOException {
132133
return toXContent(instance, contentType, new ToXContent.MapParams(
133134
Collections.singletonMap(MetaData.CONTEXT_MODE_PARAM, MetaData.XContentContext.API.toString())));
134135
}
135-
136-
protected XContentBuilder toXContent(Custom instance, XContentType contentType, ToXContent.MapParams params) throws IOException {
137-
// We need all attribute to be serialized/de-serialized for testing
138-
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
139-
if (randomBoolean()) {
140-
builder.prettyPrint();
141-
}
142-
if (instance.isFragment()) {
143-
builder.startObject();
144-
}
145-
instance.toXContent(builder, params);
146-
if (instance.isFragment()) {
147-
builder.endObject();
148-
}
149-
return builder;
150-
}
136+
*/
151137

152138
private String addRandomTask(Builder builder) {
153139
String taskId = UUIDs.base64UUID();
@@ -179,10 +165,9 @@ public void testSerializationContext() throws Exception {
179165
Collections.singletonMap(MetaData.CONTEXT_MODE_PARAM, randomFrom(CONTEXT_MODE_SNAPSHOT, CONTEXT_MODE_GATEWAY)));
180166

181167
XContentType xContentType = randomFrom(XContentType.values());
182-
XContentBuilder builder = toXContent(testInstance, xContentType, params);
183-
XContentBuilder shuffled = shuffleXContent(builder);
168+
BytesReference shuffled = toShuffledXContent(testInstance, xContentType, params, false);
184169

185-
XContentParser parser = createParser(XContentFactory.xContent(xContentType), shuffled.bytes());
170+
XContentParser parser = createParser(XContentFactory.xContent(xContentType), shuffled);
186171
PersistentTasksCustomMetaData newInstance = doParseInstance(parser);
187172
assertNotSame(newInstance, testInstance);
188173

0 commit comments

Comments
 (0)