mx4j/src/test/test/javax/management MBeanIntrospectionTest.java,NONE,1.1

Jeremy Boynes <[email protected]> Tue, 08 Feb 2005 04:11:52 +0000
Newsgroups gmane.comp.java.mx4j.cvs
Message-ID <[email protected]>
Update of /cvsroot/mx4j/mx4j/src/test/test/javax/management
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27695/src/test/test/javax/management

Added Files:
	MBeanIntrospectionTest.java 
Log Message:
Fix for [ 1115663 ] "is" is not a attr
Added testcase for introspection in general, more tests needed though :-) 

--- NEW FILE: MBeanIntrospectionTest.java ---
/* =====================================================================
 *
 * Copyright (c) 2004 Jeremy Boynes.  All rights reserved.
 *
 * =====================================================================
 */
package test.javax.management;

import test.MX4JTestCase;
import mx4j.server.MBeanIntrospector;
import mx4j.server.MBeanMetaData;

import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;

/**
 * @version $Revision: 1.1 $ $Date: 2005/02/08 04:11:49 $
 */
public class MBeanIntrospectionTest extends MX4JTestCase {
   private MBeanIntrospector introspector;

   public MBeanIntrospectionTest(String name)
   {
      super(name);
   }

   public void testOperationInfo() throws Exception
   {
      MBeanInfo info = introspect(new Basic());
      MBeanOperationInfo[] operations = info.getOperations();
      assertEquals(1, operations.length);
   }

   private MBeanMetaData createMBeanMetaData(Object mbean) throws Exception
   {
      MBeanMetaData metadata = MBeanMetaData.Factory.create();
      metadata.setMBean(mbean);
      metadata.setClassLoader(mbean.getClass().getClassLoader());
      return metadata;
   }

   private MBeanInfo introspect(Object mbean) throws Exception
   {
      MBeanMetaData md = createMBeanMetaData(mbean);
      introspector.introspect(md);
      return md.getMBeanInfo();
   }

   protected void setUp() throws Exception
   {
      introspector = new MBeanIntrospector();
   }

   public static interface BasicMBean
   {
      boolean is();
   }

   public static class Basic implements BasicMBean
   {
      public boolean is() {
         throw new UnsupportedOperationException();
      }
   }
}



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click