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

Brian Stansberry brian.stansberry at jboss.com
Thu Jul 20 22:51:28 EDT 2006


  User: bstansberry
  Date: 06/07/20 22:51:28

  Modified:    tests/functional/org/jboss/cache/replicated  Tag:
                        Branch_JBossCache_1_4_0_MUX SyncReplTxTest.java
  Log:
  Sync to JBossCache_1_4_0_GA
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.9.4.1   +58 -1     JBossCache/tests/functional/org/jboss/cache/replicated/SyncReplTxTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SyncReplTxTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/replicated/SyncReplTxTest.java,v
  retrieving revision 1.9
  retrieving revision 1.9.4.1
  diff -u -b -r1.9 -r1.9.4.1
  --- SyncReplTxTest.java	5 May 2006 10:04:48 -0000	1.9
  +++ SyncReplTxTest.java	21 Jul 2006 02:51:28 -0000	1.9.4.1
  @@ -29,7 +29,7 @@
    * Note: we use DummyTransactionManager for Tx purpose instead of relying on
    * jta.
    *
  - * @version $Revision: 1.9 $
  + * @version $Revision: 1.9.4.1 $
    */
   public class SyncReplTxTest extends TestCase {
       private static Log log = LogFactory.getLog(SyncReplTxTest.class);
  @@ -517,6 +517,63 @@
       }
   
   
  +    public void testSyncReplWithRemoteRollbackWithExistingData() throws Exception {
  +             Transaction tx;
  +             final Fqn NODE1=Fqn.fromString("/one/two/three");
  +
  +           try {
  +              initCaches(TreeCache.REPL_SYNC);
  +
  +              cache1.setSyncRollbackPhase(true);
  +              cache2.setSyncRollbackPhase(true);
  +
  +              // Test with a rollback on the remote side
  +
  +              // listener aborts any active tx
  +              TransactionAborterListener tal = new TransactionAborterListener(cache2);
  +
  +              cache1.put(NODE1, "age", new Integer(20));
  +              assertEquals(new Integer(20), cache1.get(NODE1, "age"));
  +              assertEquals(new Integer(20), cache2.get(NODE1, "age"));
  +
  +              tx=beginTransaction();
  +              cache1.put(NODE1, "age", new Integer(38));
  +
  +              System.out.println("cache1 (before commit):\n" + cache1.printLockInfo());
  +              System.out.println("cache2 (before commit):\n" + cache2.printLockInfo());
  +
  +              try {
  +                 tx.commit();
  +                 fail("commit should throw a RollbackException, we should not get here");
  +              }
  +              catch(RollbackException rollback) {
  +                 System.out.println("Transaction was rolled back, this is correct");
  +              }
  +
  +              // Sleep, as the commit call to cache2 is async
  +              _pause(1000);
  +
  +              System.out.println("cache1 (after rollback):\n" + cache1.printLockInfo());
  +              System.out.println("cache2 (after rollback):\n" + cache2.printLockInfo());
  +
  +              assertNull(tal.getCallbackException());
  +
  +              assertEquals(0, cache1.getNumberOfLocksHeld());
  +              assertEquals(0, cache2.getNumberOfLocksHeld());
  +
  +              assertEquals(3, cache1.getNumberOfNodes());
  +              assertEquals(3, cache2.getNumberOfNodes());
  +              assertEquals(new Integer(20), cache1.get(NODE1, "age"));
  +              assertEquals(new Integer(20), cache2.get(NODE1, "age"));
  +
  +           }
  +           catch(Exception e) {
  +              e.printStackTrace();
  +              fail(e.toString());
  +           }
  +        }
  +    
  +
   
      public void testASyncRepl() throws Exception {
         Integer age;
  
  
  



More information about the jboss-cvs-commits mailing list