When querying tables using aliases, DBUnit does not pick up column aliases.
Having found this StackOverflow post
http://stackoverflow.com/questions/15159085/dbunit-ignores-column-aliases-when-creating-dataset-from-query
The underlying cause seems to be a change in the MySQL connector required by a change in the JDBC spec.
Have attached example test case demonstrating the failure.
Have attached a patch against the current trunk.
Changed to use getLabel() rather than getName() as per the suggestion in the linked MySql discussion attached to the SO post.
With the patch included, existing unit tests passed ok, but am having trouble getting the integration tests running.
Getting stacktrace:
org.dbunit.dataset.NoSuchTableException: EMPTY_MULTITYPE_TABLE
at org.dbunit.ant.DbUnitTask.execute(DbUnitTask.java:385)
at org.apache.tools.ant.Task.perform(Task.java:341)
at org.apache.tools.ant.Target.execute(Target.java:309)
at org.apache.tools.ant.Target.performTasks(Target.java:336)
at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
at org.apache.tools.ant.BuildFileTest.executeTarget(BuildFileTest.java:276)
at org.dbunit.ant.DbUnitTaskIT.getFirstTargetTask(DbUnitTaskIT.java:600)
at org.dbunit.ant.DbUnitTaskIT.getStepFromTarget(DbUnitTaskIT.java:588)
at org.dbunit.ant.DbUnitTaskIT.getFirstStepFromTarget(DbUnitTaskIT.java:583)
at org.dbunit.ant.DbUnitTaskIT.testExportQueryMixed(DbUnitTaskIT.java:384)
Caused by: org.dbunit.dataset.NoSuchTableException: EMPTY_MULTITYPE_TABLE
at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:288)
at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109)
at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
at org.dbunit.ant.Operation.execute(Operation.java:192)
at org.dbunit.ant.DbUnitTask.execute(DbUnitTask.java:380)
but the tables seem to exist in my test DB.
Hi, Thanks for the patch. I'm wondering a few things on the test failures:
Which integration tests are failing for your build?
How are you running the build/tests? (what is the command line you ran)
Which profiles pass/fail?
Hi jeff,
erm... A lot of them!
I'm running:
mvn clean verify -Pmysql,oracle-default
I've set up the mysql dbunit database based on the instructions.
I've included an example output (heavily snipped to give you a flavour) at the bottom of my reply (it's pretty large!)
However, I haven't performed an svn update since I did the original checkout, which was from trunk/ so it's possible I just got it in a bad state. I also had to comment out some unit tests under TimestampDataTypeTest to get the build further.
Here's my current svn info:
I'll perform a revert/update and re-test and let you know how I get on.
Last edit: Tim 2014-06-12
First, please switch to the git repo; svn is no longer used. Release 2.5.0 is from git, not svn, and those changes are not in svn. Please let me know how the build works with your changes in the git codeline.
Does building with the "offical" profile work for you or still fail?
mvn clean install -Pofficial
Also, only run one profile at a time.
Hi sorry it's taken a while to get back onto this.
Having checked out a fresh copy, I'm getting Unit test failures:
Output:
I haven't performed any further analysis so far.
Thanks
I recently encountered that too, and it is an issue with Java 7. Java 6 did not have that problem.
Please pull latest and see if the tests all pass for you... they do for me.