简体   繁体   中英

Unitils / DBunit / Oracle - how to insert dataset in oracle views?

It seems to be a simple question. I have some unitils tests in a spring application. The database contains some oracle views and i just want to insert dataset into these views. I know that it is possible to set options to DBunit (Table Type properties). But i find nothing for unitils.

Is there some unitils properties for inserting dataset to views?

Thank you for help

Ok i think i find a way to configure unitils. But that needs some java code. I have tested this solution, it seems to work.

First i find some properties in unitils (unitils.properties):

unitils.module.dbunit.className=org.unitils.dbunit.DbUnitModule
unitils.module.dbunit.runAfter=
unitils.module.dbunit.enabled=true

So it seems to be possible to override DBUnitModule like this


public class DbUnitModule extends org.unitils.dbunit.DbUnitModule implements Module {
    /*
     * (non-Javadoc)
     * 
     * @see org.unitils.dbunit.DbUnitModule#getDbUnitDatabaseConnection(java.lang.String)
     */
    @Override
    public DbUnitDatabaseConnection getDbUnitDatabaseConnection(final String schemaName) {
        DbUnitDatabaseConnection dbConnection = super.getDbUnitDatabaseConnection(schemaName);
        dbConnection.getConfig().setProperty("http://www.dbunit.org/properties/tableType", new String[] { "VIEW", "TABLE" });
        return dbConnection;
    }
}

And then modify the configuration in unitils.properties.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM