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 6603bdc9a1ccf9373157186052b3a67f38e9d059
Author: Nick Reich <nre...@pivotal.io>
AuthorDate: Tue Mar 27 14:24:04 2018 -0700

    GEODE-4947: Add Derby connection rule
---
 .../DerbyTableMetaDataManagerIntegrationTest.java  |  43 ++++++++
 .../MySqlTableMetaDataManagerIntegrationTest.java  |  39 +++++++
 ...ostgresTableMetaDataManagerIntegrationTest.java |  40 ++++++++
 .../TableMetaDataManagerIntegrationTest.java       |  28 +++--
 .../TableMetaDataManagerMySqlIntegrationTest.java  | 113 --------------------
 ...ableMetaDataManagerPostgresIntegrationTest.java | 114 ---------------------
 .../test/junit/rules/DatabaseConnectionRule.java   | 103 +------------------
 ...nRule.java => InMemoryDerbyConnectionRule.java} |  37 +++----
 .../test/junit/rules/MySqlConnectionRule.java      |   4 +-
 .../test/junit/rules/PostgresConnectionRule.java   |   4 +-
 ...ionRule.java => SqlDatabaseConnectionRule.java} |   6 +-
 11 files changed, 165 insertions(+), 366 deletions(-)

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/internal/DerbyTableMetaDataManagerIntegrationTest.java
new file mode 100644
index 0000000..8f0ed43
--- /dev/null
+++ 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/DerbyTableMetaDataManagerIntegrationTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.geode.connectors.jdbc.internal;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.junit.Rule;
+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;
+
+@Category(IntegrationTest.class)
+public class DerbyTableMetaDataManagerIntegrationTest extends 
TableMetaDataManagerIntegrationTest {
+
+  @Rule
+  public DatabaseConnectionRule dbRule = new 
InMemoryDerbyConnectionRule(DB_NAME);
+
+  @Override
+  protected 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)");
+  }
+}
diff --git 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/MySqlTableMetaDataManagerIntegrationTest.java
 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/MySqlTableMetaDataManagerIntegrationTest.java
new file mode 100644
index 0000000..b69f88c
--- /dev/null
+++ 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/MySqlTableMetaDataManagerIntegrationTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.geode.connectors.jdbc.internal;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+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.MySqlConnectionRule;
+
+@Category(IntegrationTest.class)
+public class MySqlTableMetaDataManagerIntegrationTest extends 
TableMetaDataManagerIntegrationTest {
+
+  @ClassRule
+  public static DatabaseConnectionRule dbRule =
+      new 
MySqlConnectionRule.Builder().file("src/test/resources/docker/mysql.yml")
+          .serviceName("db").port(3306).database(DB_NAME).build();
+
+  @Override
+  public Connection getConnection() throws SQLException {
+    return dbRule.getConnection();
+  }
+}
diff --git 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/PostgresTableMetaDataManagerIntegrationTest.java
 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/PostgresTableMetaDataManagerIntegrationTest.java
new file mode 100644
index 0000000..21573e9
--- /dev/null
+++ 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/PostgresTableMetaDataManagerIntegrationTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.geode.connectors.jdbc.internal;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+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.PostgresConnectionRule;
+
+@Category(IntegrationTest.class)
+public class PostgresTableMetaDataManagerIntegrationTest
+    extends TableMetaDataManagerIntegrationTest {
+
+  @ClassRule
+  public static DatabaseConnectionRule dbRule =
+      new 
PostgresConnectionRule.Builder().file("src/test/resources/docker/postgres.yml")
+          .serviceName("db").port(5432).database(DB_NAME).build();
+
+  @Override
+  public Connection getConnection() throws SQLException {
+    return dbRule.getConnection();
+  }
+}
diff --git 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TableMetaDataManagerIntegrationTest.java
 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TableMetaDataManagerIntegrationTest.java
index cf91661..02a6584 100644
--- 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TableMetaDataManagerIntegrationTest.java
+++ 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TableMetaDataManagerIntegrationTest.java
@@ -19,7 +19,7 @@ package org.apache.geode.connectors.jdbc.internal;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.sql.Connection;
-import java.sql.DriverManager;
+import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Types;
 
@@ -31,22 +31,20 @@ import org.junit.experimental.categories.Category;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
-public class TableMetaDataManagerIntegrationTest {
+public abstract class TableMetaDataManagerIntegrationTest {
 
-  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";
+  protected static final String REGION_TABLE_NAME = "employees";
+  protected static final String DB_NAME = "test";
 
-  private TableMetaDataManager manager;
-  private Connection connection;
-  private Statement statement;
+  protected TableMetaDataManager manager;
+  protected Connection connection;
+  protected Statement statement;
 
   @Before
   public void setup() throws Exception {
-    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)");
+    createTable();
     manager = new TableMetaDataManager();
   }
 
@@ -67,6 +65,14 @@ public class TableMetaDataManagerIntegrationTest {
     }
   }
 
+  protected abstract Connection getConnection() throws SQLException;
+
+  protected void createTable() throws SQLException {
+    statement.execute("CREATE TABLE " + REGION_TABLE_NAME
+        + " (id VARCHAR(10) primary key not null, name VARCHAR(10), age int)");
+
+  }
+
   @Test
   public void validateKeyColumnName() {
     TableMetaDataView metaData = manager.getTableMetaDataView(connection, 
REGION_TABLE_NAME);
diff --git 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TableMetaDataManagerMySqlIntegrationTest.java
 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TableMetaDataManagerMySqlIntegrationTest.java
deleted file mode 100644
index 25cac1b..0000000
--- 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TableMetaDataManagerMySqlIntegrationTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
- * agreements. See the NOTICE file distributed with this work for additional 
information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the 
License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software 
distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
- * or implied. See the License for the specific language governing permissions 
and limitations under
- * the License.
- */
-package org.apache.geode.connectors.jdbc.internal;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.Statement;
-import java.sql.Types;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-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.MySqlConnectionRule;
-
-@Category(IntegrationTest.class)
-public class TableMetaDataManagerMySqlIntegrationTest {
-
-  private static final String DB_NAME = "test";
-  private static final String REGION_TABLE_NAME = "employees";
-
-  private TableMetaDataManager manager;
-  private Connection connection;
-  private Statement statement;
-
-  @ClassRule
-  public static DatabaseConnectionRule dbRule =
-      new 
MySqlConnectionRule.Builder().file("src/test/resources/docker/mysql.yml")
-          .serviceName("db").port(3306).database(DB_NAME).build();
-
-  @Before
-  public void setup() throws Exception {
-    connection = dbRule.getConnection();
-    statement = connection.createStatement();
-    statement.execute("Create Table " + REGION_TABLE_NAME
-        + " (id VARCHAR(10) primary key not null, name VARCHAR(10), age int)");
-    manager = new TableMetaDataManager();
-    DatabaseMetaData data = connection.getMetaData();
-    data.getConnection();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    closeDB();
-  }
-
-  private void closeDB() throws Exception {
-    if (statement == null) {
-      statement = connection.createStatement();
-    }
-    statement.execute("Drop table " + REGION_TABLE_NAME);
-    statement.close();
-
-    if (connection != null) {
-      connection.close();
-    }
-  }
-
-  @Test
-  public void validateKeyColumnName() {
-    TableMetaDataView metaData = manager.getTableMetaDataView(connection, 
REGION_TABLE_NAME);
-
-    String keyColumnName = metaData.getKeyColumnName();
-
-    assertThat(keyColumnName).isEqualToIgnoringCase("id");
-  }
-
-  @Test
-  public void validateColumnDataTypeForName() {
-    TableMetaDataView metaData = manager.getTableMetaDataView(connection, 
REGION_TABLE_NAME);
-
-    int nameDataType = metaData.getColumnDataType("name");
-
-    assertThat(nameDataType).isEqualTo(Types.VARCHAR);
-  }
-
-  @Test
-  public void validateColumnDataTypeForId() {
-    TableMetaDataView metaData = manager.getTableMetaDataView(connection, 
REGION_TABLE_NAME);
-
-    int nameDataType = metaData.getColumnDataType("id");
-
-    assertThat(nameDataType).isEqualTo(Types.VARCHAR);
-  }
-
-  @Test
-  public void validateColumnDataTypeForAge() {
-    TableMetaDataView metaData = manager.getTableMetaDataView(connection, 
REGION_TABLE_NAME);
-
-    int nameDataType = metaData.getColumnDataType("age");
-
-    assertThat(nameDataType).isEqualTo(Types.INTEGER);
-  }
-
-}
diff --git 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TableMetaDataManagerPostgresIntegrationTest.java
 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TableMetaDataManagerPostgresIntegrationTest.java
deleted file mode 100644
index 0538e13..0000000
--- 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/TableMetaDataManagerPostgresIntegrationTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
- * agreements. See the NOTICE file distributed with this work for additional 
information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the 
License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software 
distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
- * or implied. See the License for the specific language governing permissions 
and limitations under
- * the License.
- */
-package org.apache.geode.connectors.jdbc.internal;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.Statement;
-import java.sql.Types;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-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.MySqlConnectionRule;
-import org.apache.geode.test.junit.rules.PostgresConnectionRule;
-
-@Category(IntegrationTest.class)
-public class TableMetaDataManagerPostgresIntegrationTest {
-
-  private static final String DB_NAME = "test";
-  private static final String REGION_TABLE_NAME = "employees";
-
-  private TableMetaDataManager manager;
-  private Connection connection;
-  private Statement statement;
-
-  @ClassRule
-  public static DatabaseConnectionRule dbRule =
-      new 
PostgresConnectionRule.Builder().file("src/test/resources/docker/postgres.yml")
-          .serviceName("db").port(5432).database(DB_NAME).build();
-
-  @Before
-  public void setup() throws Exception {
-    connection = dbRule.getConnection();
-    statement = connection.createStatement();
-    statement.execute("Create Table " + REGION_TABLE_NAME
-        + " (id VARCHAR(10) primary key not null, name VARCHAR(10), age int)");
-    manager = new TableMetaDataManager();
-    DatabaseMetaData data = connection.getMetaData();
-    data.getConnection();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    closeDB();
-  }
-
-  private void closeDB() throws Exception {
-    if (statement == null) {
-      statement = connection.createStatement();
-    }
-    statement.execute("Drop table " + REGION_TABLE_NAME);
-    statement.close();
-
-    if (connection != null) {
-      connection.close();
-    }
-  }
-
-  @Test
-  public void validateKeyColumnName() {
-    TableMetaDataView metaData = manager.getTableMetaDataView(connection, 
REGION_TABLE_NAME);
-
-    String keyColumnName = metaData.getKeyColumnName();
-
-    assertThat(keyColumnName).isEqualToIgnoringCase("id");
-  }
-
-  @Test
-  public void validateColumnDataTypeForName() {
-    TableMetaDataView metaData = manager.getTableMetaDataView(connection, 
REGION_TABLE_NAME);
-
-    int nameDataType = metaData.getColumnDataType("name");
-
-    assertThat(nameDataType).isEqualTo(Types.VARCHAR);
-  }
-
-  @Test
-  public void validateColumnDataTypeForId() {
-    TableMetaDataView metaData = manager.getTableMetaDataView(connection, 
REGION_TABLE_NAME);
-
-    int nameDataType = metaData.getColumnDataType("id");
-
-    assertThat(nameDataType).isEqualTo(Types.VARCHAR);
-  }
-
-  @Test
-  public void validateColumnDataTypeForAge() {
-    TableMetaDataView metaData = manager.getTableMetaDataView(connection, 
REGION_TABLE_NAME);
-
-    int nameDataType = metaData.getColumnDataType("age");
-
-    assertThat(nameDataType).isEqualTo(Types.INTEGER);
-  }
-
-}
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 0bae5fa..bd1c9cf 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
@@ -14,108 +14,11 @@
  */
 package org.apache.geode.test.junit.rules;
 
-import static org.awaitility.Awaitility.matches;
-
-import java.io.IOException;
 import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.SQLException;
-import java.util.concurrent.TimeUnit;
-
-import com.palantir.docker.compose.DockerComposeRule;
-import com.palantir.docker.compose.connection.DockerPort;
-import com.palantir.docker.compose.connection.waiting.HealthChecks;
-import org.awaitility.Awaitility;
-import org.junit.rules.ExternalResource;
-
-public abstract class DatabaseConnectionRule extends ExternalResource {
-
-  private final DockerComposeRule dockerRule;
-  private final String serviceName;
-  private final int port;
-  private final String dbName;
-
-  protected DatabaseConnectionRule(DockerComposeRule dockerRule, String 
serviceName, int port,
-      String dbName) {
-    this.dockerRule = dockerRule;
-    this.serviceName = serviceName;
-    this.port = port;
-    this.dbName = dbName;
-  }
-
-  @Override
-  public void before() throws IOException, InterruptedException {
-    dockerRule.before();
-  }
-
-  @Override
-  public void after() {
-    dockerRule.after();
-  }
-
-  protected DockerPort getDockerPort() {
-    return dockerRule.containers().container(serviceName).port(port);
-  }
-
-  protected String getDbName() {
-    return dbName;
-  }
-
-  public Connection getConnection() throws SQLException {
-    String connectionUrl = getConnectionString();
-    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 static class Builder {
-    private String filePath;
-    private String serviceName;
-    private int port;
-    private String dbName;
-
-    public abstract DatabaseConnectionRule build();
-
-    public Builder file(String filePath) {
-      this.filePath = filePath;
-      return this;
-    }
-
-    public Builder serviceName(String serviceName) {
-      this.serviceName = serviceName;
-      return this;
-    }
-
-    public Builder port(int port) {
-      this.port = port;
-      return this;
-    }
-
-    public Builder database(String dbName) {
-      this.dbName = dbName;
-      return this;
-    }
-
-    protected String getDbName() {
-      return dbName;
-    }
-
-    protected String getServiceName() {
-      return serviceName;
-    }
-
-    protected int getPort() {
-      return port;
-    }
-
-    protected DockerComposeRule createDockerRule() {
-      return DockerComposeRule.builder().file(filePath)
-          .waitingForService(serviceName, 
HealthChecks.toHaveAllPortsOpen()).build();
-    }
 
-  }
+import org.junit.rules.TestRule;
 
+public interface DatabaseConnectionRule extends TestRule {
+  Connection getConnection() throws SQLException;
 }
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/InMemoryDerbyConnectionRule.java
similarity index 50%
copy from 
geode-connectors/src/test/java/org/apache/geode/test/junit/rules/PostgresConnectionRule.java
copy to 
geode-connectors/src/test/java/org/apache/geode/test/junit/rules/InMemoryDerbyConnectionRule.java
index 557d617..299a858 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/InMemoryDerbyConnectionRule.java
@@ -14,32 +14,25 @@
  */
 package org.apache.geode.test.junit.rules;
 
-import com.palantir.docker.compose.DockerComposeRule;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
 
-public class PostgresConnectionRule extends DatabaseConnectionRule {
-  private static final String CONNECTION_STRING =
-      "jdbc:postgresql://$HOST:$EXTERNAL_PORT/%s?user=postgres";
+import org.junit.rules.ExternalResource;
 
-  protected PostgresConnectionRule(DockerComposeRule dockerRule, String 
serviceName, int port,
-      String dbName) {
-    super(dockerRule, serviceName, port, dbName);
-  }
-
-  @Override
-  protected String getConnectionString() {
-    return getDockerPort().inFormat(String.format(CONNECTION_STRING, 
getDbName()));
-  }
+public class InMemoryDerbyConnectionRule extends ExternalResource
+    implements DatabaseConnectionRule {
+  private static final String CONNECTION_URL = 
"jdbc:derby:memory:%s;create=true";
 
-  public static class Builder extends DatabaseConnectionRule.Builder {
+  private final String dbName;
 
-    public Builder() {
-      super();
-    }
+  public InMemoryDerbyConnectionRule(String dbName) {
+    this.dbName = dbName;
+  }
 
-    @Override
-    public PostgresConnectionRule build() {
-      return new PostgresConnectionRule(createDockerRule(), getServiceName(), 
getPort(),
-          getDbName());
-    }
+  @Override
+  public Connection getConnection() throws SQLException {
+    String url = String.format(CONNECTION_URL, dbName);
+    return DriverManager.getConnection(url);
   }
 }
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 4925c6d..8a3d34f 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
@@ -19,7 +19,7 @@ import java.sql.SQLException;
 
 import com.palantir.docker.compose.DockerComposeRule;
 
-public class MySqlConnectionRule extends DatabaseConnectionRule {
+public class MySqlConnectionRule extends SqlDatabaseConnectionRule {
   private static final String CONNECTION_STRING =
       "jdbc:mysql://$HOST:$EXTERNAL_PORT?user=root&useSSL=false";
 
@@ -44,7 +44,7 @@ public class MySqlConnectionRule extends 
DatabaseConnectionRule {
     return getDockerPort().inFormat(CONNECTION_STRING);
   }
 
-  public static class Builder extends DatabaseConnectionRule.Builder {
+  public static class Builder extends SqlDatabaseConnectionRule.Builder {
 
     public Builder() {
       super();
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 557d617..a3d064c 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
@@ -16,7 +16,7 @@ package org.apache.geode.test.junit.rules;
 
 import com.palantir.docker.compose.DockerComposeRule;
 
-public class PostgresConnectionRule extends DatabaseConnectionRule {
+public class PostgresConnectionRule extends SqlDatabaseConnectionRule {
   private static final String CONNECTION_STRING =
       "jdbc:postgresql://$HOST:$EXTERNAL_PORT/%s?user=postgres";
 
@@ -30,7 +30,7 @@ public class PostgresConnectionRule extends 
DatabaseConnectionRule {
     return getDockerPort().inFormat(String.format(CONNECTION_STRING, 
getDbName()));
   }
 
-  public static class Builder extends DatabaseConnectionRule.Builder {
+  public static class Builder extends SqlDatabaseConnectionRule.Builder {
 
     public Builder() {
       super();
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/SqlDatabaseConnectionRule.java
similarity index 93%
copy from 
geode-connectors/src/test/java/org/apache/geode/test/junit/rules/DatabaseConnectionRule.java
copy to 
geode-connectors/src/test/java/org/apache/geode/test/junit/rules/SqlDatabaseConnectionRule.java
index 0bae5fa..2897873 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/SqlDatabaseConnectionRule.java
@@ -28,14 +28,15 @@ import 
com.palantir.docker.compose.connection.waiting.HealthChecks;
 import org.awaitility.Awaitility;
 import org.junit.rules.ExternalResource;
 
-public abstract class DatabaseConnectionRule extends ExternalResource {
+public abstract class SqlDatabaseConnectionRule extends ExternalResource
+    implements DatabaseConnectionRule {
 
   private final DockerComposeRule dockerRule;
   private final String serviceName;
   private final int port;
   private final String dbName;
 
-  protected DatabaseConnectionRule(DockerComposeRule dockerRule, String 
serviceName, int port,
+  protected SqlDatabaseConnectionRule(DockerComposeRule dockerRule, String 
serviceName, int port,
       String dbName) {
     this.dockerRule = dockerRule;
     this.serviceName = serviceName;
@@ -61,6 +62,7 @@ public abstract class DatabaseConnectionRule extends 
ExternalResource {
     return dbName;
   }
 
+  @Override
   public Connection getConnection() throws SQLException {
     String connectionUrl = getConnectionString();
     Awaitility.await().ignoreExceptions().atMost(10, TimeUnit.SECONDS)

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

Reply via email to