尝试用单元测试做spring注入调用service
2012-05-22 16:43 java ee spring 阅读(729) 评论(0) 编辑 收藏 举报尝试用单元测试做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());
}
}