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

Manik Surtani msurtani at jboss.com
Wed Sep 6 12:42:59 EDT 2006


  User: msurtani
  Date: 06/09/06 12:42:59

  Modified:    tests/functional/org/jboss/cache/mgmt  NotificationTest.java
  Log:
  Cache mgmt interceptor now uses new CacheListener interface
  
  Revision  Changes    Path
  1.9       +67 -143   JBossCache/tests/functional/org/jboss/cache/mgmt/NotificationTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NotificationTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/mgmt/NotificationTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- NotificationTest.java	6 Sep 2006 15:30:58 -0000	1.8
  +++ NotificationTest.java	6 Sep 2006 16:42:59 -0000	1.9
  @@ -1,11 +1,6 @@
   package org.jboss.cache.mgmt;
   
  -import junit.framework.Test;
   import junit.framework.TestCase;
  -import junit.framework.TestSuite;
  -import org.jboss.cache.AbstractCacheListener;
  -import org.jboss.cache.CacheListener;
  -import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.config.Configuration;
  @@ -21,16 +16,13 @@
   import javax.management.Notification;
   import javax.management.NotificationListener;
   import javax.management.ObjectName;
  -import java.util.ArrayList;
   import java.util.HashMap;
  -import java.util.List;
  -import java.util.Map;
   
   /**
    * Functional tests for CacheMgmtInterceptor broadcast of cache event notifications
    *
    * @author Jerry Gauthier
  - * @version $Id: NotificationTest.java,v 1.8 2006/09/06 15:30:58 msurtani Exp $
  + * @version $Id: NotificationTest.java,v 1.9 2006/09/06 16:42:59 msurtani Exp $
    */
   public class NotificationTest extends TestCase
   {
  @@ -42,25 +34,25 @@
      private static final String POPULATION = "population";
      private static final String EUROPE_NODE = "Europe";
   
  -   private boolean m_cacheStarted = false;
  -   private boolean m_cacheStopped = false;
  -   private boolean m_nodeCreated = false;
  -   private boolean m_nodeEvicted = false;
  -   private boolean m_nodeLoaded = false;
  -   private boolean m_nodeModified = false;
  -   private boolean m_nodeRemoved = false;
  -   private boolean m_nodeVisited = false;
  -   private boolean m_viewChange = false;
  -   private boolean m_nodeActivatePre = false;
  -   private boolean m_nodeActivatePost = false;
  -   private boolean m_nodeEvictPre = false;
  -   private boolean m_nodeEvictPost = false;
  -   private boolean m_nodeModifyPre = false;
  -   private boolean m_nodeModifyPost = false;
  -   private boolean m_nodePassivatePre = false;
  -   private boolean m_nodePassivatePost = false;
  -   private boolean m_nodeRemovePre = false;
  -   private boolean m_nodeRemovePost = false;
  +   private boolean m_cacheStarted;
  +   private boolean m_cacheStopped;
  +   private boolean m_nodeCreatedPre;
  +   private boolean m_nodeCreatedPost;
  +   private boolean m_nodeEvictedPre;
  +   private boolean m_nodeEvictedPost;
  +   private boolean m_nodeLoadedPre;
  +   private boolean m_nodeLoadedPost;
  +   private boolean m_nodeRemovedPre;
  +   private boolean m_nodeRemovedPost;
  +   private boolean m_nodeVisitedPre;
  +   private boolean m_nodeVisitedPost;
  +   private boolean m_viewChange;
  +   private boolean m_nodeActivatedPre;
  +   private boolean m_nodeActivatedPost;
  +   private boolean m_nodeModifiedPre;
  +   private boolean m_nodeModifiedPost;
  +   private boolean m_nodePassivatedPre;
  +   private boolean m_nodePassivatedPost;
   
      private MBeanServer m_server;
   
  @@ -135,94 +127,28 @@
         // run the tests
         assertTrue("Expected CacheStarted notification", m_cacheStarted);
         assertTrue("Expected CacheStopped notification", m_cacheStopped);
  -      assertTrue("Expected NodeCreated notification", m_nodeCreated);
  -      assertTrue("Expected NodeEvicted notification", m_nodeEvicted);
  -      assertTrue("Expected NodeLoaded notification", m_nodeLoaded);
  -      assertTrue("Expected NodeModified notification", m_nodeModified);
  -      assertTrue("Expected NodeRemoved notification", m_nodeRemoved);
  -      assertTrue("Expected NodeVisited notification", m_nodeVisited);
  -      // currently only pre=false notifications are emitted by ActivationInterceptor
  -      //assertTrue("Expected NodeActivate pre=true notification", m_nodeActivatePre);
  -      assertTrue("Expected NodeActivate pre=false notification", m_nodeActivatePost);
  -      assertTrue("Expected NodeEvict pre=true notification", m_nodeEvictPre);
  -      assertTrue("Expected NodeEvict pre=false notification", m_nodeEvictPost);
  -      assertTrue("Expected NodeModify pre=true notification", m_nodeModifyPre);
  -      assertTrue("Expected NodeModify pre=false notification", m_nodeModifyPost);
  -      assertTrue("Expected NodePassivate pre=true notification", m_nodePassivatePre);
  -      // currently only pre=true notifications are emitted by PassivationInterceptor
  -      //assertTrue("Expected NodePassivate pre=false notification", m_nodePassivatePost);
  -      assertTrue("Expected NodeRemove pre=true notification", m_nodeRemovePre);
  -      assertTrue("Expected NodeRemove pre=false notification", m_nodeRemovePost);
  -      assertTrue("Expected NodeEvict pre=true notification", m_nodeEvictPre);
  +      assertTrue("Expected NodeCreated notification", m_nodeCreatedPre);
  +      assertTrue("Expected NodeCreated notification", m_nodeCreatedPost);
  +      assertTrue("Expected NodeEvicted notification", m_nodeEvictedPre);
  +      assertTrue("Expected NodeEvicted notification", m_nodeEvictedPost);
  +      assertTrue("Expected NodeLoaded notification", m_nodeLoadedPre);
  +      assertTrue("Expected NodeLoaded notification", m_nodeLoadedPost);
  +      assertTrue("Expected NodeRemoved notification", m_nodeRemovedPre);
  +      assertTrue("Expected NodeVisited notification", m_nodeVisitedPre);
  +      assertTrue("Expected NodeVisited notification", m_nodeVisitedPost);
  +      assertTrue("Expected NodeActivated notification", m_nodeActivatedPre);
  +      assertTrue("Expected NodeActivated notification", m_nodeActivatedPost);
  +      assertTrue("Expected NodeEvicted notification", m_nodeEvictedPre);
  +      assertTrue("Expected NodeEvicted notification", m_nodeEvictedPost);
  +      assertTrue("Expected NodeModified notification", m_nodeModifiedPre);
  +      assertTrue("Expected NodeModified notification", m_nodeModifiedPost);
  +      assertTrue("Expected NodePassivated notification", m_nodePassivatedPre);
  +      assertTrue("Expected NodePassivated notification", m_nodePassivatedPost);
  +      assertTrue("Expected NodeRemoved notification", m_nodeRemovedPre);
  +      assertTrue("Expected NodeRemoved notification", m_nodeRemovedPost);
         assertTrue("Expected ViewChange notification", m_viewChange);
      }
   
  -   public void testModifyNotification() throws Exception
  -   {
  -      final List<String> notifications = new ArrayList<String>();
  -      assertNotNull("MBeanServer is null.", m_server);
  -      assertNotNull("Cache is null.", cache);
  -
  -      CacheListener listener = new AbstractCacheListener()
  -      {
  -         public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
  -         {
  -            if (!pre) notifications.add("Created " + fqn);
  -         }
  -
  -         public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data)
  -         {
  -            if (!pre) notifications.add("Modified " + fqn);
  -         }
  -
  -         public void nodeRemoved(Fqn fqn, boolean pre, boolean isLocal, Map data)
  -         {
  -            if (!pre) notifications.add("Removed " + fqn);
  -         }
  -
  -         public void nodeVisited(Fqn fqn, boolean pre)
  -         {
  -            if (!pre) notifications.add("Visited " + fqn);
  -         }
  -
  -         public void cacheStarted(CacheSPI cache)
  -         {
  -            notifications.add("Started");
  -         }
  -
  -         public void cacheStopped(CacheSPI cache)
  -         {
  -            notifications.add("Stopped");
  -         }
  -
  -         public void nodeLoaded(Fqn fqn, boolean pre, Map data)
  -         {
  -            notifications.add("Loaded");
  -         }
  -
  -      };
  -
  -      cache.getNotifier().addCacheListener(listener);
  -      cache.start();
  -
  -      // check that the correct locking scheme is in use
  -      assertEquals(optimistic, cache.getConfiguration().isNodeLockingOptimistic());
  -
  -      cache.put("/hello", "k", "v");
  -      assertEquals("Started", notifications.remove(0));
  -      assertEquals("Created /hello", notifications.remove(0));
  -      assertEquals("Modified /hello", notifications.remove(0));
  -      assertEquals(0, notifications.size());
  -
  -      cache.get("/hello", "k");
  -      assertEquals("Visited /hello", notifications.remove(0));
  -      assertEquals(0, notifications.size());
  -
  -      cache.put("/hello", "k", "v2");
  -      assertEquals("Modified /hello", notifications.remove(0));
  -      assertEquals(0, notifications.size());
  -   }
  -
      private TreeCache createCache(String clusterName) throws Exception
      {
         TreeCache cache = new TreeCache();
  @@ -274,11 +200,6 @@
         return XmlHelper.stringToElement(xml);
      }
   
  -   public static Test suite()
  -   {
  -      return new TestSuite(NotificationTest.class);
  -   }
  -
      private class MyListener implements NotificationListener
      {
         public void handleNotification(Notification notification, Object handback)
  @@ -291,44 +212,47 @@
            else if (type.equals(CacheMgmtInterceptor.NOTIF_CACHE_STOPPED))
               m_cacheStopped = true;
            else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_CREATED))
  -            m_nodeCreated = true;
  +            if (getPre(userData))
  +               m_nodeCreatedPre = true;
  +            else
  +               m_nodeCreatedPost = true;
            else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_EVICTED))
  -            m_nodeEvicted = true;
  +            if (getPre(userData))
  +               m_nodeEvictedPre = true;
  +            else
  +               m_nodeEvictedPost = true;
            else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_LOADED))
  -            m_nodeLoaded = true;
  -         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_MODIFIED))
  -            m_nodeModified = true;
  +            if (getPre(userData))
  +               m_nodeLoadedPre = true;
  +            else
  +               m_nodeLoadedPost = true;
            else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_REMOVED))
  -            m_nodeRemoved = true;
  -         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_VISITED))
  -            m_nodeVisited = true;
  -         else if (type.equals(CacheMgmtInterceptor.NOTIF_VIEW_CHANGE))
  -            m_viewChange = true;
  -         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_ACTIVATE))
               if (getPre(userData))
  -               m_nodeActivatePre = true;
  +               m_nodeRemovedPre = true;
               else
  -               m_nodeActivatePost = true;
  -         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_EVICT))
  +               m_nodeRemovedPost = true;
  +         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_VISITED))
               if (getPre(userData))
  -               m_nodeEvictPre = true;
  +               m_nodeVisitedPre = true;
               else
  -               m_nodeEvictPost = true;
  -         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_MODIFY))
  +               m_nodeVisitedPost = true;
  +         else if (type.equals(CacheMgmtInterceptor.NOTIF_VIEW_CHANGED))
  +            m_viewChange = true;
  +         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_ACTIVATED))
               if (getPre(userData))
  -               m_nodeModifyPre = true;
  +               m_nodeActivatedPre = true;
               else
  -               m_nodeModifyPost = true;
  -         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_PASSIVATE))
  +               m_nodeActivatedPost = true;
  +         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_MODIFIED))
               if (getPre(userData))
  -               m_nodePassivatePre = true;
  +               m_nodeModifiedPre = true;
               else
  -               m_nodePassivatePost = true;
  -         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_REMOVE))
  +               m_nodeModifiedPost = true;
  +         else if (type.equals(CacheMgmtInterceptor.NOTIF_NODE_PASSIVATED))
               if (getPre(userData))
  -               m_nodeRemovePre = true;
  +               m_nodePassivatedPre = true;
               else
  -               m_nodeRemovePost = true;
  +               m_nodePassivatedPost = true;
         }
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list