Package org.dbunit.database

Examples of org.dbunit.database.DatabaseConfig


  }

  public static DatabaseConnection getDatabaseConnection(Connection connection, String schema, DatabaseConnectionConfigurer databaseConnectionConfigurer) throws DatabaseUnitException {

    DatabaseConnection databaseConnection = StringUtils.hasLength(schema) ? new DatabaseConnection(connection, schema) : new DatabaseConnection(connection);
    DatabaseConfig databaseConfig = databaseConnection.getConfig();
    databaseConnectionConfigurer.configure(databaseConfig);

    return databaseConnection;
  }
View Full Code Here


*/
class HsqldbConfig implements VendorConfig {

  @Override
  public void configure(IDatabaseConnection connection) {
    DatabaseConfig config = connection.getConfig();

    config.setProperty(DBUnit.DATATYPE_FACTORY, new HsqldbDataTypeFactory());

    config.setProperty(DBUnit.QUALIFIED_TABLE_NAMES, true);
  }
View Full Code Here

   }

   private void configure()
   {
      final DatabaseConnection databaseConnection = databaseConnectionProducer.get();
      final DatabaseConfig dbUnitConfig = databaseConnection.getConfig();

      final Map<String, Object> properties = new DBUnitConfigurationPropertyMapper().map(dbUnitConfigurationInstance.get());
      for (Entry<String, Object> property : properties.entrySet())
      {
         dbUnitConfig.setProperty(property.getKey(), property.getValue());
      }
   }
View Full Code Here

    this.catalogs = catalogs;
  }

  @Override
  public void configure(IDatabaseConnection connection) {
    DatabaseConfig config = connection.getConfig();

    config.setProperty(DBUnit.DATATYPE_FACTORY, new MySqlDataTypeFactory());

    config.setProperty(DBUnit.ESCAPE_PATTERN, "`?`");

    config.setProperty(DBUnit.METADATA_HANDLER, new MySqlMetadataHandler(catalogs));

    config.setProperty(DBUnit.QUALIFIED_TABLE_NAMES, true);
  }
View Full Code Here

    // connection (+ schema à utiliser éventuellement)
       
        IDatabaseConnection databaseConnection = new DatabaseConnection( jdbcConnection );
       
      DatabaseConfig config = databaseConnection.getConfig();
     
      config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqlDataTypeFactory());
      
       
      return databaseConnection;  
        
    //return new DatabaseConnection(jdbcConnection);
View Full Code Here

    @Before
    public final void onSetup() throws Exception {
        log.debug("onSetup(): creating dbunit connection.");
        conn = new DatabaseDataSourceConnection(dataSource);

        DatabaseConfig config = conn.getConfig();


       config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
        // set auto commit to false to aviod the data to live over the test suite
        conn.getConnection().setAutoCommit(false);
    }
View Full Code Here

    JdbcMetaDataExtractor extractor = new JdbcMetaDataExtractor(jdbcConnection);
    String userName = extractor.getUserName();
   
    try {
      IDatabaseConnection dbUnitConn = new OracleConnection(jdbcConnection, userName);
      DatabaseConfig config = dbUnitConn.getConfig();
      // oracle 10g
      config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new Oracle10DataTypeFactory());
      // receycle bin (skip oracle 10g recycle bin system tables if enabled)
      config.setProperty(DatabaseConfig.FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES, Boolean.TRUE);
 
      return dbUnitConn;
    } catch (DatabaseUnitException e) {
      throw new IllegalStateException(
          "It's not possible to create a Oracle DbUnit connection: "
View Full Code Here

    private IDatabaseConnection getDBUnitConnection(Connection c)
            throws DatabaseUnitException
            {
        IDatabaseConnection conn = new DatabaseConnection(c);
        DatabaseConfig config = conn.getConfig();
        config.setFeature("http://www.dbunit.org/features/qualifiedTableNames",
                true);
        config.setProperty("http://www.dbunit.org/properties/tableType",
                TABLE_TYPES);
        return conn;
    }
View Full Code Here

        File datasetFile = new File(dataSetXML);
        if (datasetFile.exists()) {
            DataSource ds = jdbcTemplate.getDataSource();
            Connection con = DataSourceUtils.getConnection(ds);
            IDatabaseConnection dbUnitCon = new DatabaseConnection(con);
            DatabaseConfig config = dbUnitCon.getConfig();
            config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
            IDataSet dataSet = new FlatXmlDataSetBuilder().build(datasetFile);
            databaseOperation.execute(dbUnitCon, dataSet);
            DataSourceUtils.releaseConnection(con, ds);
        } else {
            System.out.println("No initial test data loaded.");
View Full Code Here

         final DataSource dataSource = dataSourceInstance.get();
         final String schema = dbUnitConfigurationInstance.get().getSchema();
         final DatabaseConnection databaseConnection = createDatabaseConnection(dataSource, schema);
         databaseConnectionProducer.set(databaseConnection);

         final DatabaseConfig dbUnitConfig = databaseConnection.getConfig();
         dbUnitConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new DefaultDataTypeFactory());

         final Map<String, Object> properties = new DBUnitConfigurationPropertyMapper().map(dbUnitConfigurationInstance.get());
         for (Entry<String, Object> property : properties.entrySet())
         {
            dbUnitConfig.setProperty(property.getKey(), property.getValue());
         }
      } catch (Exception e)
      {
         throw new DBUnitInitializationException("Unable to initialize database connection for DBUnit module.", e);
      }
View Full Code Here

TOP

Related Classes of org.dbunit.database.DatabaseConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.