From: Bluehazzard <blu...@gm...> - 2018-08-28 19:33:55
|
Hi, i am quite new to Java, Database, Unit testing and JPA, so in quite everything involved here. I try to use DBUnit combined with database-rider (https://github.com/database-rider/database-rider), Hibernate and MySQL. The test database is up and running, Hibernate populates the database with the tables and now i try to run dbunit with a pre created dataset xml file to populate the database. This database has multiple schema, and tables: ---------------------------------- schemaA table1 col_id col_num table2 col_id col_addr schemaB table3 col_id col_usr table4 ... ... ---------------------------------- my dataset.xml file looks like this: ----------------------------------- <?xml version='1.0' encoding='UTF-8'?> <dataset> <!--schemaA Table --> <schemaA.table1 id="21036" col_num="04" /> </dataset> ----------------------------------- I have set the FEATURE_QUALIFIED_TABLE_NAMES to true. Now if i start a test i get the following backtrace: ----------------------------------- [....] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: com.github.database.rider.core.exception.DataBaseSeedingException: Could not initialize dataset: dataset.xml at com.github.database.rider.core.dataset.DataSetExecutorImpl.createDataSet(DataSetExecutorImpl.java:156) at com.github.database.rider.junit5.DBUnitExtension.beforeTestExecution(DBUnitExtension.java:108) ... 80 more Caused by: org.dbunit.dataset.NoSuchTableException: schemaA.table1 at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:305) at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109) at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79) at com.github.database.rider.core.dataset.DataSetExecutorImpl.createDataSet(DataSetExecutorImpl.java:152) ... 81 more [...] ----------------------------------- If i set a breakpoint in DatabaseDataSet.java:301 and inspect the variable "_tableMap" it contains all my tables from the schemaA database. But it searches for the name in variable "tableName" what is "schemaA.table1". Obviously it can not find the table with this name, because the schema is still prefixed. Shouldn't the true table name be used: qualifiedTableName.GetTable()? So that the line DatabaseDataSet.java:301->306 is ------------------------------------ if (!_tableMap.containsTable(qualifiedTableName.GetTable())) { logger.error("Table '{}' not found in tableMap={}", qualifiedTableName.GetTable(), _tableMap); throw new NoSuchTableException(tableName); } ------------------------------------ instead of ------------------------------------ if (!_tableMap.containsTable(tableName)) { logger.error("Table '{}' not found in tableMap={}", tableName, _tableMap); throw new NoSuchTableException(tableName); } ------------------------------------ I hope someone can point out where my error is... thank you and greetings |