X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsupport%2Fpersistence%2FDatabaseUtils.java;h=311d2da3189afcfcf09141b3b52996cc1895140d;hb=96c8961955a306314dfe0cf9ca192252de39fc1c;hp=5f26bd8e0dceab7d128684399eacb51727d950bc;hpb=b55898f1f5b788c9a5fcbb06cd79ffb211aff3de;p=utils diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java index 5f26bd8e..311d2da3 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java @@ -90,15 +90,12 @@ public class DatabaseUtils { final String[] tables = getTableNames(aTables); executeInTransaction(new JdbcUnitOfWork() { public Void execute(Connection aConnection) throws Exception { - for (int i = tables.length - 1; i >= 0; i--) { + for (int i = tables.length-1; i >= 0; i--) { aOperation.execute(tables[i]); } return null; } }); - for (String table : tables) { - - } } public void cleanDatabase(ITableFilterSimple aSelection) throws Exception { @@ -190,25 +187,30 @@ public class DatabaseUtils { public void emptyTable(String aTable) throws Exception { executeSql("delete from " + aTable); } - - public void dropTables() throws Exception { - executeOnTables(tables, new TableSetOperation() { - - public void execute(String aTable) throws Exception { - dropTable(aTable); - } - }); + + public void dropTables() throws Exception { + dropTables(tables); } public void dropTables(ITableFilterSimple aTables) throws Exception { - executeOnTables(aTables, new TableSetOperation() { + final String[] tables = getTableNames(aTables); + String[] sortedTables = executeInTransaction(new JdbcUnitOfWork() { - public void execute(String aTable) throws Exception { - dropTable(aTable); + public String[] execute(Connection aConnection) throws Exception { + IDatabaseConnection connection = new DatabaseConnection( + aConnection); + ITableFilter filter = new DatabaseSequenceFilter(connection, + tables); + IDataSet dataset = new FilteredDataSet(filter, connection + .createDataSet(tables)); + return dataset.getTableNames(); } }); + for (int i = sortedTables.length-1; i >= 0; i--) { + dropTable(sortedTables[i]); + } } - + /** * @return * @throws SQLException