KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > xbean > ManagementContextXBeanConfigTest


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.xbean;
19
20 import java.net.URI JavaDoc;
21 import java.util.Hashtable JavaDoc;
22
23 import javax.management.MBeanServer JavaDoc;
24 import javax.management.ObjectName JavaDoc;
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 /**
33  *
34  * @version $Revision: 1.1 $
35  */

36 public class ManagementContextXBeanConfigTest extends TestCase {
37
38     protected BrokerService brokerService;
39
40     public void testManagmentContextConfiguredCorrectly() throws Exception JavaDoc {
41
42         assertEquals(2011, brokerService.getManagementContext().getConnectorPort());
43         assertEquals("test.domain", brokerService.getManagementContext().getJmxDomainName());
44         
45         MBeanServer JavaDoc beanServer = brokerService.getManagementContext().getMBeanServer();
46         
47         
48         // Make sure the broker is registered in the right jmx domain.
49
Hashtable JavaDoc map = new Hashtable JavaDoc();
50         map.put("Type", "Broker");
51         map.put("BrokerName", JMXSupport.encodeObjectNamePart("localhost"));
52         ObjectName JavaDoc on = new ObjectName JavaDoc("test.domain", map);
53
54         Object JavaDoc value = beanServer.getAttribute(on, "TotalEnqueueCount");
55         assertNotNull(value);
56     }
57
58     protected void setUp() throws Exception JavaDoc {
59         brokerService = createBroker();
60         brokerService.start();
61     }
62
63     protected void tearDown() throws Exception JavaDoc {
64         if (brokerService != null) {
65             brokerService.stop();
66         }
67     }
68
69     protected BrokerService createBroker() throws Exception JavaDoc {
70         String JavaDoc uri = "org/apache/activemq/xbean/management-context-test.xml";
71         return BrokerFactory.createBroker(new URI JavaDoc("xbean:"+uri));
72     }
73
74 }
75
Popular Tags