尝试用单元测试做spring注入调用service

尝试用单元测试做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());
}


}

你可能感兴趣的:(spring,exception,service,单元测试,HashMap)