标签:
public static ArrayList GetList(String deptId){
urllist.add("dept1="+deptId);
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
Criteria criteriadep2 = session.createCriteria(DepartmentTab.class);
Criteria criteria2 = session.createCriteria(DepartmentTab.class);
Criterion criterion1 = Restrictions.eq("parentId", deptId);
criteriadep2.add(criterion1);
List dept2List = criteriadep2.list();
for(EhrbiDepartmentTab dept2:dept2List){
urllist.add("dept1="+deptId+"&"+"dept2="+dept2.getDeptId());
dept2IdList.add(dept2.getDeptId());
}
logger.info(dept2IdList);
logger.info(urllist);
for(int i = 0;i dept3List = criteriadep3.list();
for(EhrbiDepartmentTab dept3:dept3List){
urllist.add("dept1="+deptId+"&"+"dept2="+dept2IdList.get(i)+"&"+"dept3="+dept3.getDeptId());
}
}
if(session!=null){
session.close();
}
return urllist;
}
获得下面的组合:[INFO ]16:11:45,833,main,[Class]DatabaseUtil, [Method]GetUrlList, [dept1=D032, dept1=D032&dept2=D032001, dept1=D032&dept2=D032002, dept1=D032&dept2=D032007, dept1=D032&dept2=D032008, dept1=D032&dept2=D032012, dept1=D032&dept2=D032016, dept1=D032&dept2=D032025, dept1=D032&dept2=D032029, dept1=D032&dept2=D032030, dept1=D032&dept2=D032034, dept1=D032&dept2=D032062, dept1=D032&dept2=D032002&dept3=D032009, dept1=D032&dept2=D032002&dept3=D032010, dept1=D032&dept2=D032002&dept3=D032041, dept1=D032&dept2=D032007&dept3=D032014, dept1=D032&dept2=D032008&dept3=D032042, dept1=D032&dept2=D032008&dept3=D032043, dept1=D032&dept2=D032008&dept3=D032044, dept1=D032&dept2=D032008&dept3=D032045, dept1=D032&dept2=D032008&dept3=D032046, dept1=D032&dept2=D032008&dept3=D032047, dept1=D032&dept2=D032012&dept3=D032066, dept1=D032&dept2=D032025&dept3=D032026, dept1=D032&dept2=D032025&dept3=D032027, dept1=D032&dept2=D032025&dept3=D032028, dept1=D032&dept2=D032029&dept3=D032048, dept1=D032&dept2=D032029&dept3=D032049, dept1=D032&dept2=D032029&dept3=D032050, dept1=D032&dept2=D032029&dept3=D032052, dept1=D032&dept2=D032029&dept3=D032053, dept1=D032&dept2=D032029&dept3=D032060, dept1=D032&dept2=D032029&dept3=D032063, dept1=D032&dept2=D032030&dept3=D032031, dept1=D032&dept2=D032030&dept3=D032032, dept1=D032&dept2=D032030&dept3=D032033, dept1=D032&dept2=D032034&dept3=D032036, dept1=D032&dept2=D032034&dept3=D032037, dept1=D032&dept2=D032034&dept3=D032040, dept1=D032&dept2=D032034&dept3=D032054, dept1=D032&dept2=D032034&dept3=D032055, dept1=D032&dept2=D032034&dept3=D032056, dept1=D032&dept2=D032034&dept3=D032057, dept1=D032&dept2=D032034&dept3=D032058, dept1=D032&dept2=D032034&dept3=D032059, dept1=D032&dept2=D032034&dept3=D032061, dept1=D032&dept2=D032034&dept3=D032064]
通过上面的方法,遍历一级组织后,就可以获取全集的测试数据。 public static ArrayList GetAllList(){
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
Criteria criteriadep1 = session.createCriteria(EhrbiDepartmentTab.class);
Criteria criteria2 = session.createCriteria(EhrbiDepartmentTab.class);
Criterion criterion1 = Restrictions.eq("depth", 1);
criteriadep1.add(criterion1);
List dept1List = criteriadep1.list();
for(DepartmentTab dept1:dept1List){
urllist.add("dept1="+dept1.getDeptId());
dept1IdList.add(dept1.getDeptId());
}
for(int i=0;i<dept1IdList.size();i++){
GetUrlList((String)dept1IdList.get(i));
}
session.close();
logger.info(urllist);
return urllist;
}
看下面的返回结果:
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032001", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032002", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032007", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032008", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032012", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032016", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032025", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032029", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032030", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032062", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032002&dept3=D032009", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032002&dept3=D032010", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032002&dept3=D032041", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032007&dept3=D032014", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032008&dept3=D032042", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032008&dept3=D032043", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032008&dept3=D032044", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032008&dept3=D032045", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032008&dept3=D032046", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032008&dept3=D032047", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032012&dept3=D032066", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032025&dept3=D032026", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032025&dept3=D032027", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032025&dept3=D032028", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032029&dept3=D032048", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032029&dept3=D032049", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032029&dept3=D032050", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032029&dept3=D032052", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032029&dept3=D032053", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032029&dept3=D032060", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032029&dept3=D032063", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032030&dept3=D032031", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032030&dept3=D032032", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032030&dept3=D032033", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032036", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032037", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032040", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032054", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032055", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032056", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032057", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032058", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032059", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032061", 0)
PASSED: GetddTest("...By一级、二级、三级部门", "http://....netease.com/common/getdd.do?dept1=D032&dept2=D032034&dept3=D032064", 0)
===============================================
Default test
Tests run: 47, Failures: 0, Skips: 0
===============================================
这是一个d1下面的遍历结果,可想而知如果是几十个d1级别的组织需要遍历的数量是非常庞大的,如果通过手工编写测试数据的方式是没法进行全集测试的。
结论
通过使用Hibernate从数据库读取关系表的方法来获取多层组织的测试数据,进行全集测试的方法在一些项目中是可以适用的。
标签:
原文地址:http://www.cnblogs.com/appstest/p/4962343.html