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

Brian Stansberry brian.stansberry at jboss.com
Fri May 11 23:54:15 EDT 2007


  User: bstansberry
  Date: 07/05/11 23:54:15

  Modified:    tests/functional/org/jboss/cache/pojo/jmx 
                        PojoCacheJmxWrapperTest.java
  Log:
  Add tests
  
  Revision  Changes    Path
  1.2       +84 -2     JBossCache/tests/functional/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapperTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PojoCacheJmxWrapperTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapperTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- PojoCacheJmxWrapperTest.java	11 May 2007 22:44:49 -0000	1.1
  +++ PojoCacheJmxWrapperTest.java	12 May 2007 03:54:15 -0000	1.2
  @@ -10,6 +10,8 @@
   import javax.management.ObjectName;
   
   import org.jboss.cache.config.Configuration;
  +import org.jboss.cache.pojo.PojoCache;
  +import org.jboss.cache.pojo.test.Person;
   
   /**
    * Tests the PojoCacheJmxWrapper class
  @@ -20,11 +22,32 @@
   public class PojoCacheJmxWrapperTest extends PojoCacheJmxWrapperTestBase
   {   
   
  -   public void testCacheMBeanBinding() throws Exception
  +   public void testCacheMBeanBinding1() throws Exception
      {
         registerWrapper();
         assertTrue("Cache Mbean should be registered ", mBeanServer.isRegistered(plainCacheMBeanName));
  -      assertTrue("PojoCache Mbean hould be registered ", mBeanServer.isRegistered(mBeanName));
  +      assertTrue("PojoCache Mbean should be registered ", mBeanServer.isRegistered(mBeanName));
  +      
  +      unregisterWrapper();
  +      assertFalse("Cache Mbean should not be registered ", mBeanServer.isRegistered(plainCacheMBeanName));
  +      assertFalse("PojoCache Mbean should not be registered ", mBeanServer.isRegistered(mBeanName));
  +   }  
  +
  +   public void testCacheMBeanBinding2() throws Exception
  +   {
  +      PojoCacheJmxWrapperMBean wrapper = createWrapper(createConfiguration());
  +      wrapper = registerWrapper(wrapper);
  +      assertFalse("Cache Mbean should not be registered ", mBeanServer.isRegistered(plainCacheMBeanName));
  +      assertTrue("PojoCache Mbean should be registered ", mBeanServer.isRegistered(mBeanName));
  +      
  +      wrapper.create();
  +      wrapper.start();
  +      
  +      assertTrue("Cache Mbean should be registered ", mBeanServer.isRegistered(plainCacheMBeanName));
  +      
  +      unregisterWrapper();
  +      assertFalse("Cache Mbean should not be registered ", mBeanServer.isRegistered(plainCacheMBeanName));
  +      assertFalse("PojoCache Mbean should not be registered ", mBeanServer.isRegistered(mBeanName));
      }
   
      public void testConfiguration() throws Exception
  @@ -42,4 +65,63 @@
         assertEquals("Cache object name ", tmpName.getCanonicalName(), cacheName);
      }
   
  +   /**
  +    * Tests that setting registerPlainCache=false disables interceptor 
  +    * registration when the wrapper is registered before create/start 
  +    * are called.
  +    * 
  +    * @throws Exception
  +    */
  +   public void testRegisterPlainCache1() throws Exception
  +   {
  +      PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
  +      wrapper.setRegisterPlainCache(false);
  +      
  +      registerWrapper(wrapper);
  +      
  +      assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
  +      assertFalse("Plain cache should not be registered", mBeanServer.isRegistered(plainCacheMBeanName));
  +   }
  +
  +   /**
  +    * Tests that setting registerPlainCache=false disables interceptor 
  +    * registration when the wrapper is registered after create/start 
  +    * are called.
  +    * 
  +    * @throws Exception
  +    */
  +   public void testRegisterPlainCache2() throws Exception
  +   {
  +      PojoCacheJmxWrapper wrapper = createWrapper(createConfiguration());
  +      wrapper.setRegisterPlainCache(false);
  +      wrapper.setRegisterInterceptors(true);
  +      
  +      wrapper.create();
  +      wrapper.start();
  +      
  +      registerWrapper(wrapper);
  +      
  +      assertTrue("Should be registered", mBeanServer.isRegistered(mBeanName));
  +      assertFalse("Plain cache should not be registered", mBeanServer.isRegistered(plainCacheMBeanName));
  +   }
  +   
  +   public void testGetInternalLocation() throws Exception
  +   {
  +      PojoCacheJmxWrapperMBean wrapper = createWrapper(createConfiguration());
  +      wrapper = registerWrapper(wrapper);
  +      wrapper.create();
  +      wrapper.start();
  +      
  +      registerWrapper(wrapper);
  +      PojoCache pc = wrapper.getPojoCache();
  +      
  +      Person joe = new Person();
  +      joe.setName("Joe");
  +      joe.setAge(25);
  +      
  +      pc.attach("/person/joe", joe);
  +      
  +      assertEquals("Correct location", "/person/joe", wrapper.getInternalLocation(joe));
  +   }
  +
   }
  
  
  



More information about the jboss-cvs-commits mailing list