📄 infoobjectdaotest.java
字号:
/*
* 创建日期 2005-6-14
*
*/
package com.ibm.sample.dao;
import org.springframework.dao.DataAccessException;
import com.ibm.sample.bo.InfoObject;
/**
* @author rayguo mail:guorui@cn.ibm.com
*
*/
public class InfoObjectDAOTest extends BaseDAOTestCase {
private IInfoObjectDAO dao = null;
protected void setUp() throws Exception {
super.setUp();
dao = (IInfoObjectDAO) factory.getBean("infoObjectDAO");
}
protected InfoObject getInfoObject()
{
InfoObject info = new InfoObject();
info.setTitle("Test 1 Title");
info.setContent("Test 1 content");
return info;
}
protected void tearDown() throws Exception {
super.tearDown();
dao = null;
}
public void testGetInfoObjectInvalid() throws Exception {
try
{
InfoObject infoObject = dao.getInfoObjectById(new Long(1000));
fail("object found in database, failing test...");
}
catch(DataAccessException d)
{
assertTrue(d != null);
}
}
public void testAddAndRemoveInfoObject() throws Exception {
InfoObject infoObject = getInfoObject();
dao.saveInfoObject(infoObject);
assertNotNull(infoObject.getInfoId());
Long iid = infoObject.getInfoId();
dao.removeInfoObject(iid);
try
{
infoObject = dao.getInfoObjectById(iid);
fail("delete object found in database, failing test...");
}
catch(DataAccessException d)
{
assertTrue(d != null);
}
}
public void testUpdateInfoObject() throws Exception {
InfoObject infoObject = getInfoObject();
dao.saveInfoObject(infoObject);
infoObject = dao.getInfoObjectById(infoObject.getInfoId());
log.info(infoObject);
infoObject.setTitle("test update Info Title");
dao.saveInfoObject(infoObject);
assertEquals(infoObject.getTitle(), "test update Info Title");
dao.removeInfoObject(infoObject.getInfoId());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -