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

Manik Surtani msurtani at jboss.com
Wed Sep 6 11:30:58 EDT 2006


  User: msurtani
  Date: 06/09/06 11:30:58

  Modified:    tests/functional/org/jboss/cache/mgmt      
                        CacheLoaderTest.java InvalidationTest.java
                        MgmtCoreTest.java NotificationTest.java
                        PassivationTest.java TxTest.java
  Log:
  Removed TreeCache dependency on ServiceMBeanSupport
  
  Revision  Changes    Path
  1.6       +71 -70    JBossCache/tests/functional/org/jboss/cache/mgmt/CacheLoaderTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLoaderTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/mgmt/CacheLoaderTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- CacheLoaderTest.java	20 Jul 2006 10:31:40 -0000	1.5
  +++ CacheLoaderTest.java	6 Sep 2006 15:30:58 -0000	1.6
  @@ -17,8 +17,9 @@
   
   /**
    * Simple functional tests for CacheLoaderInterceptor and CacheStoreInterceptor statistics
  + *
    * @author Jerry Gauthier
  - * @version $Id: CacheLoaderTest.java,v 1.5 2006/07/20 10:31:40 msurtani Exp $
  + * @version $Id: CacheLoaderTest.java,v 1.6 2006/09/06 15:30:58 msurtani Exp $
    */
   public class CacheLoaderTest extends TestCase
   {
  @@ -39,12 +40,12 @@
      protected void tearDown() throws Exception
      {
         super.tearDown();
  -      if(cache != null)
  +      if (cache != null)
         {
            CacheLoader cl = cache.getCacheLoader();
            cl.remove(Fqn.fromString(EUROPE_NODE));
  -         cache.stopService();
  -         cache.destroyService();
  +         cache.stop();
  +         cache.destroy();
            cache = null;
         }
      }
  @@ -142,7 +143,7 @@
         assertEquals("CacheLoaderStores count error: ", new Long(stores), new Long(store.getCacheLoaderStores()));
         
         // add two attributes - this should cause two stores
  -      stores+=2;
  +      stores += 2;
         cache.put("Europe/Poland", CAPITAL, "Warsaw");
         cache.put("Europe/Poland", CURRENCY, "Zloty");
         assertEquals("CacheLoaderLoads count error: ", new Long(load), new Long(loader.getCacheLoaderLoads()));
  @@ -201,10 +202,10 @@
      {
         TreeCache cache = new TreeCache();
         cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
  -      cache.getConfiguration().setCacheLoaderConfiguration(getCacheLoaderConfig("location="+getTempDir()));
  +      cache.getConfiguration().setCacheLoaderConfiguration(getCacheLoaderConfig("location=" + getTempDir()));
         cache.getConfiguration().setUseInterceptorMbeans(true);
  -      cache.createService();
  -      cache.startService();
  +      cache.create();
  +      cache.start();
         return cache;
      }
      
  @@ -218,7 +219,7 @@
        {
           Object o = interceptors.get(i);
           if (o instanceof CacheLoaderInterceptor)
  -           return (CacheLoaderInterceptor)o;
  +            return (CacheLoaderInterceptor) o;
        }
        return null;
      }
  @@ -233,7 +234,7 @@
        {
           Object o = interceptors.get(i);
           if (o instanceof CacheStoreInterceptor)
  -           return (CacheStoreInterceptor)o;
  +            return (CacheStoreInterceptor) o;
        }
        return null;
      }
  
  
  
  1.6       +51 -44    JBossCache/tests/functional/org/jboss/cache/mgmt/InvalidationTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: InvalidationTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/mgmt/InvalidationTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- InvalidationTest.java	20 Jul 2006 09:03:54 -0000	1.5
  +++ InvalidationTest.java	6 Sep 2006 15:30:58 -0000	1.6
  @@ -14,8 +14,9 @@
   
   /**
    * Simple functional tests for InvalidationInterceptor statistics
  + *
    * @author Jerry Gauthier
  - * @version $Id: InvalidationTest.java,v 1.5 2006/07/20 09:03:54 msurtani Exp $
  + * @version $Id: InvalidationTest.java,v 1.6 2006/09/06 15:30:58 msurtani Exp $
    */
   public class InvalidationTest extends TestCase
   {
  @@ -38,16 +39,16 @@
      protected void tearDown() throws Exception
      {
         super.tearDown();
  -      if(cache1 != null)
  +      if (cache1 != null)
         {
  -         cache1.stopService();
  -         cache1.destroyService();
  +         cache1.stop();
  +         cache1.destroy();
            cache1 = null;
         }
  -      if(cache2 != null)
  +      if (cache2 != null)
         {
  -         cache2.stopService();
  -         cache2.destroyService();
  +         cache2.stop();
  +         cache2.destroy();
            cache2 = null;
         }
      }
  @@ -85,9 +86,15 @@
         // to obtain a reference to the interceptor and work with it directly.
         InvalidationInterceptor mgmt1 = getInvalidationInterceptor(cache1);
         assertNotNull("Cache1 InvalidationInterceptor not found.", mgmt1);
  +
         InvalidationInterceptor mgmt2 = getInvalidationInterceptor(cache2);
         assertNotNull("Cache2 InvalidationInterceptor not found.", mgmt2);      
        
  +      assertTrue("Cache1 not configured to use MBeans", cache1.getConfiguration().isUseInterceptorMbeans());
  +      assertTrue("Cache2 not configured to use MBeans", cache2.getConfiguration().isUseInterceptorMbeans());
  +      assertTrue("InvalidationInterceptor on Cache1 not set up to use statistics!", mgmt1.getStatisticsEnabled());
  +      assertTrue("InvalidationInterceptor on Cache2 not set up to use statistics!", mgmt2.getStatisticsEnabled());
  +
         // verify basic statistics for entries loaded into cache
         assertEquals("Cache1 Invalidations count error: ", new Long(6), new Long(mgmt1.getInvalidations()));
         assertEquals("Cache2 Invalidations count error: ", new Long(10), new Long(mgmt2.getInvalidations()));
  @@ -144,8 +151,8 @@
         c.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
         c.setUseInterceptorMbeans(true);
         c.setClusterName(clusterName);
  -      cache.createService();
  -      cache.startService();
  +      cache.create();
  +      cache.start();
         return cache;
      }
      
  @@ -159,7 +166,7 @@
        {
           Object o = interceptors.get(i);
           if (o instanceof InvalidationInterceptor)
  -           return (InvalidationInterceptor)o;
  +            return (InvalidationInterceptor) o;
        }
        return null;
      }
  
  
  
  1.5       +38 -37    JBossCache/tests/functional/org/jboss/cache/mgmt/MgmtCoreTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MgmtCoreTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/mgmt/MgmtCoreTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- MgmtCoreTest.java	20 Jul 2006 10:54:00 -0000	1.4
  +++ MgmtCoreTest.java	6 Sep 2006 15:30:58 -0000	1.5
  @@ -13,8 +13,9 @@
   
   /**
    * Simple functional tests for CacheMgmtInterceptor
  + *
    * @author Jerry Gauthier
  - * @version $Id: MgmtCoreTest.java,v 1.4 2006/07/20 10:54:00 msurtani Exp $
  + * @version $Id: MgmtCoreTest.java,v 1.5 2006/09/06 15:30:58 msurtani Exp $
    */
   public class MgmtCoreTest extends TestCase
   {
  @@ -31,17 +32,17 @@
         cache = new TreeCache();
         cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
         cache.getConfiguration().setUseInterceptorMbeans(true);
  -      cache.createService();
  -      cache.startService();
  +      cache.create();
  +      cache.start();
      }
   
      protected void tearDown() throws Exception
      {
         super.tearDown();
  -      if(cache != null)
  +      if (cache != null)
         {
  -         cache.stopService();
  -         cache.destroyService();
  +         cache.stop();
  +         cache.destroy();
            cache = null;
         }
      }
  @@ -226,7 +227,7 @@
        {
           Object o = interceptors.get(i);
           if (o instanceof CacheMgmtInterceptor)
  -           return (CacheMgmtInterceptor)o;
  +            return (CacheMgmtInterceptor) o;
        }
        return null;
      }
  
  
  
  1.8       +93 -85    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.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- NotificationTest.java	16 Aug 2006 10:52:51 -0000	1.7
  +++ NotificationTest.java	6 Sep 2006 15:30:58 -0000	1.8
  @@ -12,6 +12,7 @@
   import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.interceptors.CacheMgmtInterceptor;
   import org.jboss.cache.loader.CacheLoader;
  +import org.jboss.cache.util.MBeanConfigurator;
   import org.jboss.cache.xml.XmlHelper;
   import org.w3c.dom.Element;
   
  @@ -27,8 +28,9 @@
   
   /**
    * Functional tests for CacheMgmtInterceptor broadcast of cache event notifications
  + *
    * @author Jerry Gauthier
  - * @version $Id: NotificationTest.java,v 1.7 2006/08/16 10:52:51 msurtani Exp $
  + * @version $Id: NotificationTest.java,v 1.8 2006/09/06 15:30:58 msurtani Exp $
    */
   public class NotificationTest extends TestCase
   {
  @@ -75,12 +77,14 @@
      protected void tearDown() throws Exception
      {
         super.tearDown();
  -      if(cache != null)
  +      if (cache != null)
         {
            // stop the cache before the listener is unregistered
  -         //cache1.stopService();
  -         cache.destroyService();
  +         //cache1.stop();
  +         cache.destroy();
            cache = null;
  +         // make sure we stop the mbean server
  +         MBeanServerFactory.releaseMBeanServer(m_server);
         }
      }
   
  @@ -91,12 +95,12 @@
   
         MyListener listener = new MyListener();
   
  -      ObjectName mgmt = new ObjectName(cache.getServiceName()+MGMT_SERVICE);
  +      ObjectName mgmt = new ObjectName(MBeanConfigurator.PREFIX + cache.getConfiguration().getClusterName() + MGMT_SERVICE);
         m_server.addNotificationListener(mgmt, listener, null, null);
   
         // start the cache after registering listener - this will trigger CacheStarted
         // since cache is defined with cluster, thiswill also trigger ViewChange
  -      cache.startService();
  +      cache.start();
   
         // add a node - this will trigger NodeCreated, NodeModify(pre/post) and NodeModified
         HashMap albania = new HashMap(4);
  @@ -105,7 +109,7 @@
         cache.put("Europe/Albania", albania);
   
         // modify a node - this will trigger NodeModified and NodeModify(pre/post)
  -      cache.put("Europe/Albania", POPULATION, new Integer(3563112));
  +      cache.put("Europe/Albania", POPULATION, 3563112);
   
         // retrieve an attribute - this will trigger NodeVisited
         Fqn key = Fqn.fromString("Europe/Albania");
  @@ -125,7 +129,7 @@
         cl.remove(Fqn.fromString(EUROPE_NODE));
   
         // stop the cache
  -      cache.stopService();
  +      cache.stop();
         m_server.removeNotificationListener(mgmt, listener);
   
         // run the tests
  @@ -155,7 +159,7 @@
   
      public void testModifyNotification() throws Exception
      {
  -       final List notifications = new ArrayList();
  +      final List<String> notifications = new ArrayList<String>();
          assertNotNull("MBeanServer is null.", m_server);
          assertNotNull("Cache is null.", cache);
   
  @@ -191,10 +195,15 @@
                  notifications.add("Stopped");
              }
   
  +         public void nodeLoaded(Fqn fqn, boolean pre, Map data)
  +         {
  +            notifications.add("Loaded");
  +         }
  +
          };
   
          cache.getNotifier().addCacheListener(listener);
  -       cache.startService();
  +      cache.start();
   
          // check that the correct locking scheme is in use
          assertEquals(optimistic, cache.getConfiguration().isNodeLockingOptimistic());
  @@ -219,7 +228,7 @@
         TreeCache cache = new TreeCache();
         cache.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/replSync-service.xml")); 
         cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
  -      cache.getConfiguration().setCacheLoaderConfiguration(getCacheLoaderConfig("location="+getTempDir()));
  +      cache.getConfiguration().setCacheLoaderConfiguration(getCacheLoaderConfig("location=" + getTempDir()));
         cache.getConfiguration().setUseInterceptorMbeans(true);
         cache.getConfiguration().setClusterName(clusterName);
         if (optimistic)
  @@ -227,9 +236,9 @@
             cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
             cache.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
         }
  -      cache.createService();
  +      cache.create();
         // start the cache after the listener has been registered
  -      //cache.startService();
  +      //cache.start();
         return cache;
      }
   
  @@ -243,10 +252,9 @@
         assertNotNull("User data is null, should be Object[]", data);
         assertTrue("User data is " + data.getClass().getName() + ", should be Object[]", data instanceof Object[]);
   
  -      Object[] parms = (Object[])data;
  +      Object[] parms = (Object[]) data;
         assertTrue("Parameter is " + parms[1].getClass().getName() + ", should be Boolean", parms[1] instanceof Boolean);
  -      Boolean pre = (Boolean)parms[1];
  -      return pre.booleanValue();
  +      return (Boolean) parms[1];
      }
   
      private Element getCacheLoaderConfig(String properties) throws Exception
  
  
  
  1.4       +33 -32    JBossCache/tests/functional/org/jboss/cache/mgmt/PassivationTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PassivationTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/mgmt/PassivationTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- PassivationTest.java	20 Jul 2006 06:04:56 -0000	1.3
  +++ PassivationTest.java	6 Sep 2006 15:30:58 -0000	1.4
  @@ -17,8 +17,9 @@
   
   /**
    * Simple functional tests for ActivationInterceptor and PassivationInterceptor statistics
  + *
    * @author Jerry Gauthier
  - * @version $Id: PassivationTest.java,v 1.3 2006/07/20 06:04:56 msurtani Exp $
  + * @version $Id: PassivationTest.java,v 1.4 2006/09/06 15:30:58 msurtani Exp $
    */
   public class PassivationTest extends TestCase
   {
  @@ -39,12 +40,12 @@
      protected void tearDown() throws Exception
      {
         super.tearDown();
  -      if(cache != null)
  +      if (cache != null)
         {
            CacheLoader cl = cache.getCacheLoader();
            cl.remove(Fqn.fromString(EUROPE_NODE));
  -         cache.stopService();
  -         cache.destroyService();
  +         cache.stop();
  +         cache.destroy();
            cache = null;
         }
      }
  @@ -226,11 +227,11 @@
         TreeCache cache = new TreeCache();
         Configuration c = new Configuration();
         c.setCacheMode("LOCAL");
  -      c.setCacheLoaderConfiguration(getCacheLoaderConfig("location="+getTempDir()));
  +      c.setCacheLoaderConfiguration(getCacheLoaderConfig("location=" + getTempDir()));
         c.setUseInterceptorMbeans(true);
         cache.setConfiguration(c);
  -      cache.createService();
  -      cache.startService();
  +      cache.create();
  +      cache.start();
         return cache;
      }
   
  @@ -244,7 +245,7 @@
        {
           Object o = interceptors.get(i);
           if (o instanceof ActivationInterceptor)
  -           return (ActivationInterceptor)o;
  +            return (ActivationInterceptor) o;
        }
        return null;
      }
  @@ -259,7 +260,7 @@
        {
           Object o = interceptors.get(i);
           if (o instanceof PassivationInterceptor)
  -           return (PassivationInterceptor)o;
  +            return (PassivationInterceptor) o;
        }
        return null;
      }
  
  
  
  1.6       +54 -53    JBossCache/tests/functional/org/jboss/cache/mgmt/TxTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TxTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/mgmt/TxTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- TxTest.java	20 Jul 2006 11:48:26 -0000	1.5
  +++ TxTest.java	6 Sep 2006 15:30:58 -0000	1.6
  @@ -15,8 +15,9 @@
   
   /**
    * Simple functional tests for TxInterceptor statistics
  + *
    * @author Jerry Gauthier
  - * @version $Id: TxTest.java,v 1.5 2006/07/20 11:48:26 msurtani Exp $
  + * @version $Id: TxTest.java,v 1.6 2006/09/06 15:30:58 msurtani Exp $
    */
   public class TxTest extends TestCase
   {
  @@ -39,16 +40,16 @@
      protected void tearDown() throws Exception
      {
         super.tearDown();
  -      if(cache1 != null)
  +      if (cache1 != null)
         {
  -         cache1.stopService();
  -         cache1.destroyService();
  +         cache1.stop();
  +         cache1.destroy();
            cache1 = null;
         }
  -      if(cache2 != null)
  +      if (cache2 != null)
         {
  -         cache2.stopService();
  -         cache2.destroyService();
  +         cache2.stop();
  +         cache2.destroy();
            cache2 = null;
         }
      }
  @@ -212,8 +213,8 @@
         cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
         cache.getConfiguration().setUseInterceptorMbeans(true);
         cache.getConfiguration().setClusterName(clusterName);
  -      cache.createService();
  -      cache.startService();
  +      cache.create();
  +      cache.start();
         return cache;
      }
      
  @@ -227,7 +228,7 @@
        {
           Object o = interceptors.get(i);
           if (o instanceof TxInterceptor)
  -           return (TxInterceptor)o;
  +            return (TxInterceptor) o;
        }
        return null;
      }
  
  
  



More information about the jboss-cvs-commits mailing list