Class AbstractSerializingTestCase<T extends org.elasticsearch.xcontent.ToXContent & Writeable>

Direct Known Subclasses:
AbstractDiffableSerializationTestCase

public abstract class AbstractSerializingTestCase<T extends org.elasticsearch.xcontent.ToXContent & Writeable> extends AbstractWireSerializingTestCase<T>
  • Constructor Details

    • AbstractSerializingTestCase

      public AbstractSerializingTestCase()
  • 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 ToXContent.toXContent(org.elasticsearch.xcontent.XContentBuilder, org.elasticsearch.xcontent.ToXContent.Params) 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
    • doParseInstance

      protected abstract T doParseInstance(org.elasticsearch.xcontent.XContentParser parser) throws IOException
      Parses to a new instance using the provided XContentParser
      Throws:
      IOException
    • createXContextTestInstance

      protected 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.
    • 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