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

📄 sendgoodsaddressdaotest.java

📁 Struts+Spring+Hibernate实现的在线拍卖系统,去掉了这些组件自身的jar包
💻 JAVA
字号:
package org.bestteam.dao.test;

import java.util.List;

import junit.framework.TestCase;

import org.bestteam.dao.SendGoodsAddressDao;
import org.bestteam.dao.UserInfoDao;
import org.bestteam.domain.SendGoodsAddress;
import org.bestteam.domain.UserInfo;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SendGoodsAddressDaoTest extends TestCase {

	private UserInfoDao userInfoDao;
	private SendGoodsAddressDao addressDao;
	private static ApplicationContext app;
	
	static {
		app = new ClassPathXmlApplicationContext("applicationContext.xml");
	}
	
	protected void setUp() throws Exception {
		super.setUp();
		addressDao = (SendGoodsAddressDao) app.getBean("sendGoodsAddressDao");
		userInfoDao = (UserInfoDao) app.getBean("userInfoDao");
		
	}

	protected void tearDown() throws Exception {
		super.tearDown();
		addressDao = null;
		userInfoDao = null;
	}

	public void testAttachDirty() {
		UserInfo user = userInfoDao.findUserInfoByUserID(new Integer(1));
		List list = addressDao.findSendGoodsAddressByProperty("userinfo", user);
		if (list.size() > 0) {
			SendGoodsAddress address = (SendGoodsAddress) list.get(0);
			address.setReceiveUserName("赵磊");
			assertTrue(addressDao.attachDirty(address));
		}
	}

	public void testDelete() {
		fail("尚未实现");
	}

	public void testFindSendGoodsAddressByProperty() {
		List list = addressDao.findSendGoodsAddressByProperty("receiveUserName", "王志伟");
		assertNotNull(list);
	}

	public void testFindSendGoodsAddressByUserId() {
		SendGoodsAddress address = addressDao.findSendGoodsAddressByUserId(new Integer(1));
		assertNotNull(address);
	}

	public void testSave() {
		UserInfo user = userInfoDao.findUserInfoByUserID(new Integer(1));
		SendGoodsAddress address = new SendGoodsAddress();
		address.setUserinfo(user);
		address.setAddress("北京市海淀区");
		address.setReceiveUserName("王志伟");
		assertTrue(addressDao.save(address));
	}

}

⌨️ 快捷键说明

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