Index: build.xml =================================================================== --- build.xml (revision 408) +++ build.xml (working copy) @@ -120,6 +120,7 @@ + Index: tests/org/jboss/serial/contribtests/jbser121/MyEntity.java =================================================================== --- tests/org/jboss/serial/contribtests/jbser121/MyEntity.java (revision 0) +++ tests/org/jboss/serial/contribtests/jbser121/MyEntity.java (revision 0) @@ -0,0 +1,32 @@ +package org.jboss.serial.contribtests.jbser121; + +import java.io.File; +import java.io.IOException; + +public class MyEntity { + private File file; + + // just to prevent direct instantiation + private MyEntity() { + } + + public static MyEntity createInstance() { + MyEntity entity = new MyEntity(); + entity.init(); + return entity; + } + + // In an EJB, this would be a PostConstruct + public void init() { + try { + this.file = File.createTempFile("jbser121", "txt"); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + // In an EJB, this would be the PreDestroy + public void destroy() { + this.file.delete(); + } +} Index: tests/org/jboss/serial/contribtests/jbser121/JBSER121TestCase.java =================================================================== --- tests/org/jboss/serial/contribtests/jbser121/JBSER121TestCase.java (revision 0) +++ tests/org/jboss/serial/contribtests/jbser121/JBSER121TestCase.java (revision 0) @@ -0,0 +1,35 @@ +package org.jboss.serial.contribtests.jbser121; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import junit.framework.TestCase; + +import org.jboss.serial.io.JBossObjectInputStream; +import org.jboss.serial.io.JBossObjectOutputStream; + +public class JBSER121TestCase extends TestCase { + + /** + * This test should pass for all newer JVMs as long as the property + * org.jboss.serial.SYNC_SERIALIZATION_BINARY_FORMATS is true + * + * @throws Exception + */ + public void testSerializationForAllJVMs() throws Exception { + ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); + JBossObjectOutputStream os = new JBossObjectOutputStream(byteOut); + os.writeObject(MyEntity.createInstance()); + os.flush(); + + ByteArrayInputStream byteInpt = new ByteArrayInputStream(byteOut.toByteArray()); + JBossObjectInputStream is = null; + try { + is = new JBossObjectInputStream(byteInpt); + MyEntity ent = (MyEntity) is.readObject(); + } catch (IOException e) { + fail("Failed to revert an object with a java.io.File embedded. This happens if you are using a JVM newer than JDK 1.6.0_19 and you didn't set the property org.jboss.serial.SYNC_SERIALIZATION_BINARY_FORMATS"); + } + } +}