用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - jsp代码库

csms服装库存管理系统(struts+hibernate) 课程设计

2013-07-04 作者: 小蜜锋举报

[jsp]代码库

package com.csms.dao.test;

import static org.junit.Assert.*;

import java.sql.Timestamp;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.csms.action.vo.OrderInVo;
import com.csms.action.vo.OrderOutVo;
import com.csms.dao.OrderoutDAO;
import com.csms.dao.WarehouseDAO;
import com.csms.dao.model.Orderin;
import com.csms.dao.model.Orderout;
import com.csms.dao.model.Warehouse;
import com.csms.service.UserService;

/*
 *
 * jUnit测试类
 *
 * 测试出库模块Dao类
 *
 */
public class OrderoutDAOTest {

	private static OrderoutDAO orderoutDAO;
	private static WarehouseDAO warehouseDAO;
	private static Orderout orderout;
	private static Warehouse warehouse;

	@Before
	public void setUp() throws Exception {
		orderoutDAO = new OrderoutDAO();
		warehouseDAO = new WarehouseDAO();
		orderout = new Orderout();
		warehouse = new Warehouse();
	}

	@After
	public void tearDown() throws Exception {
		orderout = null;
		warehouse = null;
	}

	@Test
	public void testSave() {
		try {
			warehouse = (Warehouse) warehouseDAO.findByProperty("warehouseNum",
					"1").get(0);
			orderout.setOrderOutNum("1000000000");
			orderout.setOutDate(Timestamp.valueOf("2013-07-02 00:00:00"));
			orderout.setWarehouse((Warehouse) warehouseDAO.findByProperty(
					"warehouseNum", "1").get(0));
			orderout.setOutPerson("jUnit");
			orderout.setOutPersonTel("10086");
			orderout.setOutPersonAddress("jUnit");
			orderout.setNote("jUnit");
			orderout.setFlag(0);
			orderout.setPerson("jUnit");
			orderoutDAO.save(orderout);
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
			assertTrue(false);
		}
		assertTrue(true);
	}

	@Test
	public void testFindByProperty() {
		List list = orderoutDAO.findByProperty("orderOutNum", "1000000000");
		assertTrue(list.size() == 1);
	}

	@Test
	public void testFindAll() {
		List list = orderoutDAO.findAll();
		assertTrue(list.size() >= 1);
	}

	@Test
	public void testMerge() {
		try {
			orderout = (Orderout) orderoutDAO.findByProperty("orderOutNum",
					"1000000000").get(0);
			orderout.setNote("jUnit!!!");
			orderout.setPerson("jUnit!!!");
			orderout.setOutDate(Timestamp.valueOf("2013-07-03 00:00:00"));
			orderoutDAO.merge(orderout);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			assertTrue(false);
		}
		assertTrue(true);
	}

	@Test
	public void testFindByLike() {

		OrderOutVo orderoutVo = new OrderOutVo();
		orderoutVo.setFlag(1);
		orderoutVo.setNote("nit!");
		orderoutVo.setOrderOutNum("1000");
		orderoutVo.setPerson("jUnit!!");

		List list = orderoutDAO.findByLike(orderoutVo);

		assertTrue(list.size() >= 1);
	}

	@Test
	public void testDelete() {
		try {
			orderout = (Orderout) orderoutDAO.findByProperty("orderOutNum",
					"1000000000").get(0);
			orderoutDAO.delete(orderout);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			assertTrue(false);
		}
		assertTrue(true);
	}
}

[代码运行效果截图]


csms服装库存管理系统(struts+hibernate) 课程设计

[源代码打包下载]




网友评论    (发表评论)

共3 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...