Bookmarks links 2(我收藏的链接2)
在appfuse应用架构下用Eclipse进行DAO单元测试
在appfuse应用架构下用Eclipse进行DAO单元测试:
假设工程根目录为%PROJECT_ROOT%
1、把%PROJECT_ROOT%下build\dao\gen等目录加入工程的“Java构建路径”——“库”中的“构建路径上的jar和类文件夹”列表中,完整的须加入的路径:
<classpathentry kind="lib" path="build/dao/gen"/>
<classpathentry kind="lib" path="build/web/classes"/>
<classpathentry kind="lib" path="build/[webappName]"/>
3、为了支持ant test-dao,修改properties.xml的dao.test.classpath,增加
<fileset dir="${commons.dir}" includes="*.jar"/>
<fileset dir="${osworkflow.dir}" includes="*.jar"/>
测试DAO依赖 mail.properties、database.properties等文件和下列xml文件:
%PROJECT_ROOT%\build\dao\gen\*.hbm.xml
%PROJECT_ROOT%\dao\applicationContext-resources.xml
%PROJECT_ROOT%\build\dao\gen\META-INF\applicationContext-hibernate.xml
下面的代码就可以满足测试DAO的依赖
protected String[] getConfigLocations() {
setAutowireMode(AUTOWIRE_BY_NAME);
return new String [] {"classpath*:/**/dao/applicationContext-*.xml",
"classpath*:META-INF/applicationContext-*.xml","/WEB-INF/applicationContext-resources.xml"};
}
