Package org.dbunit.database

Examples of org.dbunit.database.IDatabaseConnection


  public static void main(String[] args) throws Exception {
    // database connection
    @SuppressWarnings("unused")
    Class driverClass = Class.forName("com.mysql.jdbc.Driver");
    Connection jdbcConnection = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/scrumit2", "root", "bsgroup");
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);

    // partial database export
    //QueryDataSet partialDataSet = new QueryDataSet(connection);
    //partialDataSet.addTable("FOO", "SELECT * FROM TABLE WHERE COL='VALUE'");
    //partialDataSet.addTable("BAR");
    //FlatXmlDataSet.write(partialDataSet, new FileOutputStream("partial.xml"));

    // full database export
    IDataSet fullDataSet = connection.createDataSet();
    FlatXmlDataSet.write(fullDataSet, new FileOutputStream("full.xml"));

    // dependent tables database export: export table X and all tables that
    // have a PK which is a FK on X, in the right order for insertion
    //String[] depTableNames = TablesDependencyHelper.getAllDependentTables(connection, "X");
View Full Code Here


  /**
   * Connection to the database and performing a clean data insert
   * @throws Exception
   */
  protected void handleSetUpOperation() throws Exception {
    final IDatabaseConnection connection = UtilityTest.getConnection();
    final IDataSet data = getDataSet();
    try {
      DatabaseOperation.CLEAN_INSERT.execute(connection, data);
    } finally {
      connection.close();
    }
  }
View Full Code Here

  /**
   * Connection to the database and performing a clean data insert
   * @throws Exception
   */
  protected void handleSetUpOperation() throws Exception {
    final IDatabaseConnection connection = UtilityTest.getConnection();
    final IDataSet data = getDataSet();
    try {
      DatabaseOperation.CLEAN_INSERT.execute(connection, data);
    } finally {
      connection.close();
    }
  }
View Full Code Here

  /**
   * Connection to the database and performing a clean data insert
   * @throws Exception
   */
  protected void handleSetUpOperation() throws Exception {
    final IDatabaseConnection connection = UtilityTest.getConnection();
    final IDataSet data = getDataSet();
    try {
      DatabaseOperation.CLEAN_INSERT.execute(connection, data);
    } finally {
      connection.close();
    }
  }
View Full Code Here

  /**
   * Connection to the database and performing a clean data insert
   * @throws Exception
   */
  protected void handleSetUpOperation() throws Exception {
    final IDatabaseConnection connection = UtilityTest.getConnection();
    final IDataSet data = getDataSet();
    try {
      DatabaseOperation.CLEAN_INSERT.execute(connection, data);
    } finally {
      connection.close();
    }
  }
View Full Code Here

  /**
   * Connection to the database and performing a clean data insert
   * @throws Exception
   */
  protected void handleSetUpOperation() throws Exception {
    final IDatabaseConnection connection = UtilityTest.getConnection();
    final IDataSet data = getDataSet();
    try {
      DatabaseOperation.CLEAN_INSERT.execute(connection, data);
    } finally {
      connection.close();
    }
  }
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

  public void executeCallback(DbUnitConnectionCallback callback) {
    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());
View Full Code Here

        ds.setPassword(DATABASE_PASSWORD);
        ds.setDefaultAutoCommit(isAutoCommit());

        // prepare the database
        Connection conn = ds.getConnection();
        IDatabaseConnection connection = new DatabaseConnection(conn);
        IDataSet dataSet = new XmlDataSet(new FileInputStream(
                ConfigurationAssert.getTestFile("dataset.xml")));

        try
        {
            DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
        }
        finally
        {
            if (!isAutoCommit())
            {
                conn.commit();
            }
            connection.close();
        }

        return ds;
    }
View Full Code Here

    /**
     * This is some test javadoc.  This test method has a phony dependency on DB Unit.
     */
    public void testMJAVADOC180()
    {
        IDatabaseConnection phony = null;
        final HelloWorld hw = new HelloWorld();
        assertTrue( "Hello World".equals( hw.hello( "Hello World" ) ) );
    }
View Full Code Here

TOP

Related Classes of org.dbunit.database.IDatabaseConnection

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.