Package org.dbunit.database

Examples of org.dbunit.database.DatabaseDataSourceConnection


  @Autowired
  private DataSource dataSource;

  @BeforeStory
  public void deleteAllData() throws SQLException, DatabaseUnitException {
    DatabaseDataSourceConnection dbConn = new DatabaseDataSourceConnection(dataSource);
    IDataSet dataSet = dbConn.createDataSet(new String[] { "ORGANIZATION", "APPLICATION_USER" });
    DatabaseOperation.DELETE_ALL.execute(dbConn, dataSet);
  }
View Full Code Here


        String dbUrl="-unknown-" ;
        Connection jdbcConnection = null;
        Statement statement = null;
        try {
            InputStreamProvider streamProvider = getInputStreamProvider(state.url(), state.storage(), method);
            IDatabaseConnection connection = new DatabaseDataSourceConnection(new InitialContext(),
                "java:jboss/datasources/RHQDS");
            jdbcConnection = connection.getConnection();
            dbUrl = jdbcConnection.getMetaData().getURL();
            System.out.println("Using database at " + dbUrl);
            System.out.flush();

            setDatabaseType(connection);
View Full Code Here

        }

        Connection jdbcConnection=null;
        Statement statement=null;
        try {
            IDatabaseConnection connection = new DatabaseDataSourceConnection(new InitialContext(),
                "java:jboss/datasources/RHQDS");
            jdbcConnection = connection.getConnection();
            statement = jdbcConnection.createStatement();
            statement.execute("DROP TABLE RHQ_SUBJECT CASCADE");
        } catch (Exception e) {
            System.err.println("== drop subject table failed: " + e.getMessage());
        } finally {
View Full Code Here

     * @throws Exception
     */
    @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());
View Full Code Here

     * @throws Exception
     */
    @Before
    public final void onSetup() throws Exception {
        log.debug("onSetup(): creating dbunit connection.");
        conn = new DatabaseDataSourceConnection(dataSource);
    }
View Full Code Here

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

        try {
            final IDataSet dataSet = loadDataSet(source);
            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

    this.dataSource = dataSource;
  }

  public DatabaseDataSourceConnection getObject() throws Exception {
    Assert.notNull(this.dataSource, "The dataSource is required");
    DatabaseDataSourceConnection dataSourceConntection = new DatabaseDataSourceConnection(
        makeTransactionAware(this.dataSource), this.schema, this.username, this.password);
    if (this.databaseConfig != null) {
      this.databaseConfig.apply(dataSourceConntection.getConfig());
    }
    return dataSourceConntection;
  }
View Full Code Here

  public void shouldCreateDatabaseDataSourceConnection() throws Exception {
    DataSource dataSource = mock(DataSource.class);
    Connection connection = mock(Connection.class);
    given(dataSource.getConnection()).willReturn(connection);
    this.factoryBean.setDataSource(dataSource);
    DatabaseDataSourceConnection bean = this.factoryBean.getObject();
    assertNotNull(bean);
    bean.getConnection().createStatement();
    verify(dataSource).getConnection();
  }
View Full Code Here

  public void shouldAcceptUsernameAndPassword() throws Exception {
    DataSource dataSource = mock(DataSource.class);
    this.factoryBean.setDataSource(dataSource);
    this.factoryBean.setUsername("username");
    this.factoryBean.setPassword("password");
    DatabaseDataSourceConnection bean = this.factoryBean.getObject();
    assertNotNull(bean);
    bean.getConnection();
    verify(dataSource).getConnection("username", "password");
  }
View Full Code Here

  @Test
  public void shouldSupportSchema() throws Exception {
    DataSource dataSource = mock(DataSource.class);
    this.factoryBean.setDataSource(dataSource);
    this.factoryBean.setSchema("schema");
    DatabaseDataSourceConnection bean = this.factoryBean.getObject();
    assertEquals("schema", bean.getSchema());
  }
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.