📄 departmentservicetestcase.java
字号:
package sample.test;
import java.util.List;
import junit.framework.Assert;
import junit.textui.TestRunner;
import org.apache.commons.logging.LogFactory;
import sample.BaseException;
import sample.mappings.department.Department;
import sample.mappings.department.OrganizationType;
import sample.service.DepartmentService;
public class DepartmentServiceTestCase extends BaseDAOTestCase{
private DepartmentService departmentService;
protected void setUp() throws Exception {
super.setUp();
log=LogFactory.getLog(DepartmentServiceTestCase.class);
departmentService=(DepartmentService)ctx.getBean("departmentManager");
}
protected void tearDown() throws Exception {
super.tearDown();
departmentService=null;
}
// ******Department******//
// public void testCreateDepartment(){
// Department dept = new Department();
// dept.setName("testDepart");
// // dept.setOrganizationTypeId("8a524cc6089db02a01089db02e420001");
// try{
// departmentService.createDepartment(dept);
//
// }catch(BaseException e){}
//
// }
//
// public void testUpdateDepartment(){
// try{
// Department dept = departmentService.getDepartmentByName("testDepart");
// dept.setNote("123123");
// departmentService.updateDepartment(dept);
// }catch(BaseException a){
//
//
// }
//
// }
public void testDeleteDepart(){
try{
Department dept = departmentService.getDepartmentByName("testDepart");
departmentService.deleteDepartment(dept);
fail("没有相应记录");
} catch (BaseException escepted) {
Assert.assertTrue(true);
}
}
public void testGetAllDept(){
List list = departmentService.getAllDepartment();
Department dept = (Department)list.get(0);
log.info(dept.getName());
Assert.assertNotNull(list);
Assert.assertNotNull(dept.getName());
// Assert.assertEquals(list.size(),2);
}
// public void testGetDepByOrgTypeById(){
//
// List list = departmentService.getDepartmentsByOrgTypeId("8a524cc6089db02a01089db02e420001");
// System.out.println("testGetDepByOrgTypeById - list.size :" + list.size());
// Assert.assertNotNull(list);
// }
//
// public void testGetDepByParentDep(){
//
// Set depts = departmentService.getDepartmentByParentDepartmentId("8a524cc6089dc50c01089dc518040004");
// Assert.assertEquals(depts.size(),1);
// }
// ******OrganizationType******//
// public void testCreateOrgType(){
// OrganizationType org= new OrganizationType();
// org.setName("testorg");
// try{
// departmentService.createOrganizationrType(org);
// }catch(BaseException s){}
// }
//
// public void testUpdateOrgType(){
//
// OrganizationType org = departmentService.getOrganizationTypeByName("testorg");
// org.setNote("rewrw");
// }
// public void testDeletOrgType(){
//
// try{
// OrganizationType org = departmentService.getOrganizationTypeByName("testorg");
// departmentService.deleteOrganizationrType(org);
// fail("没有相应记录");
//
//
// } catch (BaseException escepted) {
//
// Assert.assertTrue(true);
// }
// }
//
// public void testGetAllOrg(){
//
// List list = departmentService.getAllOrganizationType();
// Assert.assertNotNull(list);
// }
//
public static void main(String[] args)throws Exception{
TestRunner.run(DepartmentServiceTestCase.class);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -