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

Manik Surtani manik at jboss.org
Thu Jun 28 12:53:39 EDT 2007


  User: msurtani
  Date: 07/06/28 12:53:39

  Modified:    tests/functional/org/jboss/cache  CallbackTest.java
  Log:
  Notification changes
  
  Revision  Changes    Path
  1.18      +23 -23    JBossCache/tests/functional/org/jboss/cache/CallbackTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CallbackTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/CallbackTest.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- CallbackTest.java	15 Jun 2007 12:02:58 -0000	1.17
  +++ CallbackTest.java	28 Jun 2007 16:53:39 -0000	1.18
  @@ -5,7 +5,9 @@
   import junit.framework.TestSuite;
   import org.jboss.cache.config.Configuration;
   import org.jboss.cache.lock.IsolationLevel;
  -import org.jboss.cache.misc.TestingUtil;
  +import org.jboss.cache.notifications.annotation.CacheListener;
  +import org.jboss.cache.notifications.annotation.NodeCreated;
  +import org.jboss.cache.notifications.event.Event;
   import org.jboss.cache.transaction.DummyTransactionManager;
   
   import javax.transaction.NotSupportedException;
  @@ -15,7 +17,7 @@
    * Tests whether modifications within callbacks (TreeCacheListener) are handled correctly
    *
    * @author Bela Ban
  - * @version $Id: CallbackTest.java,v 1.17 2007/06/15 12:02:58 msurtani Exp $
  + * @version $Id: CallbackTest.java,v 1.18 2007/06/28 16:53:39 msurtani Exp $
    */
   public class CallbackTest extends TestCase
   {
  @@ -25,8 +27,6 @@
      final Fqn FQN_B = Fqn.fromString("/b");
      final String KEY = "key";
      final String VALUE = "value";
  -   private final static long CALLBACK_WAIT_TIME = 200; // ms to wait for notifications to be delivered (as they are async)
  -
   
      protected void setUp() throws Exception
      {
  @@ -57,7 +57,6 @@
   
         cache.put(FQN_A, null);
         assertTrue(cache.exists(FQN_A));
  -      TestingUtil.sleepThread(CALLBACK_WAIT_TIME); // sleep a bit so the callback is processed
         assertTrue(cache.exists(FQN_B));//created by callback
         assertEquals(cache.getLockTable().size(), 0);
         System.out.println("cache locks:\n" + cache.printLockInfo());
  @@ -71,7 +70,6 @@
   
         cache.put(FQN_A, null);
         assertTrue(cache.exists(FQN_A));
  -      TestingUtil.sleepThread(CALLBACK_WAIT_TIME); // sleep a bit so the callback is processed
         assertEquals(cache.getLockTable().size(), 0);
         System.out.println("cache locks:\n" + cache.printLockInfo());
         assertEquals(0, cache.getNumberOfLocksHeld());
  @@ -86,7 +84,6 @@
         cache.put("/a", null);
         assertTrue(cache.exists(FQN_A));
         assertTrue(cache.exists(FQN_B));
  -      TestingUtil.sleepThread(CALLBACK_WAIT_TIME); // sleep a bit so the callback is processed
         assertEquals(cache.getLockTable().size(), 0);
         System.out.println("cache locks:\n" + cache.printLockInfo());
         assertEquals(0, cache.getNumberOfLocksHeld());
  @@ -101,7 +98,6 @@
         cache.put(FQN_A, null);
         tx.commit();
         assertTrue(cache.exists(FQN_A));
  -      TestingUtil.sleepThread(CALLBACK_WAIT_TIME); // sleep a bit so the callback is processed
         assertEquals(0, cache.getNumberOfLocksHeld());
      }
   
  @@ -121,7 +117,6 @@
            tx.rollback();
         }
         assertFalse(cache.exists(FQN_A));
  -      TestingUtil.sleepThread(CALLBACK_WAIT_TIME); // sleep a bit so the callback is processed
         assertEquals(0, cache.getNumberOfLocksHeld());
      }
   
  @@ -148,17 +143,19 @@
         }
      }
   
  -
  -   class ExceptionListener extends AbstractCacheListener
  +   @CacheListener
  +   class ExceptionListener
      {
  -      public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
  +      @NodeCreated
  +      public void nodeCreated(Event e)
         {
  -         if (pre) throw new RuntimeException("this will cause the TX to rollback");
  +         if (e.isPre()) throw new RuntimeException("this will cause the TX to rollback");
         }
      }
   
   
  -   class GetListener extends AbstractCacheListener
  +   @CacheListener
  +   class GetListener
      {
         CacheImpl c;
         Fqn my_fqn;
  @@ -169,25 +166,27 @@
            this.my_fqn = my_fqn;
         }
   
  -      public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
  +      @NodeCreated
  +      public void nodeCreated(Event e)
         {
  -         if (!pre)
  +         if (!e.isPre())
            {
               try
               {
                  Node n = c.get(this.my_fqn);
                  assertNotNull(n);
               }
  -            catch (CacheException e)
  +            catch (CacheException ex)
               {
  -               fail("listener was unable to do a get(" + my_fqn + ") during callback: " + e);
  +               fail("listener was unable to do a get(" + my_fqn + ") during callback: " + ex);
               }
            }
         }
   
      }
   
  -   class PutListener extends AbstractCacheListener
  +   @CacheListener
  +   class PutListener
      {
         CacheImpl c;
   
  @@ -196,9 +195,10 @@
            this.c = c;
         }
   
  -      public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
  +      @NodeCreated
  +      public void nodeCreated(Event e)
         {
  -         if (!pre)
  +         if (!e.isPre())
            {
               try
               {
  @@ -209,9 +209,9 @@
                     System.out.println("PutListener: created node " + FQN_B);
                  }
               }
  -            catch (CacheException e)
  +            catch (CacheException ex)
               {
  -               fail("listener was unable to update cache during callback: " + e);
  +               fail("listener was unable to update cache during callback: " + ex);
               }
            }
         }
  
  
  



More information about the jboss-cvs-commits mailing list