sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2641: SQOOP2: Fix test case failure for repository-postgresql
Date Tue, 27 Oct 2015 17:02:32 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 bc0de7c19 -> b09b897cf


SQOOP-2641: SQOOP2: Fix test case failure for repository-postgresql

(Colin Ma via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/b09b897c
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/b09b897c
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/b09b897c

Branch: refs/heads/sqoop2
Commit: b09b897cf869b391f97c6fd5331d04c2946bb9a2
Parents: bc0de7c
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Tue Oct 27 10:01:53 2015 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Tue Oct 27 10:01:53 2015 -0700

----------------------------------------------------------------------
 repository/repository-postgresql/pom.xml        |  6 ++++++
 .../postgresql/PostgresqlTestCase.java          | 21 ++++++++++++++++++++
 2 files changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/b09b897c/repository/repository-postgresql/pom.xml
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/pom.xml b/repository/repository-postgresql/pom.xml
index bb3859f..6550bc2 100644
--- a/repository/repository-postgresql/pom.xml
+++ b/repository/repository-postgresql/pom.xml
@@ -70,6 +70,12 @@ limitations under the License.
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b09b897c/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
index fbaf5dd..b8b0f52 100644
--- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
+++ b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
@@ -21,12 +21,14 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.sqoop.common.Direction;
 import org.apache.sqoop.common.test.db.DatabaseProvider;
 import org.apache.sqoop.common.test.db.PostgreSQLProvider;
+import org.apache.sqoop.connector.ConnectorManager;
 import org.apache.sqoop.json.DriverBean;
 import org.apache.sqoop.model.*;
 import org.apache.sqoop.repository.postgresql.PostgresqlRepositoryHandler;
 import org.apache.sqoop.submission.SubmissionStatus;
 import org.apache.sqoop.submission.counter.CounterGroup;
 import org.apache.sqoop.submission.counter.Counters;
+import org.mockito.Mockito;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
@@ -44,11 +46,17 @@ abstract public class PostgresqlTestCase {
   public static DatabaseProvider provider;
   public static PostgresqlTestUtils utils;
   public PostgresqlRepositoryHandler handler;
+  private ConnectorManager mockConnectorManager;
 
   @BeforeClass(alwaysRun = true)
   public void setUpClass() {
     provider = new PostgreSQLProvider();
     utils = new PostgresqlTestUtils(provider);
+
+    mockConnectorManager = Mockito.mock(ConnectorManager.class);
+    Mockito.when(mockConnectorManager.getConnectorConfigurable("A")).thenReturn(getConnector(true,
true, "A", "org.apache.sqoop.test.A"));
+    Mockito.when(mockConnectorManager.getConnectorConfigurable("B")).thenReturn(getConnector(true,
true, "B", "org.apache.sqoop.test.B"));
+    ConnectorManager.setInstance(mockConnectorManager);
   }
 
   @BeforeMethod(alwaysRun = true)
@@ -165,4 +173,17 @@ abstract public class PostgresqlTestCase {
 
     return configs;
   }
+
+  protected MConnector getConnector(boolean from, boolean to, String connectorName, String
connectorClass) {
+    MFromConfig fromConfig = null;
+    MToConfig toConfig = null;
+    if (from) {
+      fromConfig = getFromConfig();
+    }
+    if (to) {
+      toConfig = getToConfig();
+    }
+    return new MConnector(connectorName, connectorClass, "1.0-test", getLinkConfig(), fromConfig,
+            toConfig);
+  }
 }
\ No newline at end of file


Mime
View raw message