1 22 package org.jboss.test.jbossmx.implementation.util; 23 24 import javax.management.MBeanServer ; 25 import javax.management.MBeanServerFactory ; 26 import javax.management.ObjectName ; 27 28 import org.jboss.test.jbossmx.implementation.TestCase; 29 30 import org.jboss.mx.server.ServerConstants; 31 import org.jboss.mx.util.AgentID; 32 33 34 public class AgentIDTestCase 35 extends TestCase 36 implements ServerConstants 37 { 38 public AgentIDTestCase(String s) 39 { 40 super(s); 41 } 42 43 public void testCreate() 44 { 45 String id1 = AgentID.create(); 46 String id2 = AgentID.create(); 47 48 assertTrue(!id1.equals(id2)); 49 } 50 51 public void testGet() 52 { 53 try 54 { 55 MBeanServer server = MBeanServerFactory.createMBeanServer(); 56 String id1 = (String )server.getAttribute(new ObjectName (MBEAN_SERVER_DELEGATE), "MBeanServerId"); 57 String id2 = AgentID.get(server); 58 59 assertTrue(id1.equals(id2)); 60 } 61 catch (Throwable t) 62 { 63 log.debug("failed", t); 64 fail("Unexpected error: " + t.toString()); 65 } 66 } 67 68 } 69 | Popular Tags |