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