Migrate some *ResponseTests to AbstractStreamableXContentTestCase (#28749)
This allows us to save a bit of code, but also adds more coverage as it tests serialization which was missing in some of the existing tests. Also it requires implementing equals/hashcode and we get the corresponding tests for them for free from the base test class.
This commit is contained in:
parent
45470945d2
commit
8b4a298874
|
@ -30,6 +30,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A response for a cluster update settings action.
|
||||
|
@ -103,7 +104,22 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse implemen
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static ClusterUpdateSettingsResponse fromXContent(XContentParser parser) throws IOException {
|
||||
public static ClusterUpdateSettingsResponse fromXContent(XContentParser parser) {
|
||||
return PARSER.apply(parser, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (super.equals(o)) {
|
||||
ClusterUpdateSettingsResponse that = (ClusterUpdateSettingsResponse) o;
|
||||
return Objects.equals(transientSettings, that.transientSettings) &&
|
||||
Objects.equals(persistentSettings, that.persistentSettings);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), transientSettings, persistentSettings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class IndicesAliasesResponse extends AcknowledgedResponse implements ToXC
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static IndicesAliasesResponse fromXContent(XContentParser parser) throws IOException {
|
||||
public static IndicesAliasesResponse fromXContent(XContentParser parser) {
|
||||
return PARSER.apply(parser, null);
|
||||
}
|
||||
}
|
|
@ -67,7 +67,7 @@ public class CloseIndexResponse extends AcknowledgedResponse implements ToXConte
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static CloseIndexResponse fromXContent(XContentParser parser) throws IOException {
|
||||
public static CloseIndexResponse fromXContent(XContentParser parser) {
|
||||
return PARSER.apply(parser, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
||||
|
||||
|
@ -100,4 +101,18 @@ public class CreateIndexResponse extends ShardsAcknowledgedResponse implements T
|
|||
public static CreateIndexResponse fromXContent(XContentParser parser) {
|
||||
return PARSER.apply(parser, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (super.equals(o)) {
|
||||
CreateIndexResponse that = (CreateIndexResponse) o;
|
||||
return Objects.equals(index, that.index);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), index);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class PutMappingResponse extends AcknowledgedResponse implements ToXConte
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static PutMappingResponse fromXContent(XContentParser parser) throws IOException {
|
||||
public static PutMappingResponse fromXContent(XContentParser parser) {
|
||||
return PARSER.apply(parser, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,24 +168,19 @@ public final class RolloverResponse extends ShardsAcknowledgedResponse implement
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (super.equals(o)) {
|
||||
RolloverResponse that = (RolloverResponse) o;
|
||||
return isAcknowledged() == that.isAcknowledged() &&
|
||||
isShardsAcknowledged() == that.isShardsAcknowledged() &&
|
||||
dryRun == that.dryRun &&
|
||||
return dryRun == that.dryRun &&
|
||||
rolledOver == that.rolledOver &&
|
||||
Objects.equals(oldIndex, that.oldIndex) &&
|
||||
Objects.equals(newIndex, that.newIndex) &&
|
||||
Objects.equals(conditionStatus, that.conditionStatus);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(isAcknowledged(), isShardsAcknowledged(), oldIndex, newIndex, conditionStatus, dryRun, rolledOver);
|
||||
return Objects.hash(super.hashCode(), oldIndex, newIndex, conditionStatus, dryRun, rolledOver);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
||||
|
||||
|
@ -78,4 +79,21 @@ public abstract class AcknowledgedResponse extends ActionResponse {
|
|||
protected void addAcknowledgedField(XContentBuilder builder) throws IOException {
|
||||
builder.field(ACKNOWLEDGED.getPreferredName(), isAcknowledged());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
AcknowledgedResponse that = (AcknowledgedResponse) o;
|
||||
return isAcknowledged() == that.isAcknowledged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(isAcknowledged());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
||||
|
||||
|
@ -73,4 +74,19 @@ public abstract class ShardsAcknowledgedResponse extends AcknowledgedResponse {
|
|||
protected void addShardsAcknowledgedField(XContentBuilder builder) throws IOException {
|
||||
builder.field(SHARDS_ACKNOWLEDGED.getPreferredName(), isShardsAcknowledged());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (super.equals(o)) {
|
||||
ShardsAcknowledgedResponse that = (ShardsAcknowledgedResponse) o;
|
||||
return shardsAcknowledged == that.shardsAcknowledged;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), shardsAcknowledged);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,52 +19,65 @@
|
|||
|
||||
package org.elasticsearch.action.admin.cluster.settings;
|
||||
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.Settings.Builder;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static org.elasticsearch.test.XContentTestUtils.insertRandomFields;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
public class ClusterUpdateSettingsResponseTests extends AbstractStreamableXContentTestCase<ClusterUpdateSettingsResponse> {
|
||||
|
||||
public class ClusterUpdateSettingsResponseTests extends ESTestCase {
|
||||
|
||||
public void testFromXContent() throws IOException {
|
||||
doFromXContentTestWithRandomFields(false);
|
||||
@Override
|
||||
protected ClusterUpdateSettingsResponse doParseInstance(XContentParser parser) {
|
||||
return ClusterUpdateSettingsResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
public void testFromXContentWithRandomFields() throws IOException {
|
||||
doFromXContentTestWithRandomFields(true);
|
||||
@Override
|
||||
protected EqualsHashCodeTestUtils.MutateFunction<ClusterUpdateSettingsResponse> getMutateFunction() {
|
||||
return response -> {
|
||||
int i = randomIntBetween(0, 2);
|
||||
switch(i) {
|
||||
case 0:
|
||||
return new ClusterUpdateSettingsResponse(response.isAcknowledged() == false,
|
||||
response.transientSettings, response.persistentSettings);
|
||||
case 1:
|
||||
return new ClusterUpdateSettingsResponse(response.isAcknowledged(), mutateSettings(response.transientSettings),
|
||||
response.persistentSettings);
|
||||
case 2:
|
||||
return new ClusterUpdateSettingsResponse(response.isAcknowledged(), response.transientSettings,
|
||||
mutateSettings(response.persistentSettings));
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws IOException {
|
||||
final ClusterUpdateSettingsResponse response = createTestItem();
|
||||
boolean humanReadable = randomBoolean();
|
||||
final XContentType xContentType = XContentType.JSON;
|
||||
|
||||
BytesReference originalBytes = toShuffledXContent(response, xContentType, ToXContent.EMPTY_PARAMS, humanReadable);
|
||||
BytesReference mutated;
|
||||
if (addRandomFields) {
|
||||
mutated = insertRandomFields(xContentType, originalBytes, p -> p.startsWith("transient") || p.startsWith("persistent"),
|
||||
random());
|
||||
} else {
|
||||
mutated = originalBytes;
|
||||
private static Settings mutateSettings(Settings settings) {
|
||||
if (settings.isEmpty()) {
|
||||
return randomClusterSettings(1, 3);
|
||||
}
|
||||
Set<String> allKeys = settings.keySet();
|
||||
List<String> keysToBeModified = randomSubsetOf(randomIntBetween(1, allKeys.size()), allKeys);
|
||||
Builder builder = Settings.builder();
|
||||
for (String key : allKeys) {
|
||||
String value = settings.get(key);
|
||||
if (keysToBeModified.contains(key)) {
|
||||
value += randomAlphaOfLengthBetween(2, 5);
|
||||
}
|
||||
builder.put(key, value);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
XContentParser parser = createParser(xContentType.xContent(), mutated);
|
||||
ClusterUpdateSettingsResponse parsedResponse = ClusterUpdateSettingsResponse.fromXContent(parser);
|
||||
|
||||
assertNull(parser.nextToken());
|
||||
assertThat(parsedResponse.isAcknowledged(), equalTo(response.isAcknowledged()));
|
||||
assertThat(response.transientSettings, equalTo(response.transientSettings));
|
||||
assertThat(response.persistentSettings, equalTo(response.persistentSettings));
|
||||
@Override
|
||||
protected Predicate<String> getRandomFieldsExcludeFilter() {
|
||||
return p -> p.startsWith("transient") || p.startsWith("persistent");
|
||||
}
|
||||
|
||||
public static Settings randomClusterSettings(int min, int max) {
|
||||
|
@ -77,7 +90,13 @@ public class ClusterUpdateSettingsResponseTests extends ESTestCase {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
private static ClusterUpdateSettingsResponse createTestItem() {
|
||||
@Override
|
||||
protected ClusterUpdateSettingsResponse createTestInstance() {
|
||||
return new ClusterUpdateSettingsResponse(randomBoolean(), randomClusterSettings(0, 2), randomClusterSettings(0, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClusterUpdateSettingsResponse createBlankInstance() {
|
||||
return new ClusterUpdateSettingsResponse();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.indices.alias;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
||||
|
||||
public class IndicesAliasesResponseTests extends AbstractStreamableXContentTestCase<IndicesAliasesResponse> {
|
||||
|
||||
@Override
|
||||
protected IndicesAliasesResponse doParseInstance(XContentParser parser) {
|
||||
return IndicesAliasesResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IndicesAliasesResponse createTestInstance() {
|
||||
return new IndicesAliasesResponse(randomBoolean());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IndicesAliasesResponse createBlankInstance() {
|
||||
return new IndicesAliasesResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EqualsHashCodeTestUtils.MutateFunction<IndicesAliasesResponse> getMutateFunction() {
|
||||
return response -> new IndicesAliasesResponse(response.isAcknowledged() == false);
|
||||
}
|
||||
}
|
|
@ -19,42 +19,29 @@
|
|||
|
||||
package org.elasticsearch.action.admin.indices.close;
|
||||
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
public class CloseIndexResponseTests extends AbstractStreamableXContentTestCase<CloseIndexResponse> {
|
||||
|
||||
import static org.elasticsearch.test.XContentTestUtils.insertRandomFields;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
|
||||
public class CloseIndexResponseTests extends ESTestCase {
|
||||
|
||||
public void testFromToXContent() throws IOException {
|
||||
final CloseIndexResponse closeIndexResponse = createTestItem();
|
||||
|
||||
boolean humanReadable = randomBoolean();
|
||||
final XContentType xContentType = randomFrom(XContentType.values());
|
||||
BytesReference originalBytes = toShuffledXContent(closeIndexResponse, xContentType, ToXContent.EMPTY_PARAMS, humanReadable);
|
||||
BytesReference mutated;
|
||||
if (randomBoolean()) {
|
||||
mutated = insertRandomFields(xContentType, originalBytes, null, random());
|
||||
} else {
|
||||
mutated = originalBytes;
|
||||
@Override
|
||||
protected CloseIndexResponse doParseInstance(XContentParser parser) {
|
||||
return CloseIndexResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
CloseIndexResponse parsedCloseIndexResponse;
|
||||
try (XContentParser parser = createParser(xContentType.xContent(), mutated)) {
|
||||
parsedCloseIndexResponse = CloseIndexResponse.fromXContent(parser);
|
||||
assertNull(parser.nextToken());
|
||||
}
|
||||
assertThat(parsedCloseIndexResponse.isAcknowledged(), equalTo(closeIndexResponse.isAcknowledged()));
|
||||
@Override
|
||||
protected CloseIndexResponse createTestInstance() {
|
||||
return new CloseIndexResponse(randomBoolean());
|
||||
}
|
||||
|
||||
private static CloseIndexResponse createTestItem() {
|
||||
boolean acknowledged = randomBoolean();
|
||||
return new CloseIndexResponse(acknowledged);
|
||||
@Override
|
||||
protected CloseIndexResponse createBlankInstance() {
|
||||
return new CloseIndexResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EqualsHashCodeTestUtils.MutateFunction<CloseIndexResponse> getMutateFunction() {
|
||||
return response -> new CloseIndexResponse(response.isAcknowledged() == false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,35 +21,53 @@ package org.elasticsearch.action.admin.indices.create;
|
|||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.test.XContentTestUtils.insertRandomFields;
|
||||
public class CreateIndexResponseTests extends AbstractStreamableXContentTestCase<CreateIndexResponse> {
|
||||
|
||||
public class CreateIndexResponseTests extends ESTestCase {
|
||||
|
||||
public void testSerialization() throws IOException {
|
||||
CreateIndexResponse response = new CreateIndexResponse(true, true, "foo");
|
||||
|
||||
try (BytesStreamOutput output = new BytesStreamOutput()) {
|
||||
response.writeTo(output);
|
||||
|
||||
try (StreamInput in = output.bytes().streamInput()) {
|
||||
CreateIndexResponse serialized = new CreateIndexResponse();
|
||||
serialized.readFrom(in);
|
||||
assertEquals(response.isShardsAcknowledged(), serialized.isShardsAcknowledged());
|
||||
assertEquals(response.isAcknowledged(), serialized.isAcknowledged());
|
||||
assertEquals(response.index(), serialized.index());
|
||||
@Override
|
||||
protected CreateIndexResponse createTestInstance() {
|
||||
boolean acknowledged = randomBoolean();
|
||||
boolean shardsAcknowledged = acknowledged && randomBoolean();
|
||||
String index = randomAlphaOfLength(5);
|
||||
return new CreateIndexResponse(acknowledged, shardsAcknowledged, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CreateIndexResponse createBlankInstance() {
|
||||
return new CreateIndexResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EqualsHashCodeTestUtils.MutateFunction<CreateIndexResponse> getMutateFunction() {
|
||||
return response -> {
|
||||
if (randomBoolean()) {
|
||||
if (randomBoolean()) {
|
||||
boolean acknowledged = response.isAcknowledged() == false;
|
||||
boolean shardsAcknowledged = acknowledged && response.isShardsAcknowledged();
|
||||
return new CreateIndexResponse(acknowledged, shardsAcknowledged, response.index());
|
||||
} else {
|
||||
boolean shardsAcknowledged = response.isShardsAcknowledged() == false;
|
||||
boolean acknowledged = shardsAcknowledged || response.isAcknowledged();
|
||||
return new CreateIndexResponse(acknowledged, shardsAcknowledged, response.index());
|
||||
}
|
||||
} else {
|
||||
return new CreateIndexResponse(response.isAcknowledged(), response.isShardsAcknowledged(),
|
||||
response.index() + randomAlphaOfLengthBetween(2, 5));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CreateIndexResponse doParseInstance(XContentParser parser) {
|
||||
return CreateIndexResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
public void testSerializationWithOldVersion() throws IOException {
|
||||
|
@ -88,53 +106,4 @@ public class CreateIndexResponseTests extends ESTestCase {
|
|||
assertFalse(parsedResponse.isShardsAcknowledged());
|
||||
}
|
||||
}
|
||||
|
||||
public void testToAndFromXContent() throws IOException {
|
||||
doFromXContentTestWithRandomFields(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test adds random fields and objects to the xContent rendered out to
|
||||
* ensure we can parse it back to be forward compatible with additions to
|
||||
* the xContent
|
||||
*/
|
||||
public void testFromXContentWithRandomFields() throws IOException {
|
||||
doFromXContentTestWithRandomFields(true);
|
||||
}
|
||||
|
||||
private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws IOException {
|
||||
|
||||
final CreateIndexResponse createIndexResponse = createTestItem();
|
||||
|
||||
boolean humanReadable = randomBoolean();
|
||||
final XContentType xContentType = randomFrom(XContentType.values());
|
||||
BytesReference originalBytes = toShuffledXContent(createIndexResponse, xContentType, ToXContent.EMPTY_PARAMS, humanReadable);
|
||||
|
||||
BytesReference mutated;
|
||||
if (addRandomFields) {
|
||||
mutated = insertRandomFields(xContentType, originalBytes, null, random());
|
||||
} else {
|
||||
mutated = originalBytes;
|
||||
}
|
||||
CreateIndexResponse parsedCreateIndexResponse;
|
||||
try (XContentParser parser = createParser(xContentType.xContent(), mutated)) {
|
||||
parsedCreateIndexResponse = CreateIndexResponse.fromXContent(parser);
|
||||
assertNull(parser.nextToken());
|
||||
}
|
||||
|
||||
assertEquals(createIndexResponse.index(), parsedCreateIndexResponse.index());
|
||||
assertEquals(createIndexResponse.isShardsAcknowledged(), parsedCreateIndexResponse.isShardsAcknowledged());
|
||||
assertEquals(createIndexResponse.isAcknowledged(), parsedCreateIndexResponse.isAcknowledged());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random {@link CreateIndexResponse}.
|
||||
*/
|
||||
private static CreateIndexResponse createTestItem() {
|
||||
boolean acknowledged = randomBoolean();
|
||||
boolean shardsAcknowledged = acknowledged && randomBoolean();
|
||||
String index = randomAlphaOfLength(5);
|
||||
|
||||
return new CreateIndexResponse(acknowledged, shardsAcknowledged, index);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,17 +20,11 @@
|
|||
package org.elasticsearch.action.admin.indices.delete;
|
||||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.test.XContentTestUtils.insertRandomFields;
|
||||
|
||||
public class DeleteIndexResponseTests extends ESTestCase {
|
||||
public class DeleteIndexResponseTests extends AbstractStreamableXContentTestCase<DeleteIndexResponse> {
|
||||
|
||||
public void testToXContent() {
|
||||
DeleteIndexResponse response = new DeleteIndexResponse(true);
|
||||
|
@ -38,48 +32,23 @@ public class DeleteIndexResponseTests extends ESTestCase {
|
|||
assertEquals("{\"acknowledged\":true}", output);
|
||||
}
|
||||
|
||||
public void testToAndFromXContent() throws IOException {
|
||||
doFromXContentTestWithRandomFields(false);
|
||||
@Override
|
||||
protected DeleteIndexResponse doParseInstance(XContentParser parser) {
|
||||
return DeleteIndexResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test adds random fields and objects to the xContent rendered out to
|
||||
* ensure we can parse it back to be forward compatible with additions to
|
||||
* the xContent
|
||||
*/
|
||||
public void testFromXContentWithRandomFields() throws IOException {
|
||||
doFromXContentTestWithRandomFields(true);
|
||||
@Override
|
||||
protected DeleteIndexResponse createTestInstance() {
|
||||
return new DeleteIndexResponse(randomBoolean());
|
||||
}
|
||||
|
||||
private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws IOException {
|
||||
|
||||
final DeleteIndexResponse deleteIndexResponse = createTestItem();
|
||||
|
||||
boolean humanReadable = randomBoolean();
|
||||
final XContentType xContentType = randomFrom(XContentType.values());
|
||||
BytesReference originalBytes = toShuffledXContent(deleteIndexResponse, xContentType, ToXContent.EMPTY_PARAMS, humanReadable);
|
||||
|
||||
BytesReference mutated;
|
||||
if (addRandomFields) {
|
||||
mutated = insertRandomFields(xContentType, originalBytes, null, random());
|
||||
} else {
|
||||
mutated = originalBytes;
|
||||
}
|
||||
DeleteIndexResponse parsedDeleteIndexResponse;
|
||||
try (XContentParser parser = createParser(xContentType.xContent(), mutated)) {
|
||||
parsedDeleteIndexResponse = DeleteIndexResponse.fromXContent(parser);
|
||||
assertNull(parser.nextToken());
|
||||
@Override
|
||||
protected DeleteIndexResponse createBlankInstance() {
|
||||
return new DeleteIndexResponse();
|
||||
}
|
||||
|
||||
assertEquals(deleteIndexResponse.isAcknowledged(), parsedDeleteIndexResponse.isAcknowledged());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random {@link DeleteIndexResponse}.
|
||||
*/
|
||||
private static DeleteIndexResponse createTestItem() throws IOException {
|
||||
boolean acknowledged = randomBoolean();
|
||||
|
||||
return new DeleteIndexResponse(acknowledged);
|
||||
@Override
|
||||
protected EqualsHashCodeTestUtils.MutateFunction<DeleteIndexResponse> getMutateFunction() {
|
||||
return response -> new DeleteIndexResponse(response.isAcknowledged() == false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,17 +20,11 @@
|
|||
package org.elasticsearch.action.admin.indices.mapping.put;
|
||||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.test.XContentTestUtils.insertRandomFields;
|
||||
|
||||
public class PutMappingResponseTests extends ESTestCase {
|
||||
public class PutMappingResponseTests extends AbstractStreamableXContentTestCase<PutMappingResponse> {
|
||||
|
||||
public void testToXContent() {
|
||||
PutMappingResponse response = new PutMappingResponse(true);
|
||||
|
@ -38,48 +32,23 @@ public class PutMappingResponseTests extends ESTestCase {
|
|||
assertEquals("{\"acknowledged\":true}", output);
|
||||
}
|
||||
|
||||
public void testToAndFromXContent() throws IOException {
|
||||
doFromXContentTestWithRandomFields(false);
|
||||
@Override
|
||||
protected PutMappingResponse doParseInstance(XContentParser parser) {
|
||||
return PutMappingResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test adds random fields and objects to the xContent rendered out to
|
||||
* ensure we can parse it back to be forward compatible with additions to
|
||||
* the xContent
|
||||
*/
|
||||
public void testFromXContentWithRandomFields() throws IOException {
|
||||
doFromXContentTestWithRandomFields(true);
|
||||
@Override
|
||||
protected PutMappingResponse createTestInstance() {
|
||||
return new PutMappingResponse(randomBoolean());
|
||||
}
|
||||
|
||||
private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws IOException {
|
||||
|
||||
final PutMappingResponse putMappingResponse = createTestItem();
|
||||
|
||||
boolean humanReadable = randomBoolean();
|
||||
final XContentType xContentType = randomFrom(XContentType.values());
|
||||
BytesReference originalBytes = toShuffledXContent(putMappingResponse, xContentType, ToXContent.EMPTY_PARAMS, humanReadable);
|
||||
|
||||
BytesReference mutated;
|
||||
if (addRandomFields) {
|
||||
mutated = insertRandomFields(xContentType, originalBytes, null, random());
|
||||
} else {
|
||||
mutated = originalBytes;
|
||||
}
|
||||
PutMappingResponse parsedPutMappingResponse;
|
||||
try (XContentParser parser = createParser(xContentType.xContent(), mutated)) {
|
||||
parsedPutMappingResponse = PutMappingResponse.fromXContent(parser);
|
||||
assertNull(parser.nextToken());
|
||||
@Override
|
||||
protected PutMappingResponse createBlankInstance() {
|
||||
return new PutMappingResponse();
|
||||
}
|
||||
|
||||
assertEquals(putMappingResponse.isAcknowledged(), parsedPutMappingResponse.isAcknowledged());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random {@link PutMappingResponse}.
|
||||
*/
|
||||
private static PutMappingResponse createTestItem() throws IOException {
|
||||
boolean acknowledged = randomBoolean();
|
||||
|
||||
return new PutMappingResponse(acknowledged);
|
||||
@Override
|
||||
protected EqualsHashCodeTestUtils.MutateFunction<PutMappingResponse> getMutateFunction() {
|
||||
return response -> new PutMappingResponse(response.isAcknowledged() == false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,45 +19,41 @@
|
|||
|
||||
package org.elasticsearch.action.admin.indices.open;
|
||||
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
public class OpenIndexResponseTests extends AbstractStreamableXContentTestCase<OpenIndexResponse> {
|
||||
|
||||
import static org.elasticsearch.test.XContentTestUtils.insertRandomFields;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
|
||||
public class OpenIndexResponseTests extends ESTestCase {
|
||||
|
||||
public void testFromToXContent() throws IOException {
|
||||
final OpenIndexResponse openIndexResponse = createTestItem();
|
||||
|
||||
boolean humanReadable = randomBoolean();
|
||||
final XContentType xContentType = randomFrom(XContentType.values());
|
||||
BytesReference originalBytes = toShuffledXContent(openIndexResponse, xContentType, ToXContent.EMPTY_PARAMS, humanReadable);
|
||||
BytesReference mutated;
|
||||
if (randomBoolean()) {
|
||||
mutated = insertRandomFields(xContentType, originalBytes, null, random());
|
||||
} else {
|
||||
mutated = originalBytes;
|
||||
@Override
|
||||
protected OpenIndexResponse doParseInstance(XContentParser parser){
|
||||
return OpenIndexResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
OpenIndexResponse parsedOpenIndexResponse;
|
||||
try (XContentParser parser = createParser(xContentType.xContent(), mutated)) {
|
||||
parsedOpenIndexResponse = OpenIndexResponse.fromXContent(parser);
|
||||
assertNull(parser.nextToken());
|
||||
}
|
||||
|
||||
assertThat(parsedOpenIndexResponse.isShardsAcknowledged(), equalTo(openIndexResponse.isShardsAcknowledged()));
|
||||
assertThat(parsedOpenIndexResponse.isAcknowledged(), equalTo(openIndexResponse.isAcknowledged()));
|
||||
}
|
||||
|
||||
private static OpenIndexResponse createTestItem() {
|
||||
@Override
|
||||
protected OpenIndexResponse createTestInstance() {
|
||||
boolean acknowledged = randomBoolean();
|
||||
boolean shardsAcknowledged = acknowledged && randomBoolean();
|
||||
return new OpenIndexResponse(acknowledged, shardsAcknowledged);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OpenIndexResponse createBlankInstance() {
|
||||
return new OpenIndexResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EqualsHashCodeTestUtils.MutateFunction<OpenIndexResponse> getMutateFunction() {
|
||||
return response -> {
|
||||
if (randomBoolean()) {
|
||||
boolean acknowledged = response.isAcknowledged() == false;
|
||||
boolean shardsAcknowledged = acknowledged && response.isShardsAcknowledged();
|
||||
return new OpenIndexResponse(acknowledged, shardsAcknowledged);
|
||||
} else {
|
||||
boolean shardsAcknowledged = response.isShardsAcknowledged() == false;
|
||||
boolean acknowledged = shardsAcknowledged || response.isAcknowledged();
|
||||
return new OpenIndexResponse(acknowledged, shardsAcknowledged);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,17 +20,11 @@
|
|||
package org.elasticsearch.action.admin.indices.shrink;
|
||||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.test.XContentTestUtils.insertRandomFields;
|
||||
|
||||
public class ResizeResponseTests extends ESTestCase {
|
||||
public class ResizeResponseTests extends AbstractStreamableXContentTestCase<ResizeResponse> {
|
||||
|
||||
public void testToXContent() {
|
||||
ResizeResponse response = new ResizeResponse(true, false, "index_name");
|
||||
|
@ -38,49 +32,41 @@ public class ResizeResponseTests extends ESTestCase {
|
|||
assertEquals("{\"acknowledged\":true,\"shards_acknowledged\":false,\"index\":\"index_name\"}", output);
|
||||
}
|
||||
|
||||
public void testToAndFromXContent() throws IOException {
|
||||
doFromXContentTestWithRandomFields(false);
|
||||
@Override
|
||||
protected ResizeResponse doParseInstance(XContentParser parser) {
|
||||
return ResizeResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test adds random fields and objects to the xContent rendered out to
|
||||
* ensure we can parse it back to be forward compatible with additions to
|
||||
* the xContent
|
||||
*/
|
||||
public void testFromXContentWithRandomFields() throws IOException {
|
||||
doFromXContentTestWithRandomFields(true);
|
||||
}
|
||||
|
||||
private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws IOException {
|
||||
|
||||
final ResizeResponse resizeResponse = createTestItem();
|
||||
|
||||
boolean humanReadable = randomBoolean();
|
||||
final XContentType xContentType = randomFrom(XContentType.values());
|
||||
BytesReference originalBytes = toShuffledXContent(resizeResponse, xContentType, ToXContent.EMPTY_PARAMS, humanReadable);
|
||||
|
||||
BytesReference mutated;
|
||||
if (addRandomFields) {
|
||||
mutated = insertRandomFields(xContentType, originalBytes, null, random());
|
||||
} else {
|
||||
mutated = originalBytes;
|
||||
}
|
||||
ResizeResponse parsedResizeResponse;
|
||||
try (XContentParser parser = createParser(xContentType.xContent(), mutated)) {
|
||||
parsedResizeResponse = ResizeResponse.fromXContent(parser);
|
||||
assertNull(parser.nextToken());
|
||||
}
|
||||
|
||||
assertEquals(resizeResponse.index(), parsedResizeResponse.index());
|
||||
assertEquals(resizeResponse.isShardsAcknowledged(), parsedResizeResponse.isShardsAcknowledged());
|
||||
assertEquals(resizeResponse.isAcknowledged(), parsedResizeResponse.isAcknowledged());
|
||||
}
|
||||
|
||||
private static ResizeResponse createTestItem() {
|
||||
@Override
|
||||
protected ResizeResponse createTestInstance() {
|
||||
boolean acknowledged = randomBoolean();
|
||||
boolean shardsAcknowledged = acknowledged && randomBoolean();
|
||||
String index = randomAlphaOfLength(5);
|
||||
|
||||
return new ResizeResponse(acknowledged, shardsAcknowledged, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResizeResponse createBlankInstance() {
|
||||
return new ResizeResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EqualsHashCodeTestUtils.MutateFunction<ResizeResponse> getMutateFunction() {
|
||||
return response -> {
|
||||
if (randomBoolean()) {
|
||||
if (randomBoolean()) {
|
||||
boolean acknowledged = response.isAcknowledged() == false;
|
||||
boolean shardsAcknowledged = acknowledged && response.isShardsAcknowledged();
|
||||
return new ResizeResponse(acknowledged, shardsAcknowledged, response.index());
|
||||
} else {
|
||||
boolean shardsAcknowledged = response.isShardsAcknowledged() == false;
|
||||
boolean acknowledged = shardsAcknowledged || response.isAcknowledged();
|
||||
return new ResizeResponse(acknowledged, shardsAcknowledged, response.index());
|
||||
}
|
||||
} else {
|
||||
return new ResizeResponse(response.isAcknowledged(), response.isShardsAcknowledged(),
|
||||
response.index() + randomAlphaOfLengthBetween(2, 5));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,13 +27,12 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||
import org.elasticsearch.test.EqualsHashCodeTestUtils;
|
||||
import org.elasticsearch.test.VersionUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode;
|
||||
|
||||
public class MainResponseTests extends AbstractStreamableXContentTestCase<MainResponse> {
|
||||
|
||||
@Override
|
||||
|
@ -87,18 +86,9 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
|
|||
+ "}", builder.string());
|
||||
}
|
||||
|
||||
//TODO this should be removed and the metehod from AbstractStreamableTestCase should be
|
||||
//used instead once https://github.com/elastic/elasticsearch/pull/25910 goes in
|
||||
public void testEqualsAndHashcode() {
|
||||
MainResponse original = createTestInstance();
|
||||
checkEqualsAndHashCode(original, MainResponseTests::copy, MainResponseTests::mutate);
|
||||
}
|
||||
|
||||
private static MainResponse copy(MainResponse o) {
|
||||
return new MainResponse(o.getNodeName(), o.getVersion(), o.getClusterName(), o.getClusterUuid(), o.getBuild(), o.isAvailable());
|
||||
}
|
||||
|
||||
private static MainResponse mutate(MainResponse o) {
|
||||
@Override
|
||||
protected EqualsHashCodeTestUtils.MutateFunction<MainResponse> getMutateFunction() {
|
||||
return o -> {
|
||||
String clusterUuid = o.getClusterUuid();
|
||||
boolean available = o.isAvailable();
|
||||
Build build = o.getBuild();
|
||||
|
@ -127,5 +117,6 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
|
|||
break;
|
||||
}
|
||||
return new MainResponse(nodeName, version, clusterName, clusterUuid, build, available);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,8 @@ public abstract class AbstractDiffableSerializationTestCase<T extends Diffable<T
|
|||
|
||||
protected abstract Reader<Diff<T>> diffReader();
|
||||
|
||||
public void testDiffableSerialization() throws IOException {
|
||||
public final void testDiffableSerialization() throws IOException {
|
||||
DiffableTestUtils.testDiffableSerialization(this::createTestInstance, this::makeTestChanges, getNamedWriteableRegistry(),
|
||||
instanceReader(), diffReader());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,9 +39,8 @@ public abstract class AbstractDiffableWireSerializationTestCase<T extends Diffab
|
|||
|
||||
protected abstract Reader<Diff<T>> diffReader();
|
||||
|
||||
public void testDiffableSerialization() throws IOException {
|
||||
public final void testDiffableSerialization() throws IOException {
|
||||
DiffableTestUtils.testDiffableSerialization(this::createTestInstance, this::makeTestChanges, getNamedWriteableRegistry(),
|
||||
instanceReader(), diffReader());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public abstract class AbstractSerializingTestCase<T extends ToXContent & Writeab
|
|||
* Generic test that creates new instance from the test instance and checks
|
||||
* both for equality and asserts equality on the two instances.
|
||||
*/
|
||||
public void testFromXContent() throws IOException {
|
||||
public final void testFromXContent() throws IOException {
|
||||
for (int runs = 0; runs < NUMBER_OF_TEST_RUNS; runs++) {
|
||||
T testInstance = createTestInstance();
|
||||
XContentType xContentType = randomFrom(XContentType.values());
|
||||
|
|
|
@ -71,7 +71,7 @@ public abstract class AbstractStreamableTestCase<T extends Streamable> extends E
|
|||
* Tests that the equals and hashcode methods are consistent and copied
|
||||
* versions of the instance have are equal.
|
||||
*/
|
||||
public void testEqualsAndHashcode() {
|
||||
public final void testEqualsAndHashcode() {
|
||||
for (int runs = 0; runs < NUMBER_OF_TEST_RUNS; runs++) {
|
||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createTestInstance(), getCopyFunction(), getMutateFunction());
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public abstract class AbstractStreamableTestCase<T extends Streamable> extends E
|
|||
/**
|
||||
* Test serialization and deserialization of the test instance.
|
||||
*/
|
||||
public void testSerialization() throws IOException {
|
||||
public final void testSerialization() throws IOException {
|
||||
for (int runs = 0; runs < NUMBER_OF_TEST_RUNS; runs++) {
|
||||
T testInstance = createTestInstance();
|
||||
assertSerialization(testInstance);
|
||||
|
|
|
@ -37,7 +37,7 @@ public abstract class AbstractStreamableXContentTestCase<T extends ToXContent &
|
|||
* Generic test that creates new instance from the test instance and checks
|
||||
* both for equality and asserts equality on the two queries.
|
||||
*/
|
||||
public void testFromXContent() throws IOException {
|
||||
public final void testFromXContent() throws IOException {
|
||||
for (int runs = 0; runs < NUMBER_OF_TEST_RUNS; runs++) {
|
||||
T testInstance = createTestInstance();
|
||||
XContentType xContentType = randomFrom(XContentType.values());
|
||||
|
|
|
@ -58,7 +58,7 @@ public abstract class AbstractWireSerializingTestCase<T extends Writeable> exten
|
|||
* Tests that the equals and hashcode methods are consistent and copied
|
||||
* versions of the instance have are equal.
|
||||
*/
|
||||
public void testEqualsAndHashcode() throws IOException {
|
||||
public final void testEqualsAndHashcode() {
|
||||
for (int runs = 0; runs < NUMBER_OF_TEST_RUNS; runs++) {
|
||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(createTestInstance(), this::copyInstance, this::mutateInstance);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public abstract class AbstractWireSerializingTestCase<T extends Writeable> exten
|
|||
/**
|
||||
* Test serialization and deserialization of the test instance.
|
||||
*/
|
||||
public void testSerialization() throws IOException {
|
||||
public final void testSerialization() throws IOException {
|
||||
for (int runs = 0; runs < NUMBER_OF_TEST_RUNS; runs++) {
|
||||
T testInstance = createTestInstance();
|
||||
assertSerialization(testInstance);
|
||||
|
|
Loading…
Reference in New Issue