@Test
  public void testSerializationOfQueryResults() throws IOException, ClassNotFoundException {
    Collection data = new java.util.ArrayList();
    data.add(null);
    data.add(null);
    data.add("some string");
    data.add(Long.MAX_VALUE);
    data.add(45);
    data.add(QueryService.UNDEFINED);

    ObjectType elementType = new SimpleObjectType();
    // Undefined
    checkRoundTrip(QueryService.UNDEFINED);
    // ResultsBag
    ResultsBag rbWithoutData = new ResultsBag();
    rbWithoutData.setElementType(elementType); // avoid NPE in equals
    checkRoundTrip(rbWithoutData);
    ResultsBag rbWithData = new ResultsBag(data, null);
    rbWithData.setElementType(elementType); // avoid NPE in equals
    checkRoundTrip(rbWithData);
    /*
     * Set rbWithoutDataAsSet = new ResultsBag().asSet(); ResultsCollectionWrapper rcw = new
     * ResultsCollectionWrapper(elementType, rbWithoutDataAsSet, -1); checkRoundTrip(rcw); Set
     * rbWithDataAsSet = new ResultsBag(data, (CachePerfStats)null).asSet();
     * ResultsCollectionWrapper rcwWithData = new ResultsCollectionWrapper(elementType,
     * rbWithDataAsSet, -1); checkRoundTrip(rcwWithData);
     */
    // SortedResultSet
    SortedResultSet srsWithoutData = new SortedResultSet();
    srsWithoutData.setElementType(elementType); // avoid NPE in equals
    checkRoundTrip(srsWithoutData);
    SortedResultSet srsWithData = new SortedResultSet();
    srsWithData.setElementType(elementType); // avoid NPE in equals
    checkRoundTrip(srsWithData);

    // SortedStructSet
    // SortedStructSet sssWithoutData = new SortedStructSet();
    // checkRoundTrip(sssWithoutData);
  }
Tests the serialization of many, but not all of the possible ResultSets
geode-core/src/test/java/org/apache/geode/cache/query/internal/QueryObjectSerializationJUnitTest.java