[Jboss-cvs] JBossAS SVN: r56229 - trunk/testsuite/src/main/org/jboss/test/testbeancluster/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 24 16:59:35 EDT 2006


Author: bstansberry at jboss.com
Date: 2006-08-24 16:59:35 -0400 (Thu, 24 Aug 2006)
New Revision: 56229

Added:
   trunk/testsuite/src/main/org/jboss/test/testbeancluster/test/PackagedSessionImplUnitTestCase.java
Log:
[JBAS-3545] Ensure modification timestamp is correct for replicated sessions

Added: trunk/testsuite/src/main/org/jboss/test/testbeancluster/test/PackagedSessionImplUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/testbeancluster/test/PackagedSessionImplUnitTestCase.java	2006-08-24 20:49:10 UTC (rev 56228)
+++ trunk/testsuite/src/main/org/jboss/test/testbeancluster/test/PackagedSessionImplUnitTestCase.java	2006-08-24 20:59:35 UTC (rev 56229)
@@ -0,0 +1,71 @@
+package org.jboss.test.testbeancluster.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.jboss.ha.hasessionstate.server.PackagedSessionImpl;
+import org.jboss.test.JBossTestCase;
+
+public class PackagedSessionImplUnitTestCase extends JBossTestCase
+{
+
+   public PackagedSessionImplUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testUnmodifiedExistenceInVM() throws Exception
+   {
+      long oldTimestamp = System.currentTimeMillis();
+      
+      sleep(15); // make sure the system clock changes
+      
+      byte[] state = new byte[1];
+      PackagedSessionImpl psi = new PackagedSessionImpl("Test", state, "Test");
+      
+      long newTimestamp = psi.unmodifiedExistenceInVM();
+      
+      assertTrue("Valid initial timestamp", newTimestamp > oldTimestamp);
+      
+      
+      sleep(15); // make sure the system clock changes
+      
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      ObjectOutputStream oos = new ObjectOutputStream(baos);
+      oos.writeObject(psi);
+      oos.close();
+      
+      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+      ObjectInputStream ois = new ObjectInputStream(bais);
+      psi = (PackagedSessionImpl) ois.readObject();
+      ois.close();
+      
+      oldTimestamp = newTimestamp;
+      newTimestamp = psi.unmodifiedExistenceInVM();
+      
+      assertTrue("Valid timestamp after deserialization", newTimestamp > oldTimestamp);
+      
+      sleep(15); // make sure the system clock changes
+      
+      psi.setState(state);  // use the same state to confirm that the timestamp updates anyway
+      
+      oldTimestamp = newTimestamp;
+      newTimestamp = psi.unmodifiedExistenceInVM();
+      
+      assertTrue("Valid timestamp after setState()", newTimestamp > oldTimestamp);
+      
+      sleep(15); // make sure the system clock changes
+      
+      PackagedSessionImpl psi2 = new PackagedSessionImpl("Test", state, "Test");
+      
+      psi.update(psi2);
+      
+      oldTimestamp = newTimestamp;
+      newTimestamp = psi.unmodifiedExistenceInVM();
+      
+      assertTrue("Valid timestamp after update()", newTimestamp > oldTimestamp);
+   }
+
+}




More information about the jboss-cvs-commits mailing list