0 Replies Latest reply on Jul 8, 2010 11:35 AM by Andrew Rubinger

    Testing Serialization Protocols

    Andrew Rubinger Master
      Hey guys:

      Had a good talk w/ Dan and Lincoln at the conclusion of JBossWorld regarding wire compatibility and was asked to pass references along to this list.

      The key is that marking a class as "implements Serializable" isn't sufficient to:

      1) Make it really Serializable
      2) Ensure that the wire protocol maintains compatibility across releases

      I've been using a technique documented by Bob Lee awhile back:

      http://crazybob.org/2006/01/unit-testing-serialization-evolution_13.html

      The idea is that after you've formalized your protocol (ie. Externalizable or readObject/writeObject explicitly), you make a copy of this original class.  Then, using a special ObjectOutputStream, you can redefine this class as a new name, hence converting from old to new or new to old.

      For instance, I implement this here in ShrinkWrap to make Archives Serializable:

      http://anonsvn.jboss.org/repos/common/shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/serialization/SerializationTestCase.java

      Recommend this approach, or one similar.  Some folks like to serialize the original version into a .ser file which stays in SCM, and ends up being the basis for the test point.  But that can only test compat in one direction.

      S,
      ALR