DbUnit - Warning: AbstractTableMetaData

Viewed 15603

I am using DbUnit in the latest version 2.4.8 and I get many warnings in my Unit tests with this message:

WARN : org.dbunit.dataset.AbstractTableMetaData - 
Potential problem found: The configured data type factory 
    'class org.dbunit.dataset.datatype.DefaultDataTypeFactory' 
     might cause problems with the current database 'MySQL' (e.g. some datatypes may 
     not be supported properly). In rare cases you might see this message because the 
     list of supported database products is incomplete (list=[derby]). If so please 
     request a java-class update via the forums.If you are using your own 
     IDataTypeFactory extending DefaultDataTypeFactory, ensure that you override 
     getValidDbProducts() to specify the supported database products.

So I thought I add this (I use a MySQL database):

protected void setUpDatabaseConfig(DatabaseConfig config) {
    config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
}

But this does not help to avoid these warnings. What's wrong here?

Thank you in advance & Best Regards Tim.

6 Answers

I am using Dbunit version 2.7.0. In my case, just setting the data type factory property in the @Test doesn't suffice. The warning continues when calling dbunit JdbcDatabaseTester.onsetup() method.

I solved the problem implementing a MyJdbcDatabaseTester that extends JdbdDatabaseTester, and overriding the method getConnection(), configuring the datatype factory property:

public class MyJdbcDatabaseTester extends JdbcDatabaseTester {

public MyJdbcDatabaseTester(String driverClass, String connectionUrl, String username,
                            String password )
        throws ClassNotFoundException {
    super( driverClass, connectionUrl, username, password );
}

@Override
public IDatabaseConnection getConnection() throws Exception {
    IDatabaseConnection result = super.getConnection();
    DatabaseConfig dbConfig = result.getConfig();
    //to supress warnings when accesing to database
    dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
    return result;
}

}

Then I use MyJcbdDatabaseTester instead of JdbcDatabaseTester in my tests

Related