Closed haocao closed 9 years ago
Is there any response of this quesion?Thanks.
It looks like this is related to #67. I think the warning is raised from AbstractTableMetaData
because the MySql isn't explicitly supported by DefaultDataTypeFactory
. I think if you configure the IDataTypeFactory
as described in #67 the warning will go away.
// com.github.springtestdbunit.DbUnitTestExecutionListener
private void prepareDatabaseConnection(DbUnitTestContextAdapter testContext, String[] connectionBeanNames) throws Exception {
...
if (databaseConnection instanceof DataSource) {
databaseConnection = DatabaseDataSourceConnectionFactoryBean
.newConnection((DataSource) databaseConnection);
}
...
}
First : method prepareDatabaseConnection
is private !
Second : DatabaseDataSourceConnectionFactoryBean.newConnection
is static !
Third : I see no way we can tell spring-dbunit to use an overriden DatabaseDataSourceConnection
.
Correct design-pattern is use to fetch a custom Datasource :
testContext.getApplicationContext().getBean(connectionBeanNames[i]);
if (databaseConnection instanceof DataSource) {
...
}
but the pattern is broken to fetch a custom DatabaseDataSourceConnection
. The same test should be done (look for any existant DatabaseDataSourceConnection.class
bean in testContext), before instanciating the default one by calling DatabaseDataSourceConnectionFactoryBean.newConnection((DataSource) databaseConnection);
.
I don't see how and where spring-dbunit use custom's beans as described in https://github.com/springtestdbunit/spring-test-dbunit/issues/67 (either xml or annotation declarations).
Hi Phillip, Mario. I'm trying to use spring-test-dbunit on most of my projects, it provides a lot of essential features, but it always alerts a warning in my Unit tests with this message:
I checked the source codes(using version 1.2.1), and found the warning might caused by:
DbUnitTestExecutionListener class
So it means that the databaseConnection will be created from
DatabaseDataSourceConnectionFactoryBean.newConnection
, and so finally I foundDatabaseDataSourceConnectionFactoryBean's getObject
method:I think the
dataSourceConntection.getConfig()
can't get any value, as it should be fetched from the spring's beans.So could you help me to take a look at this issue? thanks.