You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ag...@apache.org on 2018/04/05 17:53:43 UTC

[geode] 04/23: GEODE-4947: Update integration tests to use mysql and postgres

This is an automated email from the ASF dual-hosted git repository.

agingade pushed a commit to branch feature/GEODE-4947
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 1f234ca6a1c3eba0d5b65632631d50e1c10e0204
Author: Nick Reich <nr...@pivotal.io>
AuthorDate: Wed Mar 28 10:16:46 2018 -0700

    GEODE-4947: Update integration tests to use mysql and postgres
---
 .../jdbc/internal/SqlStatementFactory.java         | 14 ++++++------
 .../jdbc/JdbcAsyncWriterIntegrationTest.java       | 14 +++++++-----
 .../connectors/jdbc/JdbcLoaderIntegrationTest.java | 15 ++++++++-----
 .../connectors/jdbc/JdbcWriterIntegrationTest.java | 13 ++++++-----
 ...va => MySqlJdbcAsyncWriterIntegrationTest.java} | 22 +++++++++---------
 ...st.java => MySqlJdbcLoaderIntegrationTest.java} | 21 ++++++++---------
 ...st.java => MySqlJdbcWriterIntegrationTest.java} | 21 ++++++++---------
 ...=> PostgresJdbcAsyncWriterIntegrationTest.java} | 21 ++++++++---------
 ...java => PostgresJdbcLoaderIntegrationTest.java} | 21 ++++++++---------
 ...java => PostgresJdbcWriterIntegrationTest.java} | 21 ++++++++---------
 .../jdbc/internal/TestConfigService.java           | 16 ++++++-------
 .../test/junit/rules/DatabaseConnectionRule.java   |  2 ++
 .../junit/rules/InMemoryDerbyConnectionRule.java   |  8 +++++--
 .../test/junit/rules/MySqlConnectionRule.java      | 26 +++++++++++++++++-----
 .../test/junit/rules/PostgresConnectionRule.java   |  2 +-
 .../junit/rules/SqlDatabaseConnectionRule.java     |  4 ++--
 16 files changed, 140 insertions(+), 101 deletions(-)

diff --git a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/SqlStatementFactory.java b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/SqlStatementFactory.java
index ac787b8..d5367ef 100644
--- a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/SqlStatementFactory.java
+++ b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/SqlStatementFactory.java
@@ -22,18 +22,18 @@ class SqlStatementFactory {
     assert columnList.size() == 1;
     ColumnValue keyCV = columnList.get(0);
     assert keyCV.isKey();
-    return "SELECT * FROM \"" + tableName + "\" WHERE \"" + keyCV.getColumnName() + "\" = ?";
+    return "SELECT * FROM " + tableName + " WHERE " + keyCV.getColumnName() + " = ?";
   }
 
   String createDestroySqlString(String tableName, List<ColumnValue> columnList) {
     assert columnList.size() == 1;
     ColumnValue keyCV = columnList.get(0);
     assert keyCV.isKey();
-    return "DELETE FROM \"" + tableName + "\" WHERE \"" + keyCV.getColumnName() + "\" = ?";
+    return "DELETE FROM " + tableName + " WHERE " + keyCV.getColumnName() + " = ?";
   }
 
   String createUpdateSqlString(String tableName, List<ColumnValue> columnList) {
-    StringBuilder query = new StringBuilder("UPDATE \"" + tableName + "\" SET ");
+    StringBuilder query = new StringBuilder("UPDATE " + tableName + " SET ");
     int idx = 0;
     for (ColumnValue column : columnList) {
       if (!column.isKey()) {
@@ -41,14 +41,14 @@ class SqlStatementFactory {
         if (idx > 1) {
           query.append(", ");
         }
-        query.append('"').append(column.getColumnName()).append('"');
+        query.append(column.getColumnName());
         query.append(" = ?");
       }
     }
     for (ColumnValue column : columnList) {
       if (column.isKey()) {
         query.append(" WHERE ");
-        query.append('"').append(column.getColumnName()).append('"');
+        query.append(column.getColumnName());
         query.append(" = ?");
         // currently only support simple primary key with one column
         break;
@@ -58,13 +58,13 @@ class SqlStatementFactory {
   }
 
   String createInsertSqlString(String tableName, List<ColumnValue> columnList) {
-    StringBuilder columnNames = new StringBuilder("INSERT INTO \"" + tableName + "\" (");
+    StringBuilder columnNames = new StringBuilder("INSERT INTO " + tableName + " (");
     StringBuilder columnValues = new StringBuilder(" VALUES (");
     int columnCount = columnList.size();
     int idx = 0;
     for (ColumnValue column : columnList) {
       idx++;
-      columnNames.append('"').append(column.getColumnName()).append('"');
+      columnNames.append(column.getColumnName());
       columnValues.append('?');
       if (idx != columnCount) {
         columnNames.append(", ");
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcAsyncWriterIntegrationTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcAsyncWriterIntegrationTest.java
index c1adcb9..11767eb 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcAsyncWriterIntegrationTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcAsyncWriterIntegrationTest.java
@@ -44,11 +44,10 @@ import org.apache.geode.pdx.PdxInstance;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
-public class JdbcAsyncWriterIntegrationTest {
+public abstract class JdbcAsyncWriterIntegrationTest {
 
-  private static final String DB_NAME = "DerbyDB";
+  static final String DB_NAME = "test";
   private static final String REGION_TABLE_NAME = "employees";
-  private static final String CONNECTION_URL = "jdbc:derby:memory:" + DB_NAME + ";create=true";
 
   private InternalCache cache;
   private Region<String, PdxInstance> employees;
@@ -65,7 +64,8 @@ public class JdbcAsyncWriterIntegrationTest {
     cache = (InternalCache) new CacheFactory().set("locators", "").set("mcast-port", "0")
         .setPdxReadSerialized(false).create();
     employees = createRegionWithJDBCAsyncWriter(REGION_TABLE_NAME);
-    connection = DriverManager.getConnection(CONNECTION_URL);
+    // connection = DriverManager.getConnection(CONNECTION_URL);
+    connection = getConnection();
     statement = connection.createStatement();
     statement.execute("Create Table " + REGION_TABLE_NAME
         + " (id varchar(10) primary key not null, name varchar(10), age int)");
@@ -95,6 +95,10 @@ public class JdbcAsyncWriterIntegrationTest {
     }
   }
 
+  public abstract Connection getConnection() throws SQLException;
+
+  public abstract String getConnectionUrl();
+
   @Test
   public void validateJDBCAsyncWriterTotalEvents() {
     employees.put("1", pdxEmployee1);
@@ -241,7 +245,7 @@ public class JdbcAsyncWriterIntegrationTest {
   private SqlHandler createSqlHandler()
       throws ConnectionConfigExistsException, RegionMappingExistsException {
     return new SqlHandler(new TestableConnectionManager(), new TableMetaDataManager(),
-        TestConfigService.getTestConfigService());
+        TestConfigService.getTestConfigService(getConnectionUrl()));
   }
 
 }
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcLoaderIntegrationTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcLoaderIntegrationTest.java
index a4ec5ab..6a9dfbd 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcLoaderIntegrationTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcLoaderIntegrationTest.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
+import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Date;
 
@@ -48,11 +49,11 @@ import org.apache.geode.pdx.internal.AutoSerializableManager;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
-public class JdbcLoaderIntegrationTest {
+public abstract class JdbcLoaderIntegrationTest {
+
+  static final String DB_NAME = "test";
 
-  private static final String DB_NAME = "DerbyDB";
   private static final String REGION_TABLE_NAME = "employees";
-  private static final String CONNECTION_URL = "jdbc:derby:memory:" + DB_NAME + ";create=true";
 
   private InternalCache cache;
   private Connection connection;
@@ -69,7 +70,7 @@ public class JdbcLoaderIntegrationTest {
         .setPdxSerializer(
             new ReflectionBasedAutoSerializer(ClassWithSupportedPdxFields.class.getName()))
         .create();
-    connection = DriverManager.getConnection(CONNECTION_URL);
+    connection = getConnection();
     statement = connection.createStatement();
   }
 
@@ -79,6 +80,10 @@ public class JdbcLoaderIntegrationTest {
     closeDB();
   }
 
+  public abstract Connection getConnection() throws SQLException;
+
+  public abstract String getConnectionUrl();
+
   private void createEmployeeTable() throws Exception {
     statement.execute("Create Table " + REGION_TABLE_NAME
         + " (id varchar(10) primary key not null, name varchar(10), age int)");
@@ -182,7 +187,7 @@ public class JdbcLoaderIntegrationTest {
       throws ConnectionConfigExistsException, RegionMappingExistsException {
     return new SqlHandler(new TestableConnectionManager(), new TableMetaDataManager(),
         TestConfigService.getTestConfigService((InternalCache) cache, pdxClassName,
-            primaryKeyInValue));
+            primaryKeyInValue, getConnectionUrl()));
   }
 
   private <K, V> Region<K, V> createRegionWithJDBCLoader(String regionName, String pdxClassName,
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcWriterIntegrationTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcWriterIntegrationTest.java
index 5e42631..5a489a7 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcWriterIntegrationTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JdbcWriterIntegrationTest.java
@@ -46,11 +46,10 @@ import org.apache.geode.pdx.PdxInstance;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
-public class JdbcWriterIntegrationTest {
+public abstract class JdbcWriterIntegrationTest {
 
-  private static final String DB_NAME = "DerbyDB";
+  static final String DB_NAME = "test";
   private static final String REGION_TABLE_NAME = "employees";
-  private static final String CONNECTION_URL = "jdbc:derby:memory:" + DB_NAME + ";create=true";
 
   private InternalCache cache;
   private Region<String, PdxInstance> employees;
@@ -68,7 +67,7 @@ public class JdbcWriterIntegrationTest {
         .setPdxReadSerialized(false).create();
     employees = createRegionWithJDBCSynchronousWriter(REGION_TABLE_NAME);
 
-    connection = DriverManager.getConnection(CONNECTION_URL);
+    connection = getConnection();
     statement = connection.createStatement();
     statement.execute("Create Table " + REGION_TABLE_NAME
         + " (id varchar(10) primary key not null, name varchar(10), age int)");
@@ -86,6 +85,10 @@ public class JdbcWriterIntegrationTest {
     closeDB();
   }
 
+  public abstract Connection getConnection() throws SQLException;
+
+  public abstract String getConnectionUrl();
+
   private void closeDB() throws Exception {
     if (statement == null) {
       statement = connection.createStatement();
@@ -227,7 +230,7 @@ public class JdbcWriterIntegrationTest {
   private SqlHandler createSqlHandler()
       throws ConnectionConfigExistsException, RegionMappingExistsException {
     return new SqlHandler(new TestableConnectionManager(), new TableMetaDataManager(),
-        TestConfigService.getTestConfigService());
+        TestConfigService.getTestConfigService(getConnectionUrl()));
   }
 
   private void assertRecordMatchesEmployee(ResultSet resultSet, String key, Employee employee)
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/MySqlJdbcAsyncWriterIntegrationTest.java
similarity index 64%
copy from geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
copy to geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/MySqlJdbcAsyncWriterIntegrationTest.java
index 8f0ed43..2ca6ff4 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/MySqlJdbcAsyncWriterIntegrationTest.java
@@ -12,32 +12,34 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.connectors.jdbc.internal;
+package org.apache.geode.connectors.jdbc;
 
 import java.sql.Connection;
 import java.sql.SQLException;
 
-import org.junit.Rule;
+import org.junit.ClassRule;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.rules.DatabaseConnectionRule;
-import org.apache.geode.test.junit.rules.InMemoryDerbyConnectionRule;
+import org.apache.geode.test.junit.rules.MySqlConnectionRule;
+import org.apache.geode.test.junit.rules.PostgresConnectionRule;
 
 @Category(IntegrationTest.class)
-public class DerbyTableMetaDataManagerIntegrationTest extends TableMetaDataManagerIntegrationTest {
+public class MySqlJdbcAsyncWriterIntegrationTest extends JdbcAsyncWriterIntegrationTest {
 
-  @Rule
-  public DatabaseConnectionRule dbRule = new InMemoryDerbyConnectionRule(DB_NAME);
+  @ClassRule
+  public static DatabaseConnectionRule dbRule =
+      new MySqlConnectionRule.Builder().file("src/test/resources/docker/mysql.yml")
+          .serviceName("db").port(3306).database(DB_NAME).build();
 
   @Override
-  protected Connection getConnection() throws SQLException {
+  public Connection getConnection() throws SQLException {
     return dbRule.getConnection();
   }
 
   @Override
-  protected void createTable() throws SQLException {
-    statement.execute("Create Table " + REGION_TABLE_NAME
-        + " (\"id\" varchar(10) primary key not null, \"name\" varchar(10), \"age\" int)");
+  public String getConnectionUrl() {
+    return dbRule.getConnectionUrl();
   }
 }
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/MySqlJdbcLoaderIntegrationTest.java
similarity index 65%
copy from geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
copy to geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/MySqlJdbcLoaderIntegrationTest.java
index 8f0ed43..9555769 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/MySqlJdbcLoaderIntegrationTest.java
@@ -12,32 +12,33 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.connectors.jdbc.internal;
+package org.apache.geode.connectors.jdbc;
 
 import java.sql.Connection;
 import java.sql.SQLException;
 
-import org.junit.Rule;
+import org.junit.ClassRule;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.rules.DatabaseConnectionRule;
-import org.apache.geode.test.junit.rules.InMemoryDerbyConnectionRule;
+import org.apache.geode.test.junit.rules.MySqlConnectionRule;
 
 @Category(IntegrationTest.class)
-public class DerbyTableMetaDataManagerIntegrationTest extends TableMetaDataManagerIntegrationTest {
+public class MySqlJdbcLoaderIntegrationTest extends JdbcLoaderIntegrationTest {
 
-  @Rule
-  public DatabaseConnectionRule dbRule = new InMemoryDerbyConnectionRule(DB_NAME);
+  @ClassRule
+  public static DatabaseConnectionRule dbRule =
+      new MySqlConnectionRule.Builder().file("src/test/resources/docker/mysql.yml")
+          .serviceName("db").port(3306).database(DB_NAME).build();
 
   @Override
-  protected Connection getConnection() throws SQLException {
+  public Connection getConnection() throws SQLException {
     return dbRule.getConnection();
   }
 
   @Override
-  protected void createTable() throws SQLException {
-    statement.execute("Create Table " + REGION_TABLE_NAME
-        + " (\"id\" varchar(10) primary key not null, \"name\" varchar(10), \"age\" int)");
+  public String getConnectionUrl() {
+    return dbRule.getConnectionUrl();
   }
 }
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/MySqlJdbcWriterIntegrationTest.java
similarity index 65%
copy from geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
copy to geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/MySqlJdbcWriterIntegrationTest.java
index 8f0ed43..8ca1ca3 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/MySqlJdbcWriterIntegrationTest.java
@@ -12,32 +12,33 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.connectors.jdbc.internal;
+package org.apache.geode.connectors.jdbc;
 
 import java.sql.Connection;
 import java.sql.SQLException;
 
-import org.junit.Rule;
+import org.junit.ClassRule;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.rules.DatabaseConnectionRule;
-import org.apache.geode.test.junit.rules.InMemoryDerbyConnectionRule;
+import org.apache.geode.test.junit.rules.MySqlConnectionRule;
 
 @Category(IntegrationTest.class)
-public class DerbyTableMetaDataManagerIntegrationTest extends TableMetaDataManagerIntegrationTest {
+public class MySqlJdbcWriterIntegrationTest extends JdbcWriterIntegrationTest {
 
-  @Rule
-  public DatabaseConnectionRule dbRule = new InMemoryDerbyConnectionRule(DB_NAME);
+  @ClassRule
+  public static DatabaseConnectionRule dbRule =
+      new MySqlConnectionRule.Builder().file("src/test/resources/docker/mysql.yml")
+          .serviceName("db").port(3306).database(DB_NAME).build();
 
   @Override
-  protected Connection getConnection() throws SQLException {
+  public Connection getConnection() throws SQLException {
     return dbRule.getConnection();
   }
 
   @Override
-  protected void createTable() throws SQLException {
-    statement.execute("Create Table " + REGION_TABLE_NAME
-        + " (\"id\" varchar(10) primary key not null, \"name\" varchar(10), \"age\" int)");
+  public String getConnectionUrl() {
+    return dbRule.getConnectionUrl();
   }
 }
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/PostgresJdbcAsyncWriterIntegrationTest.java
similarity index 65%
copy from geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
copy to geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/PostgresJdbcAsyncWriterIntegrationTest.java
index 8f0ed43..31baf95 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/PostgresJdbcAsyncWriterIntegrationTest.java
@@ -12,32 +12,33 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.connectors.jdbc.internal;
+package org.apache.geode.connectors.jdbc;
 
 import java.sql.Connection;
 import java.sql.SQLException;
 
-import org.junit.Rule;
+import org.junit.ClassRule;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.rules.DatabaseConnectionRule;
-import org.apache.geode.test.junit.rules.InMemoryDerbyConnectionRule;
+import org.apache.geode.test.junit.rules.PostgresConnectionRule;
 
 @Category(IntegrationTest.class)
-public class DerbyTableMetaDataManagerIntegrationTest extends TableMetaDataManagerIntegrationTest {
+public class PostgresJdbcAsyncWriterIntegrationTest extends JdbcAsyncWriterIntegrationTest {
 
-  @Rule
-  public DatabaseConnectionRule dbRule = new InMemoryDerbyConnectionRule(DB_NAME);
+  @ClassRule
+  public static DatabaseConnectionRule dbRule =
+      new PostgresConnectionRule.Builder().file("src/test/resources/docker/postgres.yml")
+          .serviceName("db").port(5432).database(DB_NAME).build();
 
   @Override
-  protected Connection getConnection() throws SQLException {
+  public Connection getConnection() throws SQLException {
     return dbRule.getConnection();
   }
 
   @Override
-  protected void createTable() throws SQLException {
-    statement.execute("Create Table " + REGION_TABLE_NAME
-        + " (\"id\" varchar(10) primary key not null, \"name\" varchar(10), \"age\" int)");
+  public String getConnectionUrl() {
+    return dbRule.getConnectionUrl();
   }
 }
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/PostgresJdbcLoaderIntegrationTest.java
similarity index 65%
copy from geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
copy to geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/PostgresJdbcLoaderIntegrationTest.java
index 8f0ed43..0a96d5f 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/PostgresJdbcLoaderIntegrationTest.java
@@ -12,32 +12,33 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.connectors.jdbc.internal;
+package org.apache.geode.connectors.jdbc;
 
 import java.sql.Connection;
 import java.sql.SQLException;
 
-import org.junit.Rule;
+import org.junit.ClassRule;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.rules.DatabaseConnectionRule;
-import org.apache.geode.test.junit.rules.InMemoryDerbyConnectionRule;
+import org.apache.geode.test.junit.rules.PostgresConnectionRule;
 
 @Category(IntegrationTest.class)
-public class DerbyTableMetaDataManagerIntegrationTest extends TableMetaDataManagerIntegrationTest {
+public class PostgresJdbcLoaderIntegrationTest extends JdbcLoaderIntegrationTest {
 
-  @Rule
-  public DatabaseConnectionRule dbRule = new InMemoryDerbyConnectionRule(DB_NAME);
+  @ClassRule
+  public static DatabaseConnectionRule dbRule =
+      new PostgresConnectionRule.Builder().file("src/test/resources/docker/postgres.yml")
+          .serviceName("db").port(5432).database(DB_NAME).build();
 
   @Override
-  protected Connection getConnection() throws SQLException {
+  public Connection getConnection() throws SQLException {
     return dbRule.getConnection();
   }
 
   @Override
-  protected void createTable() throws SQLException {
-    statement.execute("Create Table " + REGION_TABLE_NAME
-        + " (\"id\" varchar(10) primary key not null, \"name\" varchar(10), \"age\" int)");
+  public String getConnectionUrl() {
+    return dbRule.getConnectionUrl();
   }
 }
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/PostgresJdbcWriterIntegrationTest.java
similarity index 65%
rename from geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
rename to geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/PostgresJdbcWriterIntegrationTest.java
index 8f0ed43..ab2fe8d 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/PostgresJdbcWriterIntegrationTest.java
@@ -12,32 +12,33 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.connectors.jdbc.internal;
+package org.apache.geode.connectors.jdbc;
 
 import java.sql.Connection;
 import java.sql.SQLException;
 
-import org.junit.Rule;
+import org.junit.ClassRule;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.rules.DatabaseConnectionRule;
-import org.apache.geode.test.junit.rules.InMemoryDerbyConnectionRule;
+import org.apache.geode.test.junit.rules.PostgresConnectionRule;
 
 @Category(IntegrationTest.class)
-public class DerbyTableMetaDataManagerIntegrationTest extends TableMetaDataManagerIntegrationTest {
+public class PostgresJdbcWriterIntegrationTest extends JdbcWriterIntegrationTest {
 
-  @Rule
-  public DatabaseConnectionRule dbRule = new InMemoryDerbyConnectionRule(DB_NAME);
+  @ClassRule
+  public static DatabaseConnectionRule dbRule =
+      new PostgresConnectionRule.Builder().file("src/test/resources/docker/postgres.yml")
+          .serviceName("db").port(5432).database(DB_NAME).build();
 
   @Override
-  protected Connection getConnection() throws SQLException {
+  public Connection getConnection() throws SQLException {
     return dbRule.getConnection();
   }
 
   @Override
-  protected void createTable() throws SQLException {
-    statement.execute("Create Table " + REGION_TABLE_NAME
-        + " (\"id\" varchar(10) primary key not null, \"name\" varchar(10), \"age\" int)");
+  public String getConnectionUrl() {
+    return dbRule.getConnectionUrl();
   }
 }
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TestConfigService.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TestConfigService.java
index 93c3f27..cd19d33 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TestConfigService.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TestConfigService.java
@@ -26,24 +26,24 @@ import org.apache.geode.internal.cache.extension.ExtensionPoint;
  * Generates fake JdbcConnectorService with Connections and RegionMappings for tests.
  */
 public class TestConfigService {
-  private static final String DB_NAME = "DerbyDB";
+  // private static final String DB_NAME = "DerbyDB";
   private static final String REGION_TABLE_NAME = "employees";
   private static final String REGION_NAME = "employees";
-  private static final String CONNECTION_URL = "jdbc:derby:memory:" + DB_NAME + ";create=true";
+  // private static final String CONNECTION_URL = "jdbc:derby:memory:" + DB_NAME + ";create=true";
   private static final String CONNECTION_CONFIG_NAME = "testConnectionConfig";
 
-  public static JdbcConnectorServiceImpl getTestConfigService()
+  public static JdbcConnectorServiceImpl getTestConfigService(String connectionUrl)
       throws ConnectionConfigExistsException, RegionMappingExistsException {
-    return getTestConfigService(createMockCache(), null, false);
+    return getTestConfigService(createMockCache(), null, false, connectionUrl);
   }
 
   public static JdbcConnectorServiceImpl getTestConfigService(InternalCache cache,
-      String pdxClassName, boolean primaryKeyInValue)
+      String pdxClassName, boolean primaryKeyInValue, String connectionUrl)
       throws ConnectionConfigExistsException, RegionMappingExistsException {
 
     JdbcConnectorServiceImpl service = new JdbcConnectorServiceImpl();
     service.init(cache);
-    service.createConnectionConfig(createConnectionConfig());
+    service.createConnectionConfig(createConnectionConfig(connectionUrl));
     service.createRegionMapping(createRegionMapping(pdxClassName, primaryKeyInValue));
     return service;
   }
@@ -59,7 +59,7 @@ public class TestConfigService {
         primaryKeyInValue, Collections.emptyMap());
   }
 
-  private static ConnectionConfiguration createConnectionConfig() {
-    return new ConnectionConfiguration(CONNECTION_CONFIG_NAME, CONNECTION_URL, null, null, null);
+  private static ConnectionConfiguration createConnectionConfig(String connectionUrl) {
+    return new ConnectionConfiguration(CONNECTION_CONFIG_NAME, connectionUrl, null, null, null);
   }
 }
diff --git a/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/DatabaseConnectionRule.java b/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/DatabaseConnectionRule.java
index bd1c9cf..a2d7d56 100644
--- a/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/DatabaseConnectionRule.java
+++ b/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/DatabaseConnectionRule.java
@@ -21,4 +21,6 @@ import org.junit.rules.TestRule;
 
 public interface DatabaseConnectionRule extends TestRule {
   Connection getConnection() throws SQLException;
+
+  String getConnectionUrl();
 }
diff --git a/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/InMemoryDerbyConnectionRule.java b/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/InMemoryDerbyConnectionRule.java
index 299a858..86b55e0 100644
--- a/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/InMemoryDerbyConnectionRule.java
+++ b/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/InMemoryDerbyConnectionRule.java
@@ -32,7 +32,11 @@ public class InMemoryDerbyConnectionRule extends ExternalResource
 
   @Override
   public Connection getConnection() throws SQLException {
-    String url = String.format(CONNECTION_URL, dbName);
-    return DriverManager.getConnection(url);
+    return DriverManager.getConnection(getConnectionUrl());
+  }
+
+  @Override
+  public String getConnectionUrl() {
+    return String.format(CONNECTION_URL, dbName);
   }
 }
diff --git a/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/MySqlConnectionRule.java b/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/MySqlConnectionRule.java
index 8a3d34f..ca10229 100644
--- a/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/MySqlConnectionRule.java
+++ b/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/MySqlConnectionRule.java
@@ -14,15 +14,23 @@
  */
 package org.apache.geode.test.junit.rules;
 
+import static org.awaitility.Awaitility.matches;
+
 import java.sql.Connection;
+import java.sql.DriverManager;
 import java.sql.SQLException;
+import java.util.concurrent.TimeUnit;
 
 import com.palantir.docker.compose.DockerComposeRule;
+import org.awaitility.Awaitility;
 
 public class MySqlConnectionRule extends SqlDatabaseConnectionRule {
-  private static final String CONNECTION_STRING =
+  private static final String CREATE_DB_CONNECTION_STRING =
       "jdbc:mysql://$HOST:$EXTERNAL_PORT?user=root&useSSL=false";
 
+  private static final String CONNECTION_STRING =
+      "jdbc:mysql://$HOST:$EXTERNAL_PORT/%s?user=root&useSSL=false";
+
   protected MySqlConnectionRule(DockerComposeRule dockerRule, String serviceName, int port,
       String dbName) {
     super(dockerRule, serviceName, port, dbName);
@@ -30,18 +38,24 @@ public class MySqlConnectionRule extends SqlDatabaseConnectionRule {
 
   @Override
   public Connection getConnection() throws SQLException {
-    Connection connection = super.getConnection();
+    Awaitility.await().ignoreExceptions().atMost(10, TimeUnit.SECONDS)
+        .until(matches(() -> DriverManager.getConnection(getCreateDbConnectionUrl())));
     String dbName = getDbName();
     if (dbName != null) {
+      Connection connection = DriverManager.getConnection(getCreateDbConnectionUrl());
       connection.createStatement().execute("CREATE DATABASE IF NOT EXISTS " + dbName);
-      connection.setCatalog(dbName);
     }
-    return connection;
+    return DriverManager.getConnection(getConnectionUrl());
   }
 
   @Override
-  protected String getConnectionString() {
-    return getDockerPort().inFormat(CONNECTION_STRING);
+  public String getConnectionUrl() {
+    return getDockerPort().inFormat(String.format(CONNECTION_STRING, getDbName()));
+  }
+
+
+  public String getCreateDbConnectionUrl() {
+    return getDockerPort().inFormat(CREATE_DB_CONNECTION_STRING);
   }
 
   public static class Builder extends SqlDatabaseConnectionRule.Builder {
diff --git a/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/PostgresConnectionRule.java b/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/PostgresConnectionRule.java
index a3d064c..2f11c4b 100644
--- a/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/PostgresConnectionRule.java
+++ b/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/PostgresConnectionRule.java
@@ -26,7 +26,7 @@ public class PostgresConnectionRule extends SqlDatabaseConnectionRule {
   }
 
   @Override
-  protected String getConnectionString() {
+  public String getConnectionUrl() {
     return getDockerPort().inFormat(String.format(CONNECTION_STRING, getDbName()));
   }
 
diff --git a/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/SqlDatabaseConnectionRule.java b/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/SqlDatabaseConnectionRule.java
index 2897873..96fae8a 100644
--- a/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/SqlDatabaseConnectionRule.java
+++ b/geode-connectors/src/test/java/org/apache/geode/test/junit/rules/SqlDatabaseConnectionRule.java
@@ -64,14 +64,14 @@ public abstract class SqlDatabaseConnectionRule extends ExternalResource
 
   @Override
   public Connection getConnection() throws SQLException {
-    String connectionUrl = getConnectionString();
+    String connectionUrl = getConnectionUrl();
     Awaitility.await().ignoreExceptions().atMost(10, TimeUnit.SECONDS)
         .until(matches(() -> DriverManager.getConnection(connectionUrl)));
     Connection connection = DriverManager.getConnection(connectionUrl);
     return connection;
   }
 
-  protected abstract String getConnectionString();
+  public abstract String getConnectionUrl();
 
   public abstract static class Builder {
     private String filePath;

-- 
To stop receiving notification emails like this one, please contact
agingade@apache.org.