class UserTest
package com.slipp.user;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.slipp.PasswordMismatchException;
import com.slipp.db.Database;
public class UserTest {
public static User TEST_USER =new User("userid", "password", "name", "java@rok.net" );
@Test
public void matchPassword(){
assertTrue( TEST_USER.matchPassword("password"));
}
@Test
public void notMatchPassword(){
assertFalse(TEST_USER.matchPassword("password2"));
}
//로그인 성공 여부 테스트
@Test
public void login() throws Exception {
User user =add();
assertTrue(User.login(user.getUserid(), user.getPassword()));
}
@Test(expected=NotFoundUserException.class)
public void loginWhenNotExitedUser() throws Exception {
assertFalse(User.login("ss", "s"));
}
@Test(expected=PasswordMismatchException.class)
public void loginWhenPasswordMissmatch() throws Exception {
User user =add();
User.login(user.getUserid(), "s");
}
@Test
public void test(){
add();
}
public User add(){
User user =new User();
user.setName("홍길동");
user.setPassword("1111");
user.setUserid("qqq");
user.setEmail("aaa@aaa");
UserDAO dao=new UserDAO();
dao.removeUser(user.getUserid());
dao.insert(user);
return user;
}
}
댓글 ( 4)
댓글 남기기