浏览 1104 次
锁定老帖子 主题:工具包的简单测试类
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-09-21
package junit.test; import java.util.List; import org.junit.Test; import com.yunchow.user.Product; import com.yunchow.user.Users; import com.yunchow.util.DaoSupport; import com.yunchow.util.MyDataSource; /** * DaoSupport测试类 * @author Administrator * */ public class TestUser { @Test public void testUpdate() { DaoSupport<Users> gd = new DaoSupport<Users>(Users.class); Users us = new Users(); us.setUserId(11); us.setUserName("修改Tom"); us.setEmail("xxx"); us.setPassword("tomtomtom"); System.out.println("保存结果 为:" + gd.update(us)); } @Test public void testSave() { DaoSupport<Users> gd = new DaoSupport<Users>(Users.class); Users us = new Users(); us.setUserName("Tom"); us.setEmail("xxx"); us.setPassword("ttttt"); System.out.println(us.getRegDate()); System.out.println("保存结果 为:" + gd.save(us)); } @Test public void testRemove() { DaoSupport<Users> gd = new DaoSupport<Users>(Users.class); Users us = new Users(); us.setUserName("Tom"); us.setEmail("xxx"); us.setPassword("ttttt"); gd.remove(us); } @Test public void testCount() { DaoSupport<Users> gd = new DaoSupport<Users>(Users.class); System.out.println(gd.count("userId > 5")); } @Test public void testFindAll() { DaoSupport<Users> gd = new DaoSupport<Users>(Users.class); List<Users> userList = gd.find(5, 1, "", "userId desc"); System.out.println("------------------"); for(Users user : userList) { //System.out.print(user.getUserName() + ","); System.out.print(user.getUserId()); System.out.println(); } } @Test public void testDaoSupport() { DaoSupport<Product> gd = new DaoSupport<Product>(Product.class); List<Product> l = gd.findAll(); for(Product p : l) { System.out.println(p.getPrice()); } } @Test public void test0() { DaoSupport<Users> gd = new DaoSupport<Users>(Users.class); List<Users> userList = gd.findAll(); for(Users user : userList) { System.out.print(user.getUserName() + ","); System.out.print(user.getRegDate()); System.out.println(); } } @Test public void test1() { DaoSupport<Users> gd = new DaoSupport<Users>(Users.class); Users us = new Users(); us.setUserName("Tom"); us.setEmail("xxx"); gd.remove(us); } public void testds() { MyDataSource ds = new MyDataSource(); System.out.println(ds); } public static void main(String[] args) throws Exception { MyDataSource ds = new MyDataSource(); System.out.println(ds); } } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |