2

I have a clob column in my table. How do I represent it in the dbunit dataset xml, so that I can use it in my integration test?

EmeraldTablet
  • 812
  • 3
  • 12
  • 30

1 Answers1

0

You can do that with ReplacementDataSet

Here is an example:

Table schema:

CREATE TABLE TABLE_CLOB(COLUMN_CLOB  CLOB);

XML DataSet (file 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

troig
  • 7,072
  • 4
  • 37
  • 63