使用Junit进行单元测试,首先引入Junit的jar,配置如下。
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:factory_bean.xml") public class MainApp { @Test public void demon1() { ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"factory_bean.xml"}); Person p1 = context.getBean("chinese",Person.class); System.out.println(p1.sayHello("Marry")); System.out.println(p1.sayGoodBye("Marry")); Person p2 = context.getBean("chinese",Person.class); System.out.println(p2 == p1); System.out.println(context.getBean("&chinese")); } }
作者:Work Hard Work Smart
出处:http://www.cnblogs.com/linlf03/
欢迎任何形式的转载,未经作者同意,请保留此段声明!