Annotation Type 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImplementation ofIDataTypeFactorythat should not be used publicly and where all methods will throwUnsupportedOperationException. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanEnable or disable empty fields in dataset.booleanEnable or disable usage of JDBC batched statement by DbUnit, default isfalse.intInteger object giving the size of batch updates.booleanEnable or disable case sensitive table names.Class<? extends org.dbunit.dataset.datatype.IDataTypeFactory> Used to configure the DataType factory.booleanEnable or disable the warning message displayed when DbUnit encounter an unsupported data type.intInteger object giving the statement fetch size for loading data into a result set table.Class<? extends JdbcForeignKeyManager>[]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.booleanEnable or disable multiple schemas support.Schema to use with DBUnit Connection.Class<? extends DbUnitConfigInterceptor>[]The interceptor class that will be instantiated and executed before applying DbUnit dataset.
-
Element Details
-
schema
-
fkManagers
Class<? extends JdbcForeignKeyManager>[] fkManagersList 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>[] valueThe interceptor class that will be instantiated and executed before applying DbUnit dataset.- Returns:
- The interceptor class.
- Default:
{}
-
caseSensitiveTableNames
boolean caseSensitiveTableNamesEnable or disable case sensitive table names. If enabled, Dbunit handles all table names in a case sensitive way, default isfalse.- Returns:
- Feature activation flag.
- See Also:
- Default:
false
-
qualifiedTableNames
boolean qualifiedTableNamesEnable 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 batchedStatementsEnable or disable usage of JDBC batched statement by DbUnit, default isfalse.- Returns:
- Feature activation flag.
- See Also:
- Default:
false
-
allowEmptyFields
boolean allowEmptyFieldsEnable or disable empty fields in dataset.- Returns:
- Feature activation flag.
- See Also:
- Default:
false
-
datatypeWarning
boolean datatypeWarningEnable or disable the warning message displayed when DbUnit encounter an unsupported data type.- Returns:
- Feature activation flag.
- See Also:
- Default:
true
-
fetchSize
int fetchSizeInteger object giving the statement fetch size for loading data into a result set table.- Returns:
- The fetch size.
- See Also:
- Default:
100
-
batchSize
int batchSizeInteger object giving the size of batch updates.- Returns:
- The batch size.
- See Also:
- Default:
100
-
datatypeFactory
Class<? extends org.dbunit.dataset.datatype.IDataTypeFactory> datatypeFactoryUsed 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.Db2DataTypeFactoryorg.dbunit.ext.h2.H2DataTypeFactoryorg.dbunit.ext.hsqldb.HsqldbDataTypeFactoryorg.dbunit.ext.mckoi.MckoiDataTypeFactoryorg.dbunit.ext.mssql.MsSqlDataTypeFactoryorg.dbunit.ext.mysql.MySqlDataTypeFactoryorg.dbunit.ext.oracle.OracleDataTypeFactoryorg.dbunit.ext.oracle.Oracle10DataTypeFactoryorg.dbunit.ext.postgresql.PostgresqlDataTypeFactoryorg.dbunit.ext.netezza.NetezzaDataTypeFactory
IDataTypeFactoryspecified 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> metadataHandlerUsed to configure the handler used to control database metadata related methods. The following RDBMS specific handlers are currently available:org.dbunit.ext.db2.Db2MetadataHandlerorg.dbunit.ext.mysql.MySqlMetadataHandlerorg.dbunit.ext.netezza.NetezzaMetadataHandler
DefaultMetadataHandler. Note that theIMetadataHandlerspecified here must have a no-args constructor.- Returns:
- The metadata handler implementation.
- Default:
org.dbunit.database.DefaultMetadataHandler.class
-