Package org.dbunit.database

Examples of org.dbunit.database.DatabaseConfig


            databaseConnection = new DatabaseConnection(dataSource.getConnection());
         }

         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


    }

    private void openConnection() throws Exception {
        connection = new DatabaseConnection(datasource.getConnection());
        if (database == Database.hsql) {
            DatabaseConfig config = connection.getConfig();
            config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
                    new HsqldbDataTypeFactory());
        }
    }
View Full Code Here

    @BeforeClass
    public static void initConnection() throws Exception {
        if (null == connection) {
            IDatabaseTester databaseTester = new PropertiesBasedJdbcDatabaseTester();
            connection = databaseTester.getConnection();
            DatabaseConfig dbConfig = connection.getConfig();
            dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
        }
    }
View Full Code Here

    @BeforeClass
    public static void initConnection() throws Exception {
        if (null == connection) {
            IDatabaseTester databaseTester = new PropertiesBasedJdbcDatabaseTester();
            connection = databaseTester.getConnection();
            DatabaseConfig dbConfig = connection.getConfig();
            dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
            schemaName = System.getProperty("schemaName");
        }
    }
View Full Code Here

      props.load(in);
      System.out.print("properties loaded...");

      Connection jdbcConnection = DriverManager.getConnection(props.getProperty("db.url"), props.getProperty("db.username"), props.getProperty("db.password"));
      IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
      DatabaseConfig config = connection.getConfig();
      config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
      System.out.print("mysql connection set...");

      dataSet = new QueryDataSet(connection);
      for (String table : tables) {
        dataSet.addTable(table);
View Full Code Here

  @Override
  protected IDatabaseConnection getConnection() throws Exception {
    JdbcDatabaseTester dbTester = new JdbcDatabaseTester(DRIVER, URL, USER, PASSWORD);
    dbTester.setDataSet(getDataSet());
    IDatabaseConnection connection = dbTester.getConnection();
    DatabaseConfig memConfig = connection.getConfig();
    memConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
    return connection;
  }
View Full Code Here

*/
public static DatabaseConnection getDatabaseConnection(Connection connection) {
  DatabaseConnection databaseConnection = null;
  try {
    databaseConnection= new DatabaseConnection(connection);
    DatabaseConfig config = databaseConnection.getConfig();
    //数据库为mysql
    if ("MySQL".equalsIgnoreCase(connection.getMetaData()
        .getDatabaseProductName())) {
      config.setProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER,
          new MySqlMetadataHandler());
      config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
          new MySqlDataTypeFactory());
    } //else if ("Oracle".equalsIgnoreCase(connection.getMetaData()
//        .getDatabaseProductName())) {
//      config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
//          new Oracle10DataTypeFactory());
View Full Code Here

        userTransaction.begin();
        try {
            if (connection == null) {
                connection = new DatabaseConnection(datasource.getConnection());
                if (database == Database.hsql) {
                    DatabaseConfig config = connection.getConfig();
                    config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
                            new HsqldbDataTypeFactory());
                }
                em.flush();
            }
        } finally {
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

    Connection connection = null;
    // JH_TODO: use transactional property
    try {
      connection = DataSourceUtils.getConnection(dataSource);
      IDatabaseConnection dbUnitConnection = new DatabaseConnection(connection, schema);
      DatabaseConfig config = dbUnitConnection.getConfig();
      for (Map.Entry<String, Object> property : databaseConfigProperties.entrySet()) {
        config.setProperty(property.getKey(), property.getValue());
      }
      for (Map.Entry<String, Boolean> feature : databaseConfigFeatures.entrySet()) {
        config.setFeature(feature.getKey(), feature.getValue());
      }
      callback.doInDbUnitConnection(dbUnitConnection);
    }
    catch (DatabaseUnitException ex) {
      throw new DbUnitTemplateException(ex);
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.