Open Hellago opened 5 years ago
Sorry for the delay.
The NullPointerException is caused by no connection being available in the test context. From what I see above, you are not using the right bean name:
Could you use the same name in both and retry please?
In the meantime, I will adjust the code to avoid the NPE and log a proper message instead.
My bean "dbUnitDatabaseConnection" is a factory (badly named I agree), not a connection. I had another piece of code specifying the bean "myConnection" :
<bean id="myConnection" class="org.dbunit.database.DatabaseConnection" lazy-init="true">
<constructor-arg name="connection" ref="realConnection" />
</bean>
Messing up with the name gives the following exception at start :
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myConnection2' available
Messing up with the type of the bean gives that error :
java.lang.IllegalArgumentException: Object of class [java.sql.Connection] must be an instance of interface org.dbunit.database.IDatabaseConnection
So I think the cause is somewhere else. Maybe because I handle connections a bit "manually" ?
final QueryDataSet qds = new QueryDataSet(myConnection);
qds.addTable(tableName, sqlQuery);
MyCustomDataSetLoader.save(qds, saveFile);
Hello, First, thanks for your contribution to the community.
I get the following error :
Adding a test
if (testContext.getConnections() != null)
solves the problem, but I guess the cause is somewhere else.I'm using :
Here is my code : dbunit-context.xml :
Test class Java :
If you can't find the cause, can you at least turn the error into a warning ?
Thank you in advance.