简体   繁体   English

Unitils dbunit数据集中的CLOB表示形式

[英]CLOB representation in Unitils dbunit dataset

I have a clob column in my table. 我的桌子上有一个Clob列。 How do I represent it in the dbunit dataset xml, so that I can use it in my integration test? 如何在dbunit数据集xml中表示它,以便可以在集成测试中使用它?

You can do that with ReplacementDataSet 您可以使用ReplacementDataSet做到这一点

Here is an example: 这是一个例子:

Table schema: 表架构:

CREATE TABLE TABLE_CLOB(COLUMN_CLOB  CLOB);

XML DataSet (file dataSet.xml): XML数据集(文件dataSet.xml):

<dataset>
   <table name="TABLE_CLOB">
      <column>COLUMN_CLOB</column>
      <row>
         <value>CLOB_1</value>
      </row>
   </table>
</dataset>

In your test method: 在您的测试方法中:

// 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);

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM