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

Manik Surtani manik at jboss.org
Tue Jul 17 10:59:10 EDT 2007


  User: msurtani
  Date: 07/07/17 10:59:10

  Modified:    tests/functional/org/jboss/cache  LifeCycleTest.java
  Log:
  JBCACHE-1100
  
  Revision  Changes    Path
  1.15      +55 -1     JBossCache/tests/functional/org/jboss/cache/LifeCycleTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: LifeCycleTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/LifeCycleTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- LifeCycleTest.java	17 Jul 2007 14:44:22 -0000	1.14
  +++ LifeCycleTest.java	17 Jul 2007 14:59:10 -0000	1.15
  @@ -13,6 +13,7 @@
   import org.jboss.cache.transaction.DummyTransactionManager;
   
   import javax.transaction.NotSupportedException;
  +import javax.transaction.RollbackException;
   import javax.transaction.SystemException;
   import javax.transaction.Transaction;
   
  @@ -20,7 +21,7 @@
    * Tests restart (stop-destroy-create-start) of CacheImpl
    *
    * @author Bela Ban
  - * @version $Id: LifeCycleTest.java,v 1.14 2007/07/17 14:44:22 msurtani Exp $
  + * @version $Id: LifeCycleTest.java,v 1.15 2007/07/17 14:59:10 msurtani Exp $
    */
   public class LifeCycleTest extends TestCase
   {
  @@ -273,6 +274,59 @@
      }
   
   
  +   public void testInvalidStateTxCommit() throws Exception
  +   {
  +      CacheImpl c = createCache(Configuration.CacheMode.LOCAL);
  +      try
  +      {
  +         c.start();
  +
  +         c.getTransactionManager().begin();
  +         c.put(Fqn.ROOT, "k1", "v1");
  +         c.put(Fqn.ROOT, "k2", "v2");
  +
  +         // now DIRECTLY change the status of c.
  +         c.cacheStatus = CacheStatus.STOPPING;
  +
  +         try
  +         {
  +            c.getTransactionManager().commit();
  +            fail("Cache isn't STARTED!");
  +         }
  +         catch (RollbackException good)
  +         {
  +         }
  +      }
  +      finally
  +      {
  +         c.stop();
  +      }
  +   }
  +
  +   public void testInvalidStateTxRollback() throws Exception
  +   {
  +      CacheImpl c = createCache(Configuration.CacheMode.LOCAL);
  +      try
  +      {
  +         c.start();
  +
  +         c.getTransactionManager().begin();
  +         c.put(Fqn.ROOT, "k1", "v1");
  +         c.put(Fqn.ROOT, "k2", "v2");
  +
  +         // now DIRECTLY change the status of c.
  +         c.cacheStatus = CacheStatus.STOPPING;
  +
  +         // rollbacks should just log a message
  +         c.getTransactionManager().rollback();
  +      }
  +      finally
  +      {
  +         c.stop();
  +      }
  +   }
  +
  +
      CacheImpl createCache(Configuration.CacheMode cache_mode) throws Exception
      {
         CacheImpl retval = (CacheImpl) DefaultCacheFactory.getInstance().createCache(false);
  
  
  



More information about the jboss-cvs-commits mailing list