📄 userinfomodeltest.java
字号:
package com.zxx.tsh.test;
import java.io.Serializable;
import java.util.List;
import com.zxx.common.exception.DataAccessException;
import com.zxx.tsh.model.userinfo.pojo.UserType;
import com.zxx.tsh.service.IUserInfoManager;
import com.zxx.tsh.test.Basic.JunitBaseTest;
import com.zxx.tsh.view.userinfo.vo.UserInfoVO;
import com.zxx.tsh.view.userinfo.vo.UserTypeVO;
public class UserInfoModelTest extends JunitBaseTest{
IUserInfoManager ium = null;
Serializable id=null;
public void setUp() throws Exception {
super.setUp();
ium = (IUserInfoManager) actx.getBean("userSearvice");
//id=this.addUserType();
}
public void tearDown() throws Exception {
super.tearDown();
//System.out.println("删除用户类型状态:"+ium.deleteUserType(id));
}
private String addUserType(){
UserTypeVO uVo = new UserTypeVO();
uVo.setTypeName("管理员");
uVo.setTypeDescription("管理系统的日常维护工作");
String id=null;
try {
id = (String)ium.addUserType(uVo);
if(id.length()!=32){
System.out.println("添加用户类型挫败!");
}else{
System.out.println("添加用户类型成功!类型Id为:"+id);
}
} catch (DataAccessException e) {
e.printStackTrace();
}
return id;
}
private UserTypeVO getUserTypeById(Serializable id){
UserTypeVO utVo = null;
if(id!=null){
try {
System.out.println("id="+id);
utVo=ium.getUserTypeById(id);
if(utVo!=null)
System.out.println("用户类型对象为:"+utVo.getClass());
else
System.out.println("取得用户类型对象失败!");
} catch (DataAccessException e) {
e.printStackTrace();
}
}
return utVo;
}
public void testAddUserType(){
addUserType();
}
public void testDeleteUserType(){
//String id ="4028810910829c030110829c0b740001";
try {
System.out.println("删除结果:"+ium.deleteUserType(addUserType()));
} catch (DataAccessException e) {
e.printStackTrace();
}
}
public void testGetType(){
System.out.println(getUserTypeById("USER_TYPE_012ba700dfs72ab031s4b3").toString());
}
public void testlistAllUserType(){
try {
List<UserTypeVO> list = ium.listAllUserType();
for(UserTypeVO utVo: list){
System.out.println("用户类型VO对象有:"+utVo.toString()+"\n");
}
} catch (DataAccessException e) {
e.printStackTrace();
}
}
private String addUserInfo(){
id="USER_TYPE_012ba700dfs72ab031s4b3";
String _id = null;
if(id!=null){
UserInfoVO uVo = new UserInfoVO();
uVo.setUserName("潇湘振宇");
uVo.setUserPwd("123456");
uVo.setUserRealName("zhangxianxin");
uVo.setUserSex("男");
UserType ut = new UserType();
UserTypeVO utVo = (UserTypeVO)this.getUserTypeById(id);
if(utVo!=null){
ut.setTypeDescription(utVo.getTypeDescription());
ut.setTypeId(utVo.getTypeId());
ut.setTypeName(utVo.getTypeName());
uVo.setUserType(ut);
try {
_id = (String)ium.addUser(uVo);
if(_id.length()!=32){
System.out.println("添加用户失败!");
}else{
System.out.println("添加用户成功!用户Id为:"+_id);
}
} catch (DataAccessException e) {
e.printStackTrace();
}
}
}
return _id;
}
public void testAddUserInfo(){
addUserInfo();
}
public void testDeleteUserInfo(){
try {
System.out.println("删除结果:"+ium.deleteUserInfo(addUserInfo()));
} catch (DataAccessException e) {
e.printStackTrace();
}
}
private UserInfoVO getUserInfoById(Serializable id){
UserInfoVO utVo = null;
if(id!=null){
try {
System.out.println("id="+id);
utVo=ium.getUserInfoById(id);
if(utVo!=null)
System.out.println("用户对象为:"+utVo.toString());
else
System.out.println("取得用户类型对象失败!");
} catch (DataAccessException e) {
e.printStackTrace();
}
}
return utVo;
}
public void testGetUser(){
System.out.println(getUserInfoById("4028814edfe78aa700dfe78ab0a10001").toString());
}
public void testLogin(){
try {
if(ium.getUserInfoByLogin(this.getUserInfoById("4028814edfe78aa700dfe78ab0a10001"))){
System.out.println("登录成功!");
}else{
System.out.println("登录失败!");
}
} catch (DataAccessException e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -