KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jmx > AbstractJmxTests


1 /*
2  * Created on Jul 5, 2004
3  */

4
5 package org.springframework.jmx;
6
7 import javax.management.MBeanServer JavaDoc;
8 import javax.management.MBeanServerFactory JavaDoc;
9
10 import junit.framework.TestCase;
11
12 import org.springframework.context.ApplicationContext;
13 import org.springframework.context.support.ClassPathXmlApplicationContext;
14
15 /**
16  * @author Rob Harrop
17  */

18 public abstract class AbstractJmxTests extends TestCase {
19
20     private ClassPathXmlApplicationContext ctx;
21
22     protected MBeanServer JavaDoc server;
23
24     public void setUp() throws Exception JavaDoc {
25         server = MBeanServerFactory.createMBeanServer();
26         ctx = new ClassPathXmlApplicationContext(getApplicationContextPath());
27     }
28
29     protected String JavaDoc getApplicationContextPath() {
30         return "org/springframework/jmx/applicationContext.xml";
31     }
32
33     protected ApplicationContext getContext() {
34         return this.ctx;
35     }
36
37     public void tearDown() throws Exception JavaDoc {
38         ctx.close();
39         MBeanServerFactory.releaseMBeanServer(server);
40         assertTrue("MBeanServers not fully cleaned up", MBeanServerFactory.findMBeanServer(null).isEmpty());
41     }
42
43 }
44
Popular Tags