1 16 17 package org.springframework.jmx.export; 18 19 import javax.management.MBeanServer ; 20 import javax.management.ObjectName ; 21 22 import junit.framework.TestCase; 23 24 import org.springframework.context.support.ClassPathXmlApplicationContext; 25 import org.springframework.jmx.support.ObjectNameManager; 26 27 30 public class LazyInitTests extends TestCase { 31 32 public void testLazyInit() { 33 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getApplicationContextPath()); 34 ctx.close(); 35 } 36 37 public void testInvokeOnLazyInitBean() throws Exception { 38 ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getApplicationContextPath()); 39 try { 40 MBeanServer server = (MBeanServer ) ctx.getBean("server"); 41 42 ObjectName oname = ObjectNameManager.getInstance("bean:name=testBean2"); 43 String name = (String ) server.getAttribute(oname, "Name"); 44 45 assertEquals("Invalid name returned", "foo", name); 46 } 47 finally { 48 ctx.close(); 49 } 50 } 51 52 private String getApplicationContextPath() { 53 return "org/springframework/jmx/export/lazyInit.xml"; 54 } 55 56 } 57 | Popular Tags |