The dbunit compatibility tests, test this library against dbunit versions
A module that provides support for data set migration.
The stream module provides a lot of utility classes for dbunit stream handling.
It also contains the stream.commands
package that provides a high level
api for common dbunit tasks.
Connection sourceConnection = ...; // java.sql.Connection
DatabaseConnection databaseConnection = new DatabaseConnection(sourceConnection);
DatabaseDataSet databaseDataSet = new DatabaseDataSet(databaseConnection, false);
DataSetCommand migrateCommand = new DataSetCommand(databaseDataSet);
migrateCommand.setTables("actor", "film_actor", "film");
migrateCommand.setTableOrder(new DatabaseTableOrder(databaseConnection));
migrateCommand.setResultDecorator(ds -> new ConsistentDatabaseDataSet(databaseConnection, ds));
migrateCommand.setCsvConsumer("target/export/csv");
migrateCommand.exec();
For details take a look at lis-dbunit-dataset
The TableBrowser
can be used to extract a dataset based on a kind of extract description.
This description can be build using a domain-specific language. E.g.
The ConsistentDataSetLoader
is another option to load consistent datasets. You can
pass it an SQL-Select statement.
Provides extensions for dealing with dbunit tables.
-
MergedTable: Merged two or more tables by the primary key definition so that the result table's rows are distinct.
-
TableList: A list of tables that can be packed to make the tables unique using MergedTables.
-
CellRowFilter: Filters rows based on a column predicate.
-
ColumnList: Provides filter and query methods for a list of columns.
-
ColumnPredicates: Convenience class that provides reusable predicates that can be applied to columns.
-
TableUtil: Convenience methods for table related queries.
ITable table = ...; TableUtil tableUtil = new TableUtil(table); Row row = tableUtil.getRowById(321); for (Object cellValua : row) { System.out.println(cellValue) }
Provides Java Beans support for IDataSets which allows you to define a data set from a collection of beans. Since Java Beans are based on Java classes you can use refactoring tools to reflect database schema changes.
List<BeanList<?>> beanLists = new ArrayList<>();
BeanList<EmployeeBean> employeeBeans = new BeanList<>(EmployeeBean.class, asList(EmployeeBean.king(), EmployeeBean.blake()));
beanLists.add(employeeBeans);
BeanList<DepartmentBean> departmentBeans = new BeanList<>(DepartmentBean.class, asList(DepartmentBean.accounting(), DepartmentBean.sales(), DepartmentBean.research()));
beanLists.add(departmentBeans);
beanDataSet = new BeanDataSet(beanLists);
The ITableMetaData
for bean based data sets is determined using a BeanTableMetaDataProvider
. The DefaultBeanTableMetaDataProvider
can be customized by setting a PropertyConversion
. The PropertyConversion
is responsible for converting bean properties to
database types and vice versa. The DefaultPropertyConversion
uses the DefaultDataTypeRegistry
and the DefaultPropertyTypeRegistry
to convert property values.
Provides support for generating sql insert scripts from a IDataSet.
// Instantiate a SqlDialect
// Either from
// - com.link-intersystems.commons:lis-commons-sql
// or
// - com.link-intersystems.commons:lis-commons-sql-hibernate
SqlDialect sqlDialect = new DefaultSqlDialect();
// Create a SqlStatementWriter that generates the sql script.
Writer writer = ....; // from java.io
SqlStatementWriter sqlStatementWriter = new SqlStatementWriter(sqlDialect, writer);
// Configure the output format if needed
SqlFormatSettings sqlFormatSettings = new SqlFormatSettings();
sqlStatementWriter.setSqlFormatSettings(sqlFormatSettings);
IDataSet dataSet = ...; // A dbunit data set to export.
DataSetProducerAdapter dataSetProducerAdapter = new DataSetProducerAdapter(dataSet);
dataSetProducerAdapter.setConsumer(sqlStatementWriter);
dataSetProducerAdapter.produce();