Data types

Most of the data types are self explanatory and are adapted to the database in use. Refer to the database documentation for its data types specifics.

The following sections document data types within dbUnit.

  1. BigInteger
  2. BinaryStream
  3. Bit
  4. Blob
  5. Boolean
  6. Bytes
  7. Clob
  8. Date
  9. Double
  10. Float
  11. Integer
  12. Long
  13. Number
  14. NumberTolerant
  15. String
  16. StringIgnoreCase
  17. Time
  18. Timestamp
  19. UuidAwareBytes

Blob

Blobs contain binary data. DbUnit, however, processes data with XML or CSV files containing textual data sets, not binary. To push binary data into a database blob from dbUnit data set files, use the following syntax in a data set field:

... field_name="[TEXT|BASE64|FILE|URL <optional argument>] optional text"

The table below shows how to use each of the forms available to load binary data into a blob.

Data Type Description
TEXT Insert text in a blob. By default the encoding used is UTF-8, but optionally any encoding can be provided.

Example with UTF-8 encoding:
<!DOCTYPE dataset SYSTEM "my-dataset.dtd">
<dataset>
    <TABLE_WITHBLOB COL0="[TEXT]This is my text, saved in UTF-8 (default) encoding.  Java: bon café!"
                    COL1="row 0 col 1"
                    COL2="row 0 col 2"/>
</dataset>

Example with ISO-8859-1 encoding:
<!DOCTYPE dataset SYSTEM "my-dataset.dtd">
<dataset>
    <TABLE_WITHBLOB COL0="[TEXT ISO-8859-1]This is my text, saved in ISO-8859-1 encoding.  Java: bon café!"
                    COL1="row 0 col 1"
                    COL2="row 0 col 2"/>
</dataset>
BASE64 Insert binary in a blob using Base64

Example:
<!DOCTYPE dataset SYSTEM "my-dataset.dtd">
<dataset>
    <TABLE_WITHBLOB COL0="[BASE64]VGhpcyBpcyBteSB0ZXh0Lg=="
                    COL1="row 0 col 1"
                    COL2="row 0 col 2"/>
</dataset>
FILE Insert the content of a binary file in a blob.

Example:
<!DOCTYPE dataset SYSTEM "my-dataset.dtd">
<dataset>
    <TABLE_WITHBLOB COL0="[FILE /path/to/file/to/download]Following text here is being ignored."
                    COL1="row 0 col 1"
                    COL2="row 0 col 2"/>
</dataset>
URL Insert the content pointed by a URL in a blob.

Example:
<!DOCTYPE dataset SYSTEM "my-dataset.dtd">
<dataset>
    <TABLE_WITHBLOB COL0="[URL http://path/to/url]Following text here is being ignored."
                    COL1="row 0 col 1"
                    COL2="row 0 col 2"/>
</dataset>