private void tryArrayList(int size) throws IOException, ClassNotFoundException {
    setUp();
    final Random random = getRandom();
    final ArrayList<Long> list = size == -1 ? null : new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
      list.add(random.nextLong());
    }

    DataOutputStream out = getDataOutput();
    DataSerializer.writeArrayList(list, out);
    out.flush();

    DataInput in = getDataInput();
    ArrayList<Long> list2 = DataSerializer.readArrayList(in);
    assertEquals(list, list2);
    tearDown();
  }
Tests data serializing an {@link ArrayList}
geode-core/src/test/java/org/apache/geode/internal/DataSerializableJUnitTest.java