sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hshreedha...@apache.org
Subject [1/3] sqoop git commit: SQOOP-1950. Sqoop2: Use TestNG
Date Fri, 09 Jan 2015 00:42:15 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 f073cf693 -> 471e534ef


http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/main/java/org/apache/sqoop/test/asserts/HdfsAsserts.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/asserts/HdfsAsserts.java b/test/src/main/java/org/apache/sqoop/test/asserts/HdfsAsserts.java
index d8f2b8d..adc638a 100644
--- a/test/src/main/java/org/apache/sqoop/test/asserts/HdfsAsserts.java
+++ b/test/src/main/java/org/apache/sqoop/test/asserts/HdfsAsserts.java
@@ -32,8 +32,8 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.Assert.fail;
 
 /**
  * Assert methods suitable for checking HDFS files and directories.

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
index 9a76c4b..e98d091 100644
--- a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
@@ -17,8 +17,8 @@
  */
 package org.apache.sqoop.test.testcases;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.Assert.assertNotSame;
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.mapred.JobConf;
@@ -40,8 +40,8 @@ import org.apache.sqoop.test.data.UbuntuReleases;
 import org.apache.sqoop.test.hadoop.HadoopMiniClusterRunner;
 import org.apache.sqoop.test.hadoop.HadoopRunnerFactory;
 import org.apache.sqoop.validation.Status;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 
 /**
  * Base test case suitable for connector testing.

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/main/java/org/apache/sqoop/test/testcases/KafkaConnectorTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/KafkaConnectorTestCase.java
b/test/src/main/java/org/apache/sqoop/test/testcases/KafkaConnectorTestCase.java
index 804516b..cc6724e 100644
--- a/test/src/main/java/org/apache/sqoop/test/testcases/KafkaConnectorTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/testcases/KafkaConnectorTestCase.java
@@ -22,9 +22,9 @@ import org.apache.sqoop.common.Direction;
 import org.apache.sqoop.model.MConfigList;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MLink;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.testng.annotations.AfterClass;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
 import org.apache.sqoop.common.test.kafka.TestUtil;
 
 import java.io.IOException;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java
index 0b0a0a2..ce74894 100644
--- a/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java
@@ -19,6 +19,7 @@ package org.apache.sqoop.test.testcases;
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.Method;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.fs.FileSystem;
@@ -31,12 +32,10 @@ import org.apache.sqoop.test.hadoop.HadoopRunnerFactory;
 import org.apache.sqoop.test.hadoop.HadoopLocalRunner;
 import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster;
 import org.apache.sqoop.test.utils.HdfsUtils;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.rules.TestName;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeClass;
 
 /**
  * Basic test case that will bootstrap Sqoop server running in external Tomcat
@@ -45,7 +44,7 @@ import org.junit.rules.TestName;
 abstract public class TomcatTestCase {
   private static final Logger LOG = Logger.getLogger(TomcatTestCase.class);
 
-  @Rule public TestName name = new TestName();
+  public String name;
 
   /**
    * Temporary base path that will be used for tests.
@@ -102,10 +101,15 @@ abstract public class TomcatTestCase {
     LOG.debug("HDFS Client: " + hdfsClient);
   }
 
-  @Before
+  @BeforeMethod
+  public void findMethodName(Method method) {
+    name = method.getName();
+  }
+
+  @BeforeMethod
   public void startServer() throws Exception {
     // Get and set temporary path in hadoop cluster.
-    tmpPath = HdfsUtils.joinPathFragments(TMP_PATH_BASE, getClass().getName(), name.getMethodName());
+    tmpPath = HdfsUtils.joinPathFragments(TMP_PATH_BASE, getClass().getName(), name);
     FileUtils.deleteDirectory(new File(tmpPath));
 
     LOG.debug("Temporary Directory: " + tmpPath);
@@ -118,7 +122,7 @@ abstract public class TomcatTestCase {
     client = new SqoopClient(getServerUrl());
   }
 
-  @After
+  @AfterMethod
   public void stopServer() throws Exception {
     cluster.stop();
   }
@@ -171,7 +175,7 @@ abstract public class TomcatTestCase {
    * @return
    */
   public String getMapreduceDirectory() {
-    return HdfsUtils.joinPathFragments(hadoopCluster.getTestDirectory(), getClass().getName(),
name.getMethodName());
+    return HdfsUtils.joinPathFragments(hadoopCluster.getTestDirectory(), getClass().getName(),
name);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
index b1b3b16..f82abc7 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
@@ -23,9 +23,9 @@ import org.apache.sqoop.model.MDriverConfig;
 import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.model.MConfigList;
 import org.apache.sqoop.model.MJob;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
-import static org.junit.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertEquals;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
index e482ac5..85b9d2d 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
@@ -17,7 +17,7 @@
  */
 package org.apache.sqoop.integration.connector.jdbc.generic;
 
-import static org.junit.Assert.assertTrue;
+import static org.testng.Assert.assertTrue;
 
 import org.apache.sqoop.common.Direction;
 import org.apache.sqoop.connector.hdfs.configuration.ToFormat;
@@ -27,7 +27,7 @@ import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.model.MSubmission;
 import org.apache.sqoop.test.testcases.ConnectorTestCase;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
 /**
  * Import simple table with various configurations.

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java
b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java
index bd34911..352fb26 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.sqoop.integration.connector.jdbc.generic;
 
+import com.google.common.collect.Iterables;
 import org.apache.sqoop.common.Direction;
 import org.apache.sqoop.connector.hdfs.configuration.ToFormat;
 import org.apache.sqoop.model.MDriverConfig;
@@ -25,15 +26,15 @@ import org.apache.sqoop.model.MConfigList;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.test.testcases.ConnectorTestCase;
 import org.apache.sqoop.test.utils.ParametrizedUtils;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.Test;
+import org.testng.ITest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Factory;
+import org.testng.annotations.Test;
 
 /**
  *
  */
-@RunWith(Parameterized.class)
-public class PartitionerTest extends ConnectorTestCase {
+public class PartitionerTest extends ConnectorTestCase implements ITest {
 
   /**
    * Columns that we will use as partition column with maximal number of
@@ -54,21 +55,27 @@ public class PartitionerTest extends ConnectorTestCase {
     3, 5, 10, 13,
   };
 
-  @Parameterized.Parameters(name = "{0}-{1}-{2}")
-  public static Iterable<Object[]> data() {
-    return ParametrizedUtils.crossProduct(COLUMNS, EXTRACTORS);
-  }
-
   private String partitionColumn;
   private int maxOutputFiles;
   private int extractors;
 
+  @Factory(dataProvider="partitioner-integration-test")
   public PartitionerTest(String partitionColumn, int expectedOutputFiles, int extractors)
{
     this.partitionColumn = partitionColumn;
     this.maxOutputFiles = expectedOutputFiles;
     this.extractors = extractors;
   }
 
+  @Override
+  public String getTestName() {
+    return "PartitionerTest-" + this.partitionColumn + "-" + this.maxOutputFiles + "-" +
this.extractors;
+  }
+
+  @DataProvider(name="partitioner-integration-test", parallel=true)
+  public static Object[][] data() {
+    return Iterables.toArray(ParametrizedUtils.crossProduct(COLUMNS, EXTRACTORS), Object[].class);
+  }
+
   @Test
   public void testSplitter() throws Exception {
     createAndLoadTableUbuntuReleases();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
index f42fa32..b648870 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
@@ -17,7 +17,7 @@
  */
 package org.apache.sqoop.integration.connector.jdbc.generic;
 
-import static org.junit.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertEquals;
 
 import org.apache.sqoop.common.Direction;
 import org.apache.sqoop.model.MConfigList;
@@ -25,7 +25,7 @@ import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.test.data.Cities;
 import org.apache.sqoop.test.testcases.ConnectorTestCase;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromHDFSToKafkaTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromHDFSToKafkaTest.java
b/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromHDFSToKafkaTest.java
index dabb69d..83273f1 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromHDFSToKafkaTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromHDFSToKafkaTest.java
@@ -21,7 +21,7 @@ import org.apache.sqoop.model.MDriverConfig;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.test.testcases.KafkaConnectorTestCase;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
 
 public class FromHDFSToKafkaTest extends KafkaConnectorTestCase {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromRDBMSToKafkaTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromRDBMSToKafkaTest.java
b/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromRDBMSToKafkaTest.java
index 93d657c..04d2835 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromRDBMSToKafkaTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/kafka/FromRDBMSToKafkaTest.java
@@ -23,7 +23,7 @@ import org.apache.sqoop.model.MDriverConfig;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.test.testcases.KafkaConnectorTestCase;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
 
 public class FromRDBMSToKafkaTest extends KafkaConnectorTestCase {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/test/java/org/apache/sqoop/integration/repository/derby/upgrade/DerbyRepositoryUpgradeTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/repository/derby/upgrade/DerbyRepositoryUpgradeTest.java
b/test/src/test/java/org/apache/sqoop/integration/repository/derby/upgrade/DerbyRepositoryUpgradeTest.java
index 0c25f18..a687c16 100644
--- a/test/src/test/java/org/apache/sqoop/integration/repository/derby/upgrade/DerbyRepositoryUpgradeTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/repository/derby/upgrade/DerbyRepositoryUpgradeTest.java
@@ -22,16 +22,16 @@ import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster;
 import org.apache.sqoop.test.testcases.TomcatTestCase;
 import org.apache.sqoop.test.utils.CompressionUtils;
 import org.apache.sqoop.test.utils.HdfsUtils;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
 import org.apache.log4j.Logger;
 import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
 
 /**
  * Abstract test case for testing upgrade from previous version to the "most recent one".

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
b/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
index 055bc3d..9b3babd 100644
--- a/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
@@ -26,41 +26,39 @@ import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.model.MConfigList;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.test.testcases.ConnectorTestCase;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.Test;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Factory;
+import org.testng.annotations.Test;
 
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 /**
  * Ensure that server will reject starting job when either job itself
  * or corresponding link is disabled.
  */
-@RunWith(Parameterized.class)
 public class SubmissionWithDisabledModelObjectsTest extends ConnectorTestCase {
 
-  @Parameterized.Parameters(name = "con({0}) job({1})")
-  public static Iterable<Object[]> data() {
-    return Arrays.asList(new Object[][]{
-        {true, false},
-        {false, true},
-        {false, false},
-    });
-  }
-
   private boolean enabledLink;
   private boolean enabledJob;
 
+  @Factory(dataProvider="submission-with-disable-model-objects-integration-test")
   public SubmissionWithDisabledModelObjectsTest(boolean enabledLink, boolean enabledJob)
{
     this.enabledLink = enabledLink;
     this.enabledJob = enabledJob;
   }
 
+  @DataProvider(name="submission-with-disable-model-objects-integration-test", parallel=true)
+  public static Object[][] data() {
+    return new Object[][]{
+        {true, false},
+        {false, true},
+        {false, false},
+    };
+  }
+
   @Test
   public void testWithDisabledObjects() throws Exception {
     createAndLoadTableCities();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/test/src/test/java/org/apache/sqoop/integration/server/VersionTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/server/VersionTest.java b/test/src/test/java/org/apache/sqoop/integration/server/VersionTest.java
index b3254bd..a54492e 100644
--- a/test/src/test/java/org/apache/sqoop/integration/server/VersionTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/server/VersionTest.java
@@ -21,9 +21,9 @@ import org.apache.sqoop.client.request.VersionResourceRequest;
 import org.apache.sqoop.common.VersionInfo;
 import org.apache.sqoop.test.testcases.TomcatTestCase;
 import org.apache.sqoop.json.VersionBean;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
-import static org.junit.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertEquals;
 
 /**
  * Basic test to check that server is working and returning correct version info.

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/tomcat/pom.xml
----------------------------------------------------------------------
diff --git a/tomcat/pom.xml b/tomcat/pom.xml
index 91616bb..3eb150b 100644
--- a/tomcat/pom.xml
+++ b/tomcat/pom.xml
@@ -32,8 +32,8 @@ limitations under the License.
   <dependencies>
 
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <groupId>org.testng</groupId>
+      <artifactId>testng</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/471e534e/tools/pom.xml
----------------------------------------------------------------------
diff --git a/tools/pom.xml b/tools/pom.xml
index 01e1a5f..65fd40c 100644
--- a/tools/pom.xml
+++ b/tools/pom.xml
@@ -31,8 +31,8 @@ limitations under the License.
 
   <dependencies>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <groupId>org.testng</groupId>
+      <artifactId>testng</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.sqoop</groupId>


Mime
View raw message