1 22 package org.jboss.test.jbossmx.compliance.standard; 23 24 import javax.management.Attribute ; 25 import javax.management.MBeanServer ; 26 import javax.management.MBeanServerFactory ; 27 import javax.management.ObjectName ; 28 29 import org.jboss.test.jbossmx.compliance.TestCase; 30 import org.jboss.test.jbossmx.compliance.standard.support.PackageProtectedMBean; 31 import org.jboss.test.jbossmx.compliance.standard.support.PackageProtectedMBeanFactory; 32 33 39 public class PackageProtectedTestCase extends TestCase 40 { 41 public PackageProtectedTestCase(String s) 42 { 43 super(s); 44 } 45 46 49 public void testRegisterPackageProtectedClassImpl() 50 { 51 try 52 { 53 MBeanServer server = MBeanServerFactory.newMBeanServer(); 54 ObjectName objectName = new ObjectName ("test:key=value"); 55 PackageProtectedMBean mbean = PackageProtectedMBeanFactory.createMBean("TestMBean"); 56 57 server.registerMBean(mbean, objectName); 58 59 String name = (String )server.getAttribute(objectName, "Name"); 60 assertEquals("TestMBean", name); 61 62 server.setAttribute(objectName, new Attribute ("Name", "TestMBeanX")); 63 name = (String )server.getAttribute(objectName, "Name"); 64 assertEquals("TestMBeanX", name); 65 66 String message = "hello"; 67 String reply = (String )server.invoke( 68 objectName, 69 "echo", 70 new Object [] { message }, 71 new String [] { "java.lang.String" }); 72 73 assertEquals(message, reply); 74 75 server.unregisterMBean(objectName); 76 } 77 catch (Exception e) 78 { 79 log.debug("Unexpected Exception", e); 80 fail("Caught unexpected exception"); 81 } 82 } 83 } 84 | Popular Tags |