geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [geode] branch feature/GEODE-3781 updated: removed some unneeded test code
Date Tue, 31 Oct 2017 01:04:43 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/feature/GEODE-3781 by this push:
     new 722c54f  removed some unneeded test code
722c54f is described below

commit 722c54f6558f4398c820f162b90b45333f503f36
Author: Darrel Schneider <dschneider@pivotal.io>
AuthorDate: Mon Oct 30 18:04:26 2017 -0700

    removed some unneeded test code
---
 .../geode/connectors/jdbc/JDBCManagerUnitTest.java | 48 ++++++----------------
 1 file changed, 12 insertions(+), 36 deletions(-)

diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JDBCManagerUnitTest.java
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JDBCManagerUnitTest.java
index ca5c4ad..daa9822 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JDBCManagerUnitTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JDBCManagerUnitTest.java
@@ -53,38 +53,6 @@ public class JDBCManagerUnitTest {
   private static final String NAME_COLUMN_NAME = "name";
   private static final String AGE_COLUMN_NAME = "age";
 
-  public class TestableJDBCManager extends JDBCManager {
-
-    TestableJDBCManager(JDBCConfiguration config) {
-      super(config);
-    }
-
-    @Override
-    protected Connection createConnection(String url, String user, String password)
-        throws SQLException {
-      ResultSet rsKeys = mock(ResultSet.class);
-      when(rsKeys.next()).thenReturn(true, false);
-      when(rsKeys.getString("COLUMN_NAME")).thenReturn(ID_COLUMN_NAME);
-
-      ResultSet rs = mock(ResultSet.class);
-      when(rs.next()).thenReturn(true, false);
-      when(rs.getString("TABLE_NAME")).thenReturn(regionName.toUpperCase());
-
-      DatabaseMetaData metaData = mock(DatabaseMetaData.class);
-      when(metaData.getPrimaryKeys(null, null, regionName.toUpperCase())).thenReturn(rsKeys);
-      when(metaData.getTables(any(), any(), any(), any())).thenReturn(rs);
-
-      preparedStatement = mock(PreparedStatement.class);
-      when(preparedStatement.getUpdateCount()).thenReturn(1);
-
-      connection = mock(Connection.class);
-      when(connection.getMetaData()).thenReturn(metaData);
-      when(connection.prepareStatement(any())).thenReturn(preparedStatement, null);
-
-      return connection;
-    }
-  }
-
   public class TestableUpsertJDBCManager extends JDBCManager {
 
     final int upsertReturn;
@@ -176,11 +144,19 @@ public class JDBCManagerUnitTest {
   @After
   public void tearDown() throws Exception {}
 
-  private void createManager(String driver, String url) {
-    this.mgr = new TestableJDBCManager(createConfiguration(driver, url));
+  private void createManager(String driver, String url) throws SQLException {
+    ResultSet rsKeys = mock(ResultSet.class);
+    when(rsKeys.next()).thenReturn(true, false);
+    when(rsKeys.getString("COLUMN_NAME")).thenReturn(ID_COLUMN_NAME);
+
+    ResultSet rs = mock(ResultSet.class);
+    when(rs.next()).thenReturn(true, false);
+    when(rs.getString("TABLE_NAME")).thenReturn(regionName.toUpperCase());
+
+    this.mgr = new TestableJDBCManagerWithResultSets(createConfiguration(driver, url), rs,
rsKeys);
   }
 
-  private void createDefaultManager() {
+  private void createDefaultManager() throws SQLException {
     createManager("java.lang.String", "fakeURL");
   }
 
@@ -327,7 +303,7 @@ public class JDBCManagerUnitTest {
   }
 
   @Test
-  public void verifyMissingDriverClass() {
+  public void verifyMissingDriverClass() throws SQLException {
     createManager("non existent driver", "fakeURL");
     catchException(this.mgr).getConnection(null, null);
     assertThat((Exception) caughtException()).isInstanceOf(IllegalStateException.class);

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message