1 22 package org.jboss.test.jmx.test; 23 24 import java.util.Iterator ; 25 26 import javax.management.MBeanInfo ; 27 import javax.management.ObjectName ; 28 import javax.naming.InitialContext ; 29 30 import org.jboss.jmx.adaptor.rmi.RMIAdaptor; 31 import org.jboss.test.JBossTestCase; 32 33 39 public class RMIAdaptorUnitTestCase extends JBossTestCase 40 { 41 public RMIAdaptorUnitTestCase(String name) 42 { 43 super(name); 44 } 45 46 52 public void testMBeanInfoMarshalling() throws Exception 53 { 54 getLog().debug("+++ testMBeanInfoMarshalling"); 55 56 initURLHandlers(); 57 58 InitialContext ctx = getInitialContext(); 59 RMIAdaptor rmiAdaptor = (RMIAdaptor)ctx.lookup("jmx/invoker/RMIAdaptor"); 60 Iterator it = rmiAdaptor.queryNames(null, null).iterator(); 61 62 while (it.hasNext()) 63 { 64 ObjectName objectName = (ObjectName )it.next(); 65 try 66 { 67 MBeanInfo mbeanInfo = rmiAdaptor.getMBeanInfo(objectName); 68 } 69 catch (Throwable t) 70 { 71 getLog().error("Caught exception getting MBeanInfo for: " + objectName, t); 72 super.fail("Failed to get MBeanInfo for bean named: " + objectName); 73 } 74 } 75 } 76 77 82 private void initURLHandlers() 83 { 84 String handlerPkgs = System.getProperty("java.protocol.handler.pkgs"); 86 if (handlerPkgs != null) 87 { 88 handlerPkgs += "|org.jboss.net.protocol"; 89 } 90 else 91 { 92 handlerPkgs = "org.jboss.net.protocol"; 93 } 94 System.setProperty("java.protocol.handler.pkgs", handlerPkgs); 95 } 96 } 97 | Popular Tags |