Skip to content

Commit

Permalink
replaced dropDBIfExists with Utils function
Browse files Browse the repository at this point in the history
  • Loading branch information
rene-ye committed Jun 18, 2018
1 parent a968dd9 commit 4c85049
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,12 @@ public void testDBSchemasForDashedCatalogName() throws SQLException {
UUID id = UUID.randomUUID();
String testCatalog = "dash-catalog" + id;
String testSchema = "some-schema" + id;
String dropDBIfExists = "IF EXISTS (SELECT name FROM sys.databases WHERE name = N'" + testCatalog + "') " + "DROP DATABASE [" + testCatalog
+ "]";
Statement stmt = connection.createStatement();

try (Connection dashConn = DriverManager.getConnection(connectionString); Statement dashStatement = dashConn.createStatement()) {

connection.createStatement().execute(dropDBIfExists);
connection.createStatement().execute(String.format("CREATE DATABASE [%s]", testCatalog));
Utils.dropDatabaseIfExists(testCatalog, stmt);
stmt.execute(String.format("CREATE DATABASE [%s]", testCatalog));

dashStatement.execute(String.format("USE [%s]", testCatalog));
dashStatement.execute(String.format("CREATE SCHEMA [%s]", testSchema));
Expand Down Expand Up @@ -230,8 +229,9 @@ public void testDBSchemasForDashedCatalogName() throws SQLException {
assertTrue(hasDashCatalogSchema, dashCatalogFormat.format(new Object[] {testSchema}));
}
finally {
connection.createStatement().execute(dropDBIfExists);
Utils.dropDatabaseIfExists(testCatalog, stmt);
}
stmt.close();
}

/**
Expand All @@ -244,13 +244,12 @@ public void testDBSchemasForDashedCatalogNameWithPattern() throws SQLException {
UUID id = UUID.randomUUID();
String testCatalog = "dash-catalog" + id;
String testSchema = "some-schema" + id;
String dropDBIfExists = "IF EXISTS (SELECT name FROM sys.databases WHERE name = N'" + testCatalog + "') " + "DROP DATABASE [" + testCatalog
+ "]";
Statement stmt = connection.createStatement();

try (Connection dashConn = DriverManager.getConnection(connectionString); Statement dashStatement = dashConn.createStatement()) {

connection.createStatement().execute(dropDBIfExists);
connection.createStatement().execute(String.format("CREATE DATABASE [%s]", testCatalog));
Utils.dropDatabaseIfExists(testCatalog, stmt);
stmt.execute(String.format("CREATE DATABASE [%s]", testCatalog));

dashStatement.execute(String.format("USE [%s]", testCatalog));
dashStatement.execute(String.format("CREATE SCHEMA [%s]", testSchema));
Expand All @@ -277,8 +276,9 @@ public void testDBSchemasForDashedCatalogNameWithPattern() throws SQLException {
assertTrue(hasResults, atLeastOneFoundFormat.format(schemaMsgArgs));
}
finally {
connection.createStatement().execute(dropDBIfExists);
Utils.dropDatabaseIfExists(testCatalog, stmt);
}
stmt.close();
}

/**
Expand Down

0 comments on commit 4c85049

Please sign in to comment.