【问题标题】:CLOB representation in Unitils dbunit datasetUnitils dbunit 数据集中的 CLOB 表示
【发布时间】:2015-04-06 23:20:24
【问题描述】:

我的表中有一个 clob 列。如何在 dbunit 数据集 xml 中表示它,以便在集成测试中使用它?

【问题讨论】:

    标签: integration-testing dbunit unitils


    【解决方案1】:

    你可以用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);
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2015-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多