??Spring?н??Dbunit??Dao???м?????????
???????????? ???????[ 2013/12/23 10:37:14 ] ????????
????????????
????????????????DataSourceUtils.getConnection(datasource) ?? ?????????????????????????Dbunit????????Dbunit??????????????????????????????????????????????????С?Spring??TransactionManager?????????????????????浽ThreadLocal?У?DataSourceUtils.getConnection???????????ThreadLocal?л???????
????user001.xml
????Xml????
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<user nick="user001" password="password001" />
</dataset>
|
???????dbunit?????????xml????????????????????????????????壬????Excel?????????
????Dbunit?????????
????IDatabaseConnection
?????????????????????DatabaseConnection ??DatabaseDataSourceConnection ?????????????????????????
????IDataSet
?????????????????????Xml???Excel????????????????????????????????????????????????????????????????????????????????????????????IDatatable???????
??????????updateUser?????У??????QueryDataSet??????????й??????Dataset???????FlatXmlDataSet??Xml????й??????Dataset????????????Dataset?????
QueryDataSet actual = new QueryDataSet(conn);
actual.addTable("user"?? "select * from user where user.nick = 'user001'");
IDataSet expected = new FlatXmlDataSet(new ClassPathResource(
"com/taobao/dbunit/dao/user001_updated.xml").getFile());
Assertion.assertEquals(expected?? actual);
DatabaseOperation
|
????????????????ο??????????????????????????????????DatabaseOperation .INSERT?????? InsertOperation????????execute???????????????????????磺
????IDataSet origen = new FlatXmlDataSet(new ClassPathResource(
????"com/taobao/dbunit/dao/user001.xml").getFile());
????DatabaseOperation.INSERT.execute(conn?? origen);
??????Xml????й???DataSet?????Insert???????????????????????
????Assertion
???????????assertEqual???????????????????????????
???????????Dbunit???????????http://www.dbunit.org/components.html
????PS:???Oracle??????????DatabaseConnection???????scheme??new DatabaseConnection(conn??SCHEMA_NAME ) ??SCHMEA_NAME?????д??
?????????????д???????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11