Details
diff --git a/util/src/test/java/com/ning/billing/dbi/DBTestingHelper.java b/util/src/test/java/com/ning/billing/dbi/DBTestingHelper.java
index 35e3590..840e330 100644
--- a/util/src/test/java/com/ning/billing/dbi/DBTestingHelper.java
+++ b/util/src/test/java/com/ning/billing/dbi/DBTestingHelper.java
@@ -19,11 +19,9 @@ package com.ning.billing.dbi;
import java.io.IOException;
import java.util.List;
-import org.skife.jdbi.v2.DBI;
import org.skife.jdbi.v2.Handle;
import org.skife.jdbi.v2.IDBI;
import org.skife.jdbi.v2.tweak.HandleCallback;
-import org.skife.jdbi.v2.util.StringMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -121,26 +119,6 @@ public abstract class DBTestingHelper {
});
}
- public synchronized List<String> fetchAllTables() {
- if (allTables == null) {
- final String dbiString = getInformationSchemaJdbcConnectionString();
- final IDBI cleanupDbi = new DBI(dbiString, USERNAME, PASSWORD);
-
- final List<String> tables = cleanupDbi.withHandle(new HandleCallback<List<String>>() {
-
- @Override
- public List<String> withHandle(final Handle h) throws Exception {
- return h.createQuery("select table_name from tables where table_schema = :table_schema and table_type = 'BASE TABLE';")
- .bind("table_schema", DB_NAME)
- .map(new StringMapper())
- .list();
- }
- });
- allTables = tables;
- }
- return allTables;
- }
-
public void cleanupAllTables() {
final List<String> tablesToCleanup = fetchAllTables();
for (final String tableName : tablesToCleanup) {
@@ -172,7 +150,7 @@ public abstract class DBTestingHelper {
// To create the DBI
public abstract String getJdbcConnectionString();
- public abstract String getInformationSchemaJdbcConnectionString();
+ public abstract List<String> fetchAllTables();
public abstract void start() throws IOException;
diff --git a/util/src/test/java/com/ning/billing/dbi/H2TestingHelper.java b/util/src/test/java/com/ning/billing/dbi/H2TestingHelper.java
index 3e798fa..92e5a90 100644
--- a/util/src/test/java/com/ning/billing/dbi/H2TestingHelper.java
+++ b/util/src/test/java/com/ning/billing/dbi/H2TestingHelper.java
@@ -18,8 +18,12 @@ package com.ning.billing.dbi;
import java.io.IOException;
import java.sql.SQLException;
+import java.util.List;
import org.h2.tools.Server;
+import org.skife.jdbi.v2.Handle;
+import org.skife.jdbi.v2.tweak.HandleCallback;
+import org.skife.jdbi.v2.util.StringMapper;
import org.testng.Assert;
public class H2TestingHelper extends DBTestingHelper {
@@ -50,8 +54,20 @@ public class H2TestingHelper extends DBTestingHelper {
}
@Override
- public String getInformationSchemaJdbcConnectionString() {
- return "jdbc:h2:mem:foo;MODE=MYSQL;SCHEMA_SEARCH_PATH=INFORMATION_SCHEMA;DB_CLOSE_DELAY=-1";
+ public synchronized List<String> fetchAllTables() {
+ if (allTables == null) {
+ allTables = dbiInstance.withHandle(new HandleCallback<List<String>>() {
+
+ @Override
+ public List<String> withHandle(final Handle h) throws Exception {
+ return h.createQuery("select table_name from information_schema.tables where table_catalog = :table_catalog and table_type = 'TABLE';")
+ .bind("table_catalog", DB_NAME)
+ .map(new StringMapper())
+ .list();
+ }
+ });
+ }
+ return allTables;
}
@Override
diff --git a/util/src/test/java/com/ning/billing/dbi/MysqlTestingHelper.java b/util/src/test/java/com/ning/billing/dbi/MysqlTestingHelper.java
index 52b4be0..39d1021 100644
--- a/util/src/test/java/com/ning/billing/dbi/MysqlTestingHelper.java
+++ b/util/src/test/java/com/ning/billing/dbi/MysqlTestingHelper.java
@@ -22,8 +22,12 @@ import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import org.skife.jdbi.v2.Handle;
+import org.skife.jdbi.v2.tweak.HandleCallback;
+import org.skife.jdbi.v2.util.StringMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@@ -77,8 +81,20 @@ public class MysqlTestingHelper extends DBTestingHelper {
}
@Override
- public String getInformationSchemaJdbcConnectionString() {
- return "jdbc:mysql://localhost:" + port + "/information_schema";
+ public synchronized List<String> fetchAllTables() {
+ if (allTables == null) {
+ allTables = dbiInstance.withHandle(new HandleCallback<List<String>>() {
+
+ @Override
+ public List<String> withHandle(final Handle h) throws Exception {
+ return h.createQuery("select table_name from tables where table_schema = :table_schema and table_type = 'BASE TABLE';")
+ .bind("table_schema", DB_NAME)
+ .map(new StringMapper())
+ .list();
+ }
+ });
+ }
+ return allTables;
}
public void start() throws IOException {