Ejemplo n.º 1
0
  /**
   * Adds the tables of the DbUnit dataset to the given schema.
   *
   * @param dbUnitDataSet The DbUnit dataset containing the tables, not null
   * @param schema The schema to add the tables to, not null
   */
  protected void addTables(IDataSet dbUnitDataSet, Schema schema) throws DataSetException {
    ITableIterator dbUnitTableIterator = dbUnitDataSet.iterator();
    while (dbUnitTableIterator.next()) {
      ITable dbUnitTable = dbUnitTableIterator.getTable();
      String tableName = dbUnitTable.getTableMetaData().getTableName();

      List<String> primaryKeyColumnNames = getPrimaryKeyColumnNames(dbUnitTable);

      Table table = schema.getTable(tableName);
      if (table == null) {
        table = new Table(tableName);
        schema.addTable(table);
      }
      addRows(dbUnitTable, table, primaryKeyColumnNames);
    }
  }