[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);
}
}
[代码运行效果截图]
[源代码打包下载]
初级程序员
by: 卡嘟丫丫 发表于:2014-11-30 19:45:15 顶(0) | 踩(0) 回复
我到底该用哪一个?还有啊,虽然代码上很正确,可是为什么部署了不能用呢?
回复评论