Package org.elasticsearch.test
Class DiffableTestUtils
java.lang.Object
org.elasticsearch.test.DiffableTestUtils
Utilities that simplify testing of diffable classes
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends org.elasticsearch.cluster.Diffable<T>>
TassertDiffApplication
(T remoteChanges, T localInstance, org.elasticsearch.cluster.Diff<T> diffs) Asserts that changes are applied correctly, i.e.static <T extends org.elasticsearch.common.io.stream.Writeable>
TassertSerialization
(T testInstance, org.elasticsearch.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, org.elasticsearch.common.io.stream.Writeable.Reader<T> reader) Asserts that testInstance can be correctly.static <T extends org.elasticsearch.common.io.stream.Writeable>
TcopyInstance
(T diffs, org.elasticsearch.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, org.elasticsearch.common.io.stream.Writeable.Reader<T> reader) Simulates sending diffs over the wirestatic <T extends org.elasticsearch.cluster.Diffable<T>>
voidtestDiffableSerialization
(Supplier<T> testInstance, Function<T, T> modifier, org.elasticsearch.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, org.elasticsearch.common.io.stream.Writeable.Reader<T> reader, org.elasticsearch.common.io.stream.Writeable.Reader<org.elasticsearch.cluster.Diff<T>> diffReader) Tests making random changes to an object, calculating diffs for these changes, sending this diffs over the wire and appling these diffs on the other side.
-
Field Details
-
NUMBER_OF_DIFF_TEST_RUNS
protected static final int NUMBER_OF_DIFF_TEST_RUNS- See Also:
-
-
Method Details
-
assertDiffApplication
public static <T extends org.elasticsearch.cluster.Diffable<T>> T assertDiffApplication(T remoteChanges, T localInstance, org.elasticsearch.cluster.Diff<T> diffs) Asserts that changes are applied correctly, i.e. that applying diffs to localInstance produces that object equal but not the same as the remoteChanges instance. -
copyInstance
public static <T extends org.elasticsearch.common.io.stream.Writeable> T copyInstance(T diffs, org.elasticsearch.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, org.elasticsearch.common.io.stream.Writeable.Reader<T> reader) throws IOException Simulates sending diffs over the wire- Throws:
IOException
-
testDiffableSerialization
public static <T extends org.elasticsearch.cluster.Diffable<T>> void testDiffableSerialization(Supplier<T> testInstance, Function<T, T> modifier, org.elasticsearch.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, org.elasticsearch.common.io.stream.Writeable.Reader<T> reader, org.elasticsearch.common.io.stream.Writeable.Reader<org.elasticsearch.cluster.Diff<T>> diffReader) throws IOExceptionTests making random changes to an object, calculating diffs for these changes, sending this diffs over the wire and appling these diffs on the other side.- Throws:
IOException
-
assertSerialization
public static <T extends org.elasticsearch.common.io.stream.Writeable> T assertSerialization(T testInstance, org.elasticsearch.common.io.stream.NamedWriteableRegistry namedWriteableRegistry, org.elasticsearch.common.io.stream.Writeable.Reader<T> reader) throws IOException Asserts that testInstance can be correctly.- Throws:
IOException
-