[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/optimistic ...

Manik Surtani msurtani at jboss.com
Sat Nov 11 13:01:03 EST 2006


  User: msurtani
  Date: 06/11/11 13:01:03

  Added:       tests/functional/org/jboss/cache/optimistic  Tag:
                        Branch_JBossCache_1_4_0 VersioningOnReadTest.java
  Log:
  JBCACHE-842
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +92 -0     JBossCache/tests/functional/org/jboss/cache/optimistic/Attic/VersioningOnReadTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: VersioningOnReadTest.java
  ===================================================================
  RCS file: VersioningOnReadTest.java
  diff -N VersioningOnReadTest.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ VersioningOnReadTest.java	11 Nov 2006 18:01:03 -0000	1.1.2.1
  @@ -0,0 +1,92 @@
  +package org.jboss.cache.optimistic;
  +
  +import org.jboss.cache.Fqn;
  +import org.jboss.cache.TreeCache;
  +
  +import javax.transaction.Transaction;
  +import javax.transaction.TransactionManager;
  +
  +/**
  + * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
  + */
  +public class VersioningOnReadTest extends AbstractOptimisticTestCase
  +{
  +   TreeCache cache;
  +   Fqn fqn = Fqn.fromString("/a");
  +   TransactionManager tm;
  +
  +   public VersioningOnReadTest(String name)
  +   {
  +      super(name);
  +   }
  +
  +   protected void setUp() throws Exception
  +   {
  +      super.setUp();
  +      cache = createCache();
  +      tm = cache.getTransactionManager();
  +   }
  +
  +   protected void tearDown() throws Exception
  +   {
  +      super.tearDown();
  +      destroyCache(cache);
  +   }
  +
  +   public void testUpdateOnWrite() throws Exception
  +   {
  +      cache.put(fqn, "k", "v");
  +
  +      assertEquals("v", cache.get(fqn, "k"));
  +
  +      // now start a tx to mod the node
  +      tm.begin();
  +      cache.put(fqn, "k", "v2");
  +
  +      // suspend the tx
  +      Transaction tx = tm.suspend();
  +
  +      // now modify the node
  +      cache.put(fqn, "k", "v3");
  +
  +      // resume the tx
  +      tm.resume(tx);
  +
  +      try
  +      {
  +         tm.commit();
  +         fail("Should have failed with a data version mismatch");
  +      }
  +      catch (Exception e)
  +      {
  +         // do nothing
  +      }
  +   }
  +
  +   public void testUpdateOnRead() throws Exception
  +   {
  +      cache.put(fqn, "k", "v");
  +
  +      assertEquals("v", cache.get(fqn, "k"));
  +
  +      // now start a tx to mod the node
  +      tm.begin();
  +      cache.get(fqn, "k");
  +
  +      // suspend the tx
  +      Transaction tx = tm.suspend();
  +
  +      // now modify the node
  +      cache.put(fqn, "k", "v3");
  +
  +      // resume the tx
  +      tm.resume(tx);
  +
  +      // now put some other stuff elsewhere
  +      cache.put(Fqn.fromString("/b"), "k", "v");
  +
  +      // this should succeed since there is no contention on writing to /a
  +      tm.commit();
  +   }
  +
  +}
  
  
  



More information about the jboss-cvs-commits mailing list