2
我的表中有一個clob列。如何在dbunit數據集xml中表示它,以便我可以在集成測試中使用它?Unitils dbunit數據集中的CLOB表示
我的表中有一個clob列。如何在dbunit數據集xml中表示它,以便我可以在集成測試中使用它?Unitils dbunit數據集中的CLOB表示
你可以做到這一點與ReplacementDataSet
下面是一個例子:
表模式:
CREATE TABLE TABLE_CLOB(COLUMN_CLOB CLOB);
XML數據集(文件dataSet.xml):
<dataset>
<table name="TABLE_CLOB">
<column>COLUMN_CLOB</column>
<row>
<value>CLOB_1</value>
</row>
</table>
</dataset>
在你的測試方法:
// Initialize one IDataSet from your dataset xml
InputStream expIn = this.getClass().getResourceAsStream("dataSet.xml");
IDataSet xmlDataSet = new XmlDataSet(expIn);
// Initialize one ReplacementDataSet with previous xmlDataSet
ReplacementDataSet dataSet = new ReplacementDataSet(xmlDataSet);
// Make the replacements
dataSet.addReplacementObject("CLOB_1", YourClobObject);
// Insert the dataSet into the databaseTest
DatabaseOperation.CLEAN_INSERT.execute(databaseTester.getConnection(), dataSet);
希望它有幫助