I'm trying to fix the test suite on an project which I've inherited from another programmer for some java database code. The project itself is using hibernate and MySQL for the DB stuff, but for the purposes of the test cases dbunit is being used. I can correctly load and initialize hibernate's session factory, but I keep getting exceptions when I try to run my tests in Eclipse, namely "org.dbunit.dataset.NoSuchTableException: mytablename".
I know that all the files are in the right place, and that the actual XML file I'm passing into dbunit is ok (I'm using the FlatXmlDataSet type). My setUp() method in the database test case base class looks like this:
@Override
protected void setUp() throws Exception {
super.setUp();
IDataSet dataSet = new FlatXmlDataSet(new File(mDataFile));
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
IDatabaseConnection connection = new DatabaseConnection(session.connection());
DatabaseConfig config = connection.getConfig();
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
session.getTransaction().commit();
}
Right after the CLEAN_INSERT database operation, the exception gets thrown complaining about the last table in my XML file, regardless of which table this is. I have verified the DTD and XML schema by hand and with Eclipse, even going to the point of making sure the ordering of the tables in the two files matched. I'd rather not paste those files in here (as it would involve a lot of search-replacing), but trust me that I've looked through dbunit examples and made sure that the syntax matches.
Any ideas on what could be wrong? I've been googling for hours and can't come up with anything useful.
Edit: One thing I forgot to mention, is that when I place a breakpoint at the line which throws, I can look through dataSet's structure and see that all of my tables are actually in there, along with all of the test data. So at least that part seems to be working correctly.
@Bogdan: Hrm... good idea. I'll try loading the data with a regular INSERT. @sleske: Also a good suggestion. Thanks for the hints; hopefully this will set me on the right path to fixing this problem.