1 18 package org.apache.activemq.xbean; 19 20 import java.net.URI ; 21 import java.util.Hashtable ; 22 23 import javax.management.MBeanServer ; 24 import javax.management.ObjectName ; 25 26 import junit.framework.TestCase; 27 28 import org.apache.activemq.broker.BrokerFactory; 29 import org.apache.activemq.broker.BrokerService; 30 import org.apache.activemq.util.JMXSupport; 31 32 36 public class ManagementContextXBeanConfigTest extends TestCase { 37 38 protected BrokerService brokerService; 39 40 public void testManagmentContextConfiguredCorrectly() throws Exception { 41 42 assertEquals(2011, brokerService.getManagementContext().getConnectorPort()); 43 assertEquals("test.domain", brokerService.getManagementContext().getJmxDomainName()); 44 45 MBeanServer beanServer = brokerService.getManagementContext().getMBeanServer(); 46 47 48 Hashtable map = new Hashtable (); 50 map.put("Type", "Broker"); 51 map.put("BrokerName", JMXSupport.encodeObjectNamePart("localhost")); 52 ObjectName on = new ObjectName ("test.domain", map); 53 54 Object value = beanServer.getAttribute(on, "TotalEnqueueCount"); 55 assertNotNull(value); 56 } 57 58 protected void setUp() throws Exception { 59 brokerService = createBroker(); 60 brokerService.start(); 61 } 62 63 protected void tearDown() throws Exception { 64 if (brokerService != null) { 65 brokerService.stop(); 66 } 67 } 68 69 protected BrokerService createBroker() throws Exception { 70 String uri = "org/apache/activemq/xbean/management-context-test.xml"; 71 return BrokerFactory.createBroker(new URI ("xbean:"+uri)); 72 } 73 74 } 75 | Popular Tags |