noticedaotest.java
来自「oa系统 很不错 想做毕业设计的 进来看看 还有开题报告 和毕业论文 进来看看」· Java 代码 · 共 83 行
JAVA
83 行
package com.oa.hibernate.test;
import java.util.Iterator;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import com.oa.hibernate.beans.Notice;
import com.oa.hibernate.dao.INoticeDAO;
import com.oa.hibernate.dao.NoticeDAO;
import junit.framework.TestCase;
public class NoticeDAOTest extends TestCase {
public INoticeDAO noticeDAO;
public NoticeDAOTest(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
noticeDAO = new NoticeDAO();
ApplicationContext ctx = new FileSystemXmlApplicationContext(
"WebRoot/WEB-INF/applicationContext.xml");
noticeDAO = (INoticeDAO) ctx.getBean("noticeDAO");
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void testInsert() throws Exception {
Notice notice = new Notice();
notice.setSender("admin");
notice.setTitle("JavaWeb");
notice.setContent("JavaWeb");
notice.setSendtime("2008-10-10");
noticeDAO.insert(notice);
notice = noticeDAO.findById(AllTest.ID);
assertNotNull(notice);
}
public void testFindPager() throws Exception {
List list = noticeDAO.findPager(10, 0).getResultList();
assertTrue(list.size() > 0);
Iterator it = list.iterator();
while (it.hasNext()) {
Notice notice = (Notice) it.next();
assertNotNull(notice);
}
}
public void testFindById() throws Exception {
Notice Notice = noticeDAO.findById(AllTest.ID);
assertNotNull(Notice);
}
public void testUpdate() throws Exception {
Notice notice = new Notice();
notice.setId(new Integer(AllTest.ID));
notice.setSender("admin");
notice.setTitle("JavaWeb Develop");
notice.setContent("JavaWeb");
notice.setSendtime("2008-10-10");
noticeDAO.update(notice);
Notice notice2 = noticeDAO.findById(AllTest.ID);
assertTrue(notice2.getTitle().equals("JavaWeb Develop"));
}
public void testDelete() throws Exception {
noticeDAO.delete(AllTest.ID);
Notice notice = noticeDAO.findById(AllTest.ID);
assertNull(notice);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?