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

Manik Surtani msurtani at jboss.com
Wed Oct 11 09:49:25 EDT 2006


  User: msurtani
  Date: 06/10/11 09:49:25

  Modified:    tests/functional/org/jboss/cache/transaction  Tag:
                        Branch_JBossCache_1_4_0 SuspendTxTest.java
  Log:
  JBCACHE-785
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +34 -7     JBossCache/tests/functional/org/jboss/cache/transaction/Attic/SuspendTxTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SuspendTxTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/Attic/SuspendTxTest.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -b -r1.1.2.1 -r1.1.2.2
  --- SuspendTxTest.java	11 Oct 2006 13:30:40 -0000	1.1.2.1
  +++ SuspendTxTest.java	11 Oct 2006 13:49:25 -0000	1.1.2.2
  @@ -4,12 +4,21 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   import org.jboss.cache.TreeCache;
  +import org.jboss.cache.Fqn;
  +import org.jboss.cache.config.Option;
   import org.jboss.cache.transaction.DummyTransactionManager;
   
   import javax.transaction.Transaction;
  +import javax.transaction.TransactionManager;
   
  +/**
  + * Based on a contribution by Owen Taylor
  + * @author otaylor at redhat.com
  + * @author Manik Surtani (manik at jboss.org)
  + */
   public class SuspendTxTest extends TestCase {
      TreeCache cache;
  +   TransactionManager mgr;
   
      protected void setUp() throws Exception {
         super.setUp();
  @@ -18,12 +27,18 @@
         cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
         cache.createService();
         cache.startService();
  +      mgr = cache.getTransactionManager();
      }
   
      protected void tearDown() throws Exception {
         super.tearDown();
         cache.stopService();
         cache.destroyService();
  +      if (mgr.getTransaction() != null)
  +      {
  +            mgr.rollback();
  +      }
  +      mgr = null;
      }
   
      /**
  @@ -31,7 +46,6 @@
       * from the transaction.
       */
      public void testSuspendedLocks() throws Exception {
  -      DummyTransactionManager mgr=DummyTransactionManager.getInstance();
         mgr.begin();
   	   
         cache.put("/one/two", "key1", "val1");
  @@ -39,18 +53,31 @@
         
         Transaction tx = mgr.suspend();
   
  -      // The currently is that the transaction is cached in the
  -      // thread-local invocation context, if you uncomment the
  -      // next two lines, the test will succeed. 
  -      // cache.getInvocationContext().setTransaction(null);
  -      // cache.getInvocationContext().setGlobalTransaction(null);
  -
         cache.put("/a/b", "key1", "val1");
         mgr.resume(tx);
         
         assertEquals(numLocksBefore, cache.getNumberOfLocksHeld());
      }
   
  +   /**
  +    * Tests that locks created when a transaction is suspended are independent
  +    * from the transaction.
  +    */
  +   public void testSuspendedUsingOptionsLocks() throws Exception {
  +      mgr.begin();
  +
  +      cache.put("/one/two", "key1", "val1");
  +      int numLocksBefore = cache.getNumberOfLocksHeld();
  +
  +      Option o = new Option();
  +      o.setFailSilently(true); // will cause any current txs to be suspended for the duration of this call.
  +
  +      cache.put(Fqn.fromString("/a/b"), "key1", "val1", o);
  +
  +      assertEquals(numLocksBefore, cache.getNumberOfLocksHeld());
  +   }
  +
  +
   
      public static Test suite() {
         return new TestSuite(SuspendTxTest.class);
  
  
  



More information about the jboss-cvs-commits mailing list