Search in sources :

Example 1 with HsqldbDataTypeFactory

use of org.dbunit.ext.hsqldb.HsqldbDataTypeFactory in project openmrs-core by openmrs.

the class TestUtil method printOutTableContents.

/**
 * Print the contents of the given tableName to system.out<br>
 * <br>
 * Call this from any {@link BaseContextSensitiveTest} child by:
 * TestUtil.printOutTableContents(getConnection(), "encounter");
 *
 * @param sqlConnection the connection to use
 * @param tableNames the name(s) of the table(s) to print out
 * @throws Exception
 */
public static void printOutTableContents(Connection sqlConnection, String... tableNames) throws Exception {
    for (String tableName : tableNames) {
        System.out.println("The contents of table: " + tableName);
        IDatabaseConnection connection = new DatabaseConnection(sqlConnection);
        DatabaseConfig config = connection.getConfig();
        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
        QueryDataSet outputSet = new QueryDataSet(connection);
        outputSet.addTable(tableName);
        FlatXmlDataSet.write(outputSet, System.out);
    }
}
Also used : HsqldbDataTypeFactory(org.dbunit.ext.hsqldb.HsqldbDataTypeFactory) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DatabaseConnection(org.dbunit.database.DatabaseConnection) QueryDataSet(org.dbunit.database.QueryDataSet) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DatabaseConfig(org.dbunit.database.DatabaseConfig)

Example 2 with HsqldbDataTypeFactory

use of org.dbunit.ext.hsqldb.HsqldbDataTypeFactory in project thingsboard by thingsboard.

the class JpaDbunitTestConfig method databaseConfigBean.

@Bean
public DatabaseConfigBean databaseConfigBean() {
    DatabaseConfigBean databaseConfigBean = new DatabaseConfigBean();
    databaseConfigBean.setDatatypeFactory(new HsqldbDataTypeFactory());
    return databaseConfigBean;
}
Also used : HsqldbDataTypeFactory(org.dbunit.ext.hsqldb.HsqldbDataTypeFactory) DatabaseConfigBean(com.github.springtestdbunit.bean.DatabaseConfigBean) DatabaseConfigBean(com.github.springtestdbunit.bean.DatabaseConfigBean) Bean(org.springframework.context.annotation.Bean) DatabaseDataSourceConnectionFactoryBean(com.github.springtestdbunit.bean.DatabaseDataSourceConnectionFactoryBean)

Aggregations

HsqldbDataTypeFactory (org.dbunit.ext.hsqldb.HsqldbDataTypeFactory)2 DatabaseConfigBean (com.github.springtestdbunit.bean.DatabaseConfigBean)1 DatabaseDataSourceConnectionFactoryBean (com.github.springtestdbunit.bean.DatabaseDataSourceConnectionFactoryBean)1 DatabaseConfig (org.dbunit.database.DatabaseConfig)1 DatabaseConnection (org.dbunit.database.DatabaseConnection)1 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)1 QueryDataSet (org.dbunit.database.QueryDataSet)1 Bean (org.springframework.context.annotation.Bean)1