Annotation Type DbUnitConfig


@Retention(RUNTIME) @Inherited @Documented @Target({METHOD,TYPE}) public @interface DbUnitConfig
Annotation that can be used to customize DBUnit configuration property when the DbUnit connection will be created.

For example:


 @DbUnitConfig(DefaultConfig.class)
  public class TestClass {
    @Rule
    public DbUnitRule rule = new DbUnitRule(connectionFactory);

    @Test
    public void test1() {
    }

    @Test
    @DbUnitDataSet("/dataset/xml/table1.xml")
    public void test2() {
    }

    public static class DefaultConfig implements DbUnitConfigInterceptor {
      @Override
      public void applyConfiguration(DatabaseConfig config) {
        config.setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, true);
      }
    }
  }

See Also:
  • DatabaseConfig
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Implementation of IDataTypeFactory that should not be used publicly and where all methods will throw UnsupportedOperationException.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Enable or disable empty fields in dataset.
    boolean
    Enable or disable usage of JDBC batched statement by DbUnit, default is false.
    int
    Integer object giving the size of batch updates.
    boolean
    Enable or disable case sensitive table names.
    Class<? extends org.dbunit.dataset.datatype.IDataTypeFactory>
    Used to configure the DataType factory.
    boolean
    Enable or disable the warning message displayed when DbUnit encounter an unsupported data type.
    int
    Integer object giving the statement fetch size for loading data into a result set table.
    List of foreign key manager that can be used to: Disable foreign keys before setup/teardown operations. Re-enable foreign keys after setup/teardown operations.
    Class<? extends org.dbunit.database.IMetadataHandler>
    Used to configure the handler used to control database metadata related methods.
    boolean
    Enable or disable multiple schemas support.
    Schema to use with DBUnit Connection.
    The interceptor class that will be instantiated and executed before applying DbUnit dataset.
  • Element Details

    • schema

      String schema
      Schema to use with DBUnit Connection.
      Returns:
      Schema.
      Default:
      ""
    • fkManagers

      Class<? extends JdbcForeignKeyManager>[] fkManagers
      List of foreign key manager that can be used to:
      • Disable foreign keys before setup/teardown operations.
      • Re-enable foreign keys after setup/teardown operations.
      Returns:
      Array of foreign key managers, each class must have an empty constructor to be initialized.
      See Also:
      Default:
      {}
    • value

      Class<? extends DbUnitConfigInterceptor>[] value
      The interceptor class that will be instantiated and executed before applying DbUnit dataset.
      Returns:
      The interceptor class.
      Default:
      {}
    • caseSensitiveTableNames

      boolean caseSensitiveTableNames
      Enable or disable case sensitive table names. If enabled, Dbunit handles all table names in a case sensitive way, default is false.
      Returns:
      Feature activation flag.
      See Also:
      Default:
      false
    • qualifiedTableNames

      boolean qualifiedTableNames
      Enable or disable multiple schemas support. If enabled, Dbunit access tables with names fully qualified by schema using this format: "SCHEMA.TABLE".
      Returns:
      Feature activation flag.
      See Also:
      Default:
      false
    • batchedStatements

      boolean batchedStatements
      Enable or disable usage of JDBC batched statement by DbUnit, default is false.
      Returns:
      Feature activation flag.
      See Also:
      Default:
      false
    • allowEmptyFields

      boolean allowEmptyFields
      Enable or disable empty fields in dataset.
      Returns:
      Feature activation flag.
      See Also:
      Default:
      false
    • datatypeWarning

      boolean datatypeWarning
      Enable or disable the warning message displayed when DbUnit encounter an unsupported data type.
      Returns:
      Feature activation flag.
      See Also:
      Default:
      true
    • fetchSize

      int fetchSize
      Integer object giving the statement fetch size for loading data into a result set table.
      Returns:
      The fetch size.
      See Also:
      Default:
      100
    • batchSize

      int batchSize
      Integer object giving the size of batch updates.
      Returns:
      The batch size.
      See Also:
      Default:
      100
    • datatypeFactory

      Class<? extends org.dbunit.dataset.datatype.IDataTypeFactory> datatypeFactory
      Used to configure the DataType factory. You can replace the default factory to add support for non-standard database vendor data types. The following factories are currently available:
      • org.dbunit.ext.db2.Db2DataTypeFactory
      • org.dbunit.ext.h2.H2DataTypeFactory
      • org.dbunit.ext.hsqldb.HsqldbDataTypeFactory
      • org.dbunit.ext.mckoi.MckoiDataTypeFactory
      • org.dbunit.ext.mssql.MsSqlDataTypeFactory
      • org.dbunit.ext.mysql.MySqlDataTypeFactory
      • org.dbunit.ext.oracle.OracleDataTypeFactory
      • org.dbunit.ext.oracle.Oracle10DataTypeFactory
      • org.dbunit.ext.postgresql.PostgresqlDataTypeFactory
      • org.dbunit.ext.netezza.NetezzaDataTypeFactory
      Note that the IDataTypeFactory specified here must have a no-args constructor.
      Returns:
      The datatype factory.
      Default:
      com.github.mjeanroy.dbunit.core.annotations.DbUnitConfig.AutoDetectDataTypeFactory.class
    • metadataHandler

      Class<? extends org.dbunit.database.IMetadataHandler> metadataHandler
      Used to configure the handler used to control database metadata related methods. The following RDBMS specific handlers are currently available:
      • org.dbunit.ext.db2.Db2MetadataHandler
      • org.dbunit.ext.mysql.MySqlMetadataHandler
      • org.dbunit.ext.netezza.NetezzaMetadataHandler
      For all others the default handler should do the job: DefaultMetadataHandler. Note that the IMetadataHandler specified here must have a no-args constructor.
      Returns:
      The metadata handler implementation.
      Default:
      org.dbunit.database.DefaultMetadataHandler.class