@Test
  public void testStack() throws Exception {
    Random random = getRandom();
    Stack<Long> list = new Stack<>();
    int size = random.nextInt(50);
    for (int i = 0; i < size; i++) {
      list.add(random.nextLong());
    }

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

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