Package org.dbunit.database

Examples of org.dbunit.database.DatabaseDataSourceConnection


  public void shouldSupportDatabaseConfigBean() throws Exception {
    DataSource dataSource = mock(DataSource.class);
    this.factoryBean.setDataSource(dataSource);
    DatabaseConfigBean databaseConfig = mock(DatabaseConfigBean.class);
    this.factoryBean.setDatabaseConfig(databaseConfig);
    DatabaseDataSourceConnection bean = this.factoryBean.getObject();
    assertNotNull(bean);
    verify(databaseConfig).apply(bean.getConfig());
  }
View Full Code Here


  @Test
  public void shouldCreateCreateTransactionAwareConnection() throws Exception {
    DataSource dataSource = mock(DataSource.class);
    this.factoryBean.setDataSource(dataSource);
    DatabaseDataSourceConnection dataSourceConnection = this.factoryBean.getObject();
    Connection connection = dataSourceConnection.getConnection();
    assertTrue(connection.toString() + " is not transaction aware",
        connection.toString().startsWith("Transaction-aware proxy"));
  }
View Full Code Here

  @Test
  public void shouldNotWrapCreateTransactionAwareConnection() throws Exception {
    DataSource dataSource = new TransactionAwareDataSourceProxy(mock(DataSource.class));
    this.factoryBean.setDataSource(dataSource);
    DatabaseDataSourceConnection dataSourceConnection = this.factoryBean.getObject();
    Connection connection = dataSourceConnection.getConnection();
    assertTrue(
        connection.toString() + " is not transaction aware",
        connection.toString().startsWith(
            "Transaction-aware proxy for target Connection  from DataSource [Mock for DataSource"));
  }
View Full Code Here

    DataSource dataSource = mock(DataSource.class);
    Connection connection = mock(Connection.class);
    given(dataSource.getConnection()).willReturn(connection);
    this.factoryBean.setDataSource(dataSource);
    this.factoryBean.setTransactionAware(false);
    DatabaseDataSourceConnection dataSourceConnection = this.factoryBean.getObject();
    Connection actual = dataSourceConnection.getConnection();
    assertSame(connection, actual);
  }
View Full Code Here

    assert source != null;

    try {
      final FileInputStream inputStream = new FileInputStream(source);
      final IDataSet dataSet = new XmlDataSet(inputStream);
      final IDatabaseConnection connection = new DatabaseDataSourceConnection(
          database.getDataSource());
      try {
        DatabaseOperation.INSERT.execute(connection, dataSet);
      } finally {
        connection.close();
      }
    } catch (final SQLException exception) {
      logger.logError(ERROR_PROCESSING_SOURCE_FILE, exception,
          source.getPath());
    } catch (final DatabaseUnitException exception) {
View Full Code Here

        assert logger != null;
        assert source != null;

        try {
            final IDataSet dataSet = loadDataSet(source);
            final IDatabaseConnection connection = new DatabaseDataSourceConnection(
                    ((SQLDatabase)database).getDataSource());
            final Boolean qualifiedTableNames = source.getQualifiedTableNames();
            if (qualifiedTableNames != null) {
                final DatabaseConfig config = connection.getConfig();
                config.setProperty(
                        DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES,
                        source.getQualifiedTableNames());
            }
            try {
                DatabaseOperation.INSERT.execute(connection, dataSet);
            } finally {
                connection.close();
            }
        } catch (final SQLException exception) {
            final String message = MessageUtil.getMessage(ERROR_PROCESSING_SOURCE_FILE, source.getSourceFile());
            logger.logError(message, exception);
        } catch (final DatabaseUnitException exception) {
View Full Code Here

TOP

Related Classes of org.dbunit.database.DatabaseDataSourceConnection

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.