⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testuserdao.java

📁 struts+spring+hibernate 集成的例子
💻 JAVA
字号:
package com.test.dao;

import java.util.List;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.lqk.dao.UserDAO;
import com.lqk.vo.Users;

public class TestUserDAO extends TestCase {

	public TestUserDAO(String arg0) {
		super(arg0);
	}

	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}
	
	public UserDAO getDao(){
		String currentPath = null;
		currentPath = TestUserDAO.class.getResource("/").getPath();
		String[] patterns = new String[] {
				currentPath + "../applicationContext.xml"};
		
		ApplicationContext ctx= new FileSystemXmlApplicationContext(patterns);
		return (UserDAO)ctx.getBean("userDAOProxy");
	}
	
	public void testInsertUser(){
		
		Users user = new Users();
		user.setUsername("王武");
		user.setUserpassword("123");
		user.setUsermail("xiaxin@163.com");
		int i = getDao().insertUser(user);	
		System.out.println(i);
		
		Assert.assertNotNull(new Integer(i));
	}
	
	public void testFindUsersForPage(){
		
		List list = getDao().findUsersForPage(80000,100);
		
		Assert.assertNotNull(list);
	}
	
	public void testGetRow(){
		int i = getDao().getAllRow();
		System.out.println("Count:"+i);
		Assert.assertNotNull(new Integer(i));
	}
	
	public void testTemp(){
		int a=300;
		int b=30;
		int c=(a/b)+1;
		int mod = a%b;
		System.out.println("mod:" + mod);
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -