sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject sqoop git commit: SQOOP-3366: Improve unit tests to be able to execute them in a single JVM
Date Fri, 24 Aug 2018 10:29:34 GMT
Repository: sqoop
Updated Branches:
  refs/heads/trunk 0d6c455e5 -> f02158084


SQOOP-3366: Improve unit tests to be able to execute them in a single JVM

(Nguyen Truong via Szabolcs Vasas)


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

Branch: refs/heads/trunk
Commit: f0215808447f40bcddd50b42f48a765d55094273
Parents: 0d6c455
Author: Szabolcs Vasas <vasas@apache.org>
Authored: Fri Aug 24 12:14:08 2018 +0200
Committer: Szabolcs Vasas <vasas@apache.org>
Committed: Fri Aug 24 12:14:08 2018 +0200

----------------------------------------------------------------------
 src/test/org/apache/sqoop/TestIncrementalImport.java           | 1 +
 src/test/org/apache/sqoop/TestSqoopOptions.java                | 2 +-
 .../sqoop/metastore/TestMetastoreConfigurationParameters.java  | 6 ++++--
 src/test/org/apache/sqoop/testutil/BaseSqoopTestCase.java      | 2 ++
 src/test/org/apache/sqoop/testutil/HsqldbTestServer.java       | 4 ++--
 src/test/org/apache/sqoop/tool/TestMainframeImportTool.java    | 5 -----
 6 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/f0215808/src/test/org/apache/sqoop/TestIncrementalImport.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/TestIncrementalImport.java b/src/test/org/apache/sqoop/TestIncrementalImport.java
index e1faf35..29c4779 100644
--- a/src/test/org/apache/sqoop/TestIncrementalImport.java
+++ b/src/test/org/apache/sqoop/TestIncrementalImport.java
@@ -86,6 +86,7 @@ public class TestIncrementalImport  {
 
   public static void resetSourceDataSchema() throws SQLException {
     SqoopOptions options = new SqoopOptions();
+    SqoopOptions.clearNonceDir();
     options.setConnectString(SOURCE_DB_URL);
     options.setUsername(AUTO_STORAGE_USERNAME);
     options.setPassword(AUTO_STORAGE_PASSWORD);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f0215808/src/test/org/apache/sqoop/TestSqoopOptions.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/TestSqoopOptions.java b/src/test/org/apache/sqoop/TestSqoopOptions.java
index d0591ad..e55682e 100644
--- a/src/test/org/apache/sqoop/TestSqoopOptions.java
+++ b/src/test/org/apache/sqoop/TestSqoopOptions.java
@@ -79,7 +79,7 @@ public class TestSqoopOptions {
 
   @Before
   public void setup() {
-    originalSystemProperties = System.getProperties();
+    originalSystemProperties = (Properties)System.getProperties().clone();
     excludedClassesFromClone.add(String.class);
     excludedClassesFromClone.add(Class.class);
     excludedClassesFromClone.add(Integer.class);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f0215808/src/test/org/apache/sqoop/metastore/TestMetastoreConfigurationParameters.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/metastore/TestMetastoreConfigurationParameters.java
b/src/test/org/apache/sqoop/metastore/TestMetastoreConfigurationParameters.java
index 0f1eb89..5a6fac5 100644
--- a/src/test/org/apache/sqoop/metastore/TestMetastoreConfigurationParameters.java
+++ b/src/test/org/apache/sqoop/metastore/TestMetastoreConfigurationParameters.java
@@ -45,6 +45,7 @@ public class TestMetastoreConfigurationParameters {
     private static final String TEST_PASSWORD = "sqoop";
     private static final String DEFAULT_HSQLDB_USER = "SA";
     private static final String NON_DEFAULT_PASSWORD = "NOT_DEFAULT";
+    private static final String DEFAULT_PASSWORD = "";
     private static HsqldbTestServer testHsqldbServer;
 
     private Sqoop sqoop;
@@ -57,7 +58,8 @@ public class TestMetastoreConfigurationParameters {
     }
 
     @AfterClass
-    public static void afterClass() {
+    public static void afterClass() throws SQLException {
+        testHsqldbServer.changePasswordForUser(DEFAULT_HSQLDB_USER, NON_DEFAULT_PASSWORD,
DEFAULT_PASSWORD);
         testHsqldbServer.stop();
     }
 
@@ -99,7 +101,7 @@ public class TestMetastoreConfigurationParameters {
     private static void setupUsersForTesting() throws SQLException {
         // We create a new user and change the password of SA to make sure that Sqoop does
not connect to metastore with the default user and password.
         testHsqldbServer.createNewUser(TEST_USER, TEST_PASSWORD);
-        testHsqldbServer.changePasswordForUser(DEFAULT_HSQLDB_USER, NON_DEFAULT_PASSWORD);
+        testHsqldbServer.changePasswordForUser(DEFAULT_HSQLDB_USER, DEFAULT_PASSWORD, NON_DEFAULT_PASSWORD);
     }
 
     private void verifyMetastoreIsInitialized() throws SQLException {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f0215808/src/test/org/apache/sqoop/testutil/BaseSqoopTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/testutil/BaseSqoopTestCase.java b/src/test/org/apache/sqoop/testutil/BaseSqoopTestCase.java
index 1730698..ad2f10a 100644
--- a/src/test/org/apache/sqoop/testutil/BaseSqoopTestCase.java
+++ b/src/test/org/apache/sqoop/testutil/BaseSqoopTestCase.java
@@ -219,6 +219,8 @@ public abstract class BaseSqoopTestCase {
             CommonArgs.FS_DEFAULT_NAME)));
     incrementTableNum();
 
+    SqoopOptions.clearNonceDir();
+
     if (!isLog4jConfigured) {
       BasicConfigurator.configure();
       isLog4jConfigured = true;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f0215808/src/test/org/apache/sqoop/testutil/HsqldbTestServer.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/testutil/HsqldbTestServer.java b/src/test/org/apache/sqoop/testutil/HsqldbTestServer.java
index c63a8f2..0138608 100644
--- a/src/test/org/apache/sqoop/testutil/HsqldbTestServer.java
+++ b/src/test/org/apache/sqoop/testutil/HsqldbTestServer.java
@@ -285,8 +285,8 @@ public class HsqldbTestServer {
     }
   }
 
-  public void changePasswordForUser(String username, String newPassword) throws SQLException
{
-    try (Connection connection = getConnection(); Statement statement = connection.createStatement())
{
+  public void changePasswordForUser(String username, String oldPassword, String newPassword)
throws SQLException {
+    try (Connection connection = getConnection(username, oldPassword); Statement statement
= connection.createStatement()) {
       statement.executeUpdate(String.format("ALTER USER %s SET PASSWORD %s", username, newPassword));
     }
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f0215808/src/test/org/apache/sqoop/tool/TestMainframeImportTool.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/tool/TestMainframeImportTool.java b/src/test/org/apache/sqoop/tool/TestMainframeImportTool.java
index c2edc53..00e57bd 100644
--- a/src/test/org/apache/sqoop/tool/TestMainframeImportTool.java
+++ b/src/test/org/apache/sqoop/tool/TestMainframeImportTool.java
@@ -55,11 +55,6 @@ public class TestMainframeImportTool extends BaseSqoopTestCase {
     sqoopOption = new SqoopOptions();
   }
 
-  @After
-  public void tearDown() {
-    System.setOut(null);
-  }
-
   @SuppressWarnings("deprecation")
   @Test
   public void testGetImportOptions() throws SecurityException,


Mime
View raw message