尝试用单元测试做spring注入调用service
public class GoodsCategoryServiceImplTest extends TestCase{
public ApplicationContext context=null;
protected void setUp() throws Exception {
String[] files={"appContext-core.xml","appContext-memcached.xml","appContext-mvc.xml"};
context=(ApplicationContext)new ClassPathXmlApplicationContext(files);
}
public void test(){
GoodsCategoryService goodsCategoryService=(GoodsCategoryService) context.getBean("goodsCategoryService");
System.out.println(goodsCategoryService.getAll(new HashMap()).size());
}
}
本文转自yjflinchong 51CTO博客,原文链接:http://blog.51cto.com/yjflinchong/1165011,如需转载请自行联系原作者