1. ibatis中的单元测试
1.1 对映射层进行单元测试
1. 测试用数据库实例
http://hsqldb.sourceforge.net/
2. 数据库脚本
3. ibatis配置文件
4. ibatis SqlMapClient单元测试
public class PersonMapTest extends TestCase {
private SqlMapClient sqlMapClient;
public void setup() {
sqlMapClient = SqlMapClientBuilder.build("maps/TestSqlMapConfig.xml");
runSqlScript("scripts/drop-person-schema.sql");
runSqlScript("scripts/create-person-schema.sql");
runSqlScript("scripts/create-person-test-data.sql");
}
public void testShouldGetPersonWithIdOfOne() {
Person person = (Person) sqlMapClient.queryForObject("getPerson", new Integer(1));
assertNotNull("Expected to find a person.", person);
assertEquals("Expected person ID to be 1.", new Integer(1), person.getId());
}
}