Class AbstractSerializationTestCase<T extends Writeable>

java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
Direct Known Subclasses:
AbstractChunkedSerializingTestCase, AbstractXContentSerializingTestCase

public abstract class AbstractSerializationTestCase<T extends Writeable> extends AbstractWireSerializingTestCase<T>
  • Constructor Details

    • AbstractSerializationTestCase

      public AbstractSerializationTestCase()
  • Method Details

    • testFromXContent

      public final void testFromXContent() throws IOException
      Generic test that creates new instance from the test instance and checks both for equality and asserts equality on the two instances.
      Throws:
      IOException
    • testConcurrentToXContent

      public final void testConcurrentToXContent() throws IOException, InterruptedException, ExecutionException
      Calls xContent serialization on many threads and verifies that they produce the same result. Async search sometimes does this to aggregation responses and, in general, we think it's reasonable for everything that can convert itself to json to be able to do so concurrently.
      Throws:
      IOException
      InterruptedException
      ExecutionException
    • asXContent

      protected abstract org.elasticsearch.xcontent.ToXContent asXContent(T instance)
    • createXContextTestInstance

      protected abstract T createXContextTestInstance(org.elasticsearch.xcontent.XContentType xContentType)
      Creates a random instance to use in the xcontent tests. Override this method if the random instance that you build should be aware of the XContentType used in the test.
    • createXContentTester

      protected abstract AbstractXContentTestCase.XContentTester<T> createXContentTester()
    • supportsUnknownFields

      protected boolean supportsUnknownFields()
      Indicates whether the parser supports unknown fields or not. In case it does, such behaviour will be tested by inserting random fields before parsing and checking that they don't make parsing fail.
    • getRandomFieldsExcludeFilter

      protected Predicate<String> getRandomFieldsExcludeFilter()
      Returns a predicate that given the field name indicates whether the field has to be excluded from random fields insertion or not
    • getShuffleFieldsExceptions

      protected String[] getShuffleFieldsExceptions()
      Fields that have to be ignored when shuffling as part of testFromXContent
    • getToXContentParams

      protected org.elasticsearch.xcontent.ToXContent.Params getToXContentParams()
      Params that have to be provided when calling calling ToXContent.toXContent(XContentBuilder, ToXContent.Params)
    • assertToXContentEquivalence

      protected boolean assertToXContentEquivalence()
      Whether or not to assert equivalence of the XContent of the test instance and the instance parsed from the XContent of the test instance.
      Returns:
      true if equivalence should be asserted, otherwise false
    • randomDate

      protected Date randomDate()
      Returns:
      a random date between 1970 and ca 2065
    • randomInstant

      protected Instant randomInstant()
      Returns:
      a random instant between 1970 and ca 2065