package org.easybooks.bookstore.action;
import org.easybooks.bookstore.service.IUserService;
import org.easybooks.bookstore.vo.User;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/*
* ??????????
*  ??????????????????????????
*  Actor???????
* */
public class UserActionTest {
@Test
public void testRegisterSuccess() throws Exception {
BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext.xml");
User user=new User();
user.setUsername("WYH");
user.setPassword("");
user.setSex("?");
user.setAge(23);
UserAction userAction=new UserAction();
userAction.setUser(user);
userAction.setUserService((IUserService)factory.getBean( "userService" ));
String result=userAction.register();
System.out.println("???:"+user.getUsername()+"???"+result);
}
}

????2????д????????????????????????DAO????в???????????????????????????????????
??????TestUserDAO()?м??????????????
@Test
public void testUserReg(){
User user= new User();
user.setUsername("?????");
user.setSex("?");
user.setPassword("123456");
user.setAge(22);
try {
if(userDAO.exitUser(user.getUsername())){
System.out.println("???????"+user.getUsername()+"????????????????????????");
}else{
userDAO.saveUser(user);
System.out.println("????????"+user.getUsername()+"???");
}
} catch (Exception e) {
System.out.println("??????");
}
}

?????????????????????????????????????????