User: juhalindfors
  Date: 02/04/08 16:26:24

  Modified:    src/main/test/compliance/server MBeanServerTEST.java
  Log:
  instantiate tests that show a NPE from BasicMBeanRegistry when null loader
  is used (should use the mbean server's cl in that case)
  
  fix coming up
  
  Revision  Changes    Path
  1.11      +96 -3     jmx/src/main/test/compliance/server/MBeanServerTEST.java
  
  Index: MBeanServerTEST.java
  ===================================================================
  RCS file: /cvsroot/jboss/jmx/src/main/test/compliance/server/MBeanServerTEST.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MBeanServerTEST.java      8 Apr 2002 21:22:47 -0000       1.10
  +++ MBeanServerTEST.java      8 Apr 2002 23:26:24 -0000       1.11
  @@ -54,7 +54,7 @@
    * Tests the MBean server impl. through the <tt>MBeanServer</tt> interface.
    *
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Juha Lindfors</a>.
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    *   
    */
   public class MBeanServerTEST
  @@ -801,6 +801,98 @@
       }
   
      /**
  +    * Tests instantiate(String className) with null class name. According to
  +    * javadoc, should throw RuntimeOperationsException wrapping IllegalArgException.
  +    */
  +   public void testInstantiateWithNullClassName() throws Exception
  +   {
  +      try
  +      {
  +         MBeanServer server = MBeanServerFactory.createMBeanServer();
  +         Object o = server.instantiate(null);
  +
  +         // should not reach here
  +         fail("incorrect exception behavior");
  +      }
  +      catch (RuntimeOperationsException e)
  +      {
  +         // expected
  +         
  +         // check that it wraps IAE
  +         assertTrue(e.getTargetException() instanceof IllegalArgumentException);
  +      }
  +   }  
  +
  +   /**
  +    * Tests instantiate(String className) with empty class name string. should
  +    * throw ReflectionException wrapping CNFE.
  +    */
  +   public void testInstantiateWithEmptyClassName() throws Exception
  +   {
  +      try
  +      {
  +         MBeanServer server = MBeanServerFactory.createMBeanServer();
  +         Object o = server.instantiate("");
  +
  +         // should not reach here
  +         fail("incorrect exception/classloading behavior");
  +      }
  +      catch (ReflectionException e)
  +      {
  +         // expected
  +         
  +         // check that it wraps CNFE
  +         assertTrue(e.getTargetException() instanceof ClassNotFoundException);
  +      }
  +   }  
  +
  +   /**
  +    * Tests instantiate(String className, ObjectName loader) with null class name. 
According to
  +    * javadoc, should throw RuntimeOperationsException wrapping IllegalArgException.
  +    */
  +   public void testInstantiateWithNullClassName2() throws Exception
  +   {
  +      try
  +      {
  +         MBeanServer server = MBeanServerFactory.createMBeanServer();
  +         Object o = server.instantiate(null, null);
  +
  +         // should not reach here
  +         fail("incorrect exception behavior");
  +      }
  +      catch (RuntimeOperationsException e)
  +      {
  +         // expected
  +         
  +         // check that it wraps IAE
  +         assertTrue(e.getTargetException() instanceof IllegalArgumentException);
  +      }
  +   }  
  +
  +   /**
  +    * Tests instantiate(String className, ObjectName loader) with empty class name 
string. should
  +    * throw ReflectionException wrapping CNFE.
  +    */
  +   public void testInstantiateWithEmptyClassName2() throws Exception
  +   {
  +      try
  +      {
  +         MBeanServer server = MBeanServerFactory.createMBeanServer();
  +         Object o = server.instantiate("", null);
  +
  +         // should not reach here
  +         fail("incorrect exception/classloading behavior");
  +      }
  +      catch (ReflectionException e)
  +      {
  +         // expected
  +         
  +         // check that it wraps CNFE
  +         assertTrue(e.getTargetException() instanceof ClassNotFoundException);
  +      }
  +   }  
  +    
  +   /**
       * Tests instantiate(String className) classloading behaviour. According to
       * javadoc, DLR should be used to instantiate the class
       */
  @@ -821,8 +913,9 @@
         assertTrue(o.getClass().getClassLoader().equals(mlet));
      }  
      
  +   
      /**
  -    * Tests instantiate(String className) classloading behaviour. According to
  +    * Tests instantiate(String className, ObjectName loader) classloading 
behaviour. According to
       * javadoc, DLR should be used to instantiate the class. This should fail as
       * the MLet MBean is never added to the agent and therefore not in the DLR.
       */
  @@ -859,7 +952,7 @@
            assertTrue(e.getTargetException() instanceof ClassNotFoundException);
         }
      }  
  -   
  +      
      
       // MBeanServer registerMBean ------------------------------------
       
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Sponsored by http://www.ThinkGeek.com/

Reply via email to