I'm looking forward to integrate dbUnit to a project. The project has Spring and has no ORM. While loading the XML dataSet to the db i'm getting org.dbunit.dataset.NoSuchTableException: XXX_VW "XXX_VW" is a db view. However, I'm able to load the dataset to any table. I've confirmed in db the required view exits and the metadata is similiar.
Below is the code I execute during setup method of my test.
DataSource dc = (MCDataSource) context.getBean("dataSource");
databaseTester = new DataSourceDatabaseTester(dc, dc.getUsername());
DatabaseConfig config = databaseTester.getConnection().getConfig();
config.setProperty(DatabaseConfig.PROPERTY_TABLE_TYPE, new String[]{"TABLE", "VIEW"});
databaseTester.setDataSet(this.getDataSet());
databaseTester.setTearDownOperation(DatabaseOperation.DELETE_ALL);
databaseTester.onSetup();
Any idea what could be the issue ?
Instead implement and setOperationListener and do setProperty during lifecycle methods of OperationListener.
databaseTester.setOperationListener(new IOperationListener() {
@Override
public void operationTearDownFinished(IDatabaseConnection connection) {
// TODO Auto-generated method stub
}
@Override
public void operationSetUpFinished(IDatabaseConnection connection) {
// TODO Auto-generated method stub
}
@Override
public void connectionRetrieved(IDatabaseConnection connection) {
DatabaseConfig config = connection.getConfig();
config.setProperty(DatabaseConfig.PROPERTY_TABLE_TYPE, new String[]{"TABLE", "VIEW"});
databaseTester.setDataSet(this.getDataSet());
databaseTester.setTearDownOperation(DatabaseOperation.DELETE_ALL);
databaseTester.onSetup();