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-2625: Sqoop2: Fix test case failure for repository-mysql
Date Tue, 27 Oct 2015 17:17:21 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 b09b897cf -> ecdb8167b


SQOOP-2625: Sqoop2: Fix test case failure for repository-mysql

(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/ecdb8167
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/ecdb8167
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/ecdb8167

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

----------------------------------------------------------------------
 .../sqoop/common/test/db/MySQLProvider.java     |  2 +-
 repository/repository-mysql/pom.xml             |  6 ++-
 .../repository/mysql/MySqlTestCase.java         | 39 ++++++++++++++------
 .../repository/mysql/TestConnectorHandling.java |  4 ++
 .../repository/mysql/TestDriverHandling.java    |  4 ++
 .../repository/mysql/TestHandler.java           |  2 +
 .../repository/mysql/TestJobHandling.java       |  6 +++
 .../repository/mysql/TestLinkHandling.java      |  6 +++
 .../mysql/TestSubmissionHandling.java           |  5 +++
 9 files changed, 60 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/ecdb8167/common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java
----------------------------------------------------------------------
diff --git a/common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java
b/common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java
index cef59bb..268e475 100644
--- a/common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java
+++ b/common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java
@@ -34,7 +34,7 @@ public class MySQLProvider extends DatabaseProvider {
 
   private static final String CONNECTION = System.getProperties().getProperty(
     "sqoop.provider.mysql.jdbc",
-    "jdbc:mysql://localhost/test"
+    "jdbc:mysql://localhost:3306/test?createDatabaseIfNotExist=true&amp;sessionVariables=sql_mode='ANSI_QUOTES'"
   );
 
   private static final String USERNAME = System.getProperties().getProperty(

http://git-wip-us.apache.org/repos/asf/sqoop/blob/ecdb8167/repository/repository-mysql/pom.xml
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/pom.xml b/repository/repository-mysql/pom.xml
index 15e909e..066d76b 100644
--- a/repository/repository-mysql/pom.xml
+++ b/repository/repository-mysql/pom.xml
@@ -61,6 +61,11 @@ limitations under the License.
       <artifactId>mysql-connector-java</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
@@ -106,7 +111,6 @@ limitations under the License.
           <name>mysql</name>
         </property>
       </activation>
-
       <build>
         <plugins>
           <plugin>

http://git-wip-us.apache.org/repos/asf/sqoop/blob/ecdb8167/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
index fcd4b71..232ef4c 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
@@ -22,11 +22,9 @@ import java.util.Date;
 import java.util.LinkedList;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.lang.StringUtils;
-import org.apache.sqoop.common.test.db.DatabaseProvider;
 import org.apache.sqoop.common.test.db.MySQLProvider;
+import org.apache.sqoop.connector.ConnectorManager;
 import org.apache.sqoop.json.DriverBean;
 import org.apache.sqoop.model.InputEditable;
 import org.apache.sqoop.model.MConfig;
@@ -47,23 +45,27 @@ import org.apache.sqoop.repository.mysql.MySqlRepositoryHandler;
 import org.apache.sqoop.submission.SubmissionStatus;
 import org.apache.sqoop.submission.counter.CounterGroup;
 import org.apache.sqoop.submission.counter.Counters;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.*;
+import org.mockito.Mockito;
 
 /**
  * Abstract class with convenience methods for testing mysql repository.
  */
-abstract public class MySqlTestCase extends TestCase {
-
-  public static DatabaseProvider provider;
+abstract public class MySqlTestCase {
+  public static MySQLProvider provider;
   public static MySqlTestUtils utils;
   public MySqlRepositoryHandler handler;
+  private ConnectorManager mockConnectorManager;
 
-  @BeforeClass
-  public void setUpClass() {
+  @BeforeClass(alwaysRun = true)
+  public void setUpClass() throws Exception {
     provider = new MySQLProvider();
     utils = new MySqlTestUtils(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)
@@ -77,7 +79,7 @@ abstract public class MySqlTestCase extends TestCase {
 
   @AfterMethod(alwaysRun = true)
   public void tearDown() throws Exception {
-    provider.dropDatabase("SQOOP");
+    provider.dropDatabase(CommonRepositorySchemaConstants.SCHEMA_SQOOP);
     provider.stop();
   }
 
@@ -184,4 +186,17 @@ abstract public class MySqlTestCase extends TestCase {
 
     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);
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/ecdb8167/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestConnectorHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestConnectorHandling.java
b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestConnectorHandling.java
index 4d30b5e..223217a 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestConnectorHandling.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestConnectorHandling.java
@@ -23,6 +23,10 @@ import org.apache.sqoop.common.test.db.TableName;
 import org.apache.sqoop.model.MConnector;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
 /**
  * Test driver methods on MySql repository.
  */

http://git-wip-us.apache.org/repos/asf/sqoop/blob/ecdb8167/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestDriverHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestDriverHandling.java
b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestDriverHandling.java
index c3144ef..72fefd5 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestDriverHandling.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestDriverHandling.java
@@ -22,6 +22,10 @@ import org.apache.sqoop.common.test.db.TableName;
 import org.apache.sqoop.model.MDriver;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertNotNull;
+
 /**
  * Test driver methods on MySql repository.
  */

http://git-wip-us.apache.org/repos/asf/sqoop/blob/ecdb8167/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestHandler.java
b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestHandler.java
index bfa53bd..5b3f290 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestHandler.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestHandler.java
@@ -20,6 +20,8 @@ package org.apache.sqoop.integration.repository.mysql;
 
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.assertTrue;
+
 /**
  * Test driver methods on MySql repository.
  */

http://git-wip-us.apache.org/repos/asf/sqoop/blob/ecdb8167/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestJobHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestJobHandling.java
b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestJobHandling.java
index 4784f10..7a87fee 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestJobHandling.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestJobHandling.java
@@ -35,6 +35,12 @@ import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
 /**
  * Test driver methods on MySql repository.
  */

http://git-wip-us.apache.org/repos/asf/sqoop/blob/ecdb8167/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestLinkHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestLinkHandling.java
b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestLinkHandling.java
index 2e33cdb..89cfc4e 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestLinkHandling.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestLinkHandling.java
@@ -33,6 +33,12 @@ import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
 /**
  * Test driver methods on MySql repository.
  */

http://git-wip-us.apache.org/repos/asf/sqoop/blob/ecdb8167/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
index faf01cb..b4f34b6 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
@@ -36,6 +36,11 @@ import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
 /**
  * Test driver methods on MySql repository.
  */


Mime
View raw message