[Jboss-cvs] JBossAS SVN: r56195 - branches/Branch_4_0/testsuite/src/main/org/jboss/test/testbeancluster/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 23 16:15:03 EDT 2006


Author: bstansberry at jboss.com
Date: 2006-08-23 16:15:02 -0400 (Wed, 23 Aug 2006)
New Revision: 56195

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

Added: branches/Branch_4_0/testsuite/src/main/org/jboss/test/testbeancluster/test/PackagedSessionImplUnitTestCase.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/testbeancluster/test/PackagedSessionImplUnitTestCase.java	2006-08-23 19:12:08 UTC (rev 56194)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/testbeancluster/test/PackagedSessionImplUnitTestCase.java	2006-08-23 20:15:02 UTC (rev 56195)
@@ -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