1 4 5 package org.springframework.jmx; 6 7 import javax.management.MBeanServer ; 8 import javax.management.MBeanServerFactory ; 9 10 import junit.framework.TestCase; 11 12 import org.springframework.context.ApplicationContext; 13 import org.springframework.context.support.ClassPathXmlApplicationContext; 14 15 18 public abstract class AbstractJmxTests extends TestCase { 19 20 private ClassPathXmlApplicationContext ctx; 21 22 protected MBeanServer server; 23 24 public void setUp() throws Exception { 25 server = MBeanServerFactory.createMBeanServer(); 26 ctx = new ClassPathXmlApplicationContext(getApplicationContextPath()); 27 } 28 29 protected String 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 { 38 ctx.close(); 39 MBeanServerFactory.releaseMBeanServer(server); 40 assertTrue("MBeanServers not fully cleaned up", MBeanServerFactory.findMBeanServer(null).isEmpty()); 41 } 42 43 } 44 | Popular Tags |