@Test
  public void testSerialize() {
    ThriftyList<Integer> list = new ThriftyList<Integer>();
    int testCount = 10;
    for (int j = 0; j < testCount; j++) {
      list.add(j);
    }
    try {
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      ObjectOutputStream os = new ObjectOutputStream(out);
      try {
        os.writeObject(list);
      } finally {
        os.close();
      }
      ObjectInputStream is = new ObjectInputStream(new ByteArrayInputStream(
          out.toByteArray()));
      try {
        list = (ThriftyList<Integer>) is.readObject();
      } finally {
        is.close();
      }
    } catch (Exception e) {
      StringWriter writer = new StringWriter();
      e.printStackTrace(new PrintWriter(writer));
      Assert.fail(writer.toString());
    }
    for (int j = 0; j < testCount; j++) {
      Assert.assertEquals(Integer.valueOf(j), list.get(j));
    }

    list = new ThriftyList<Integer>();
    try {
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      ObjectOutputStream os = new ObjectOutputStream(out);
      try {
        os.writeObject(list);
      } finally {
        os.close();
      }
      ObjectInputStream is = new ObjectInputStream(new ByteArrayInputStream(
          out.toByteArray()));
      try {
        list = (ThriftyList<Integer>) is.readObject();
      } finally {
        is.close();
      }
    } catch (Exception e) {
      StringWriter writer = new StringWriter();
      e.printStackTrace(new PrintWriter(writer));
      Assert.fail(writer.toString());
    }
    Assert.assertTrue(list.isEmpty());
  }