Menu

#253 Make connection properties configurable for DataSourceDatabaseTester

(future)
open
nobody
None
5
2023-01-17
2023-01-17
No

We are using dbUnit to setup and tear down our db data in tests. We are using specific db. And in order to provide proper DATATYPE_FACTORY we have to use the following code:

@BeforeTest
init() {
        DataSourceDatabaseTester databaseTester = new DataSourceDatabaseTester(dataSource);
...
        databaseTester.setOperationListener(new DefaultOperationListener() {
            @Override
            public void connectionRetrieved(IDatabaseConnection connection) {
                connection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
                super.connectionRetrieved(connection);
            }
        });
            databaseTester.onSetup();
}

This code to configure data type factory (hsqldb) is not very handsome. Can you for example allow providing DatabaseConfig into DataSourceDatabaseTester. Or can you detect database type automatically.

Discussion