hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From templ...@apache.org
Subject hadoop git commit: HADOOP-14666. Tests use assertTrue(....equals(...)) instead of assertEquals()
Date Wed, 19 Jul 2017 20:59:59 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 077fcf6a9 -> c21c26039


HADOOP-14666. Tests use assertTrue(....equals(...)) instead of assertEquals()


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

Branch: refs/heads/trunk
Commit: c21c26039238f633a0d2df9670f636d026c35649
Parents: 077fcf6
Author: Daniel Templeton <templedf@apache.org>
Authored: Wed Jul 19 13:58:55 2017 -0700
Committer: Daniel Templeton <templedf@apache.org>
Committed: Wed Jul 19 13:58:55 2017 -0700

----------------------------------------------------------------------
 .../authentication/util/TestCertificateUtil.java         |  6 ++++--
 .../java/org/apache/hadoop/conf/TestDeprecatedKeys.java  |  2 +-
 .../apache/hadoop/crypto/key/TestKeyProviderFactory.java | 11 +++++++----
 .../src/test/java/org/apache/hadoop/fs/TestHardLink.java |  2 +-
 .../security/alias/TestCredentialProviderFactory.java    | 10 +++++-----
 .../hadoop/security/authorize/TestAccessControlList.java |  8 ++++----
 .../apache/hadoop/util/TestReadWriteDiskValidator.java   |  5 +++--
 7 files changed, 25 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/c21c2603/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestCertificateUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestCertificateUtil.java
b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestCertificateUtil.java
index ce4176c..5794eb6 100644
--- a/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestCertificateUtil.java
+++ b/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestCertificateUtil.java
@@ -17,6 +17,8 @@
  */
 package org.apache.hadoop.security.authentication.util;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -86,8 +88,8 @@ public class TestCertificateUtil {
         + "Mzc1xA==";
     try {
       RSAPublicKey pk = CertificateUtil.parseRSAPublicKey(pem);
-      assertTrue(pk != null);
-      assertTrue(pk.getAlgorithm().equals("RSA"));
+      assertNotNull(pk);
+      assertEquals("RSA", pk.getAlgorithm());
     } catch (ServletException se) {
       fail("Should not have thrown ServletException");
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c21c2603/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestDeprecatedKeys.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestDeprecatedKeys.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestDeprecatedKeys.java
index 3036d0c..167daa5 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestDeprecatedKeys.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestDeprecatedKeys.java
@@ -35,7 +35,7 @@ public class TestDeprecatedKeys extends TestCase {
     conf.set("topology.script.file.name", "xyz");
     conf.set("topology.script.file.name", "xyz");
     String scriptFile = conf.get(CommonConfigurationKeys.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY);
-    assertTrue(scriptFile.equals("xyz")) ;
+    assertEquals("xyz", scriptFile) ;
   }
   
   //Tests reading / writing a conf file with deprecation after setting

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c21c2603/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyProviderFactory.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyProviderFactory.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyProviderFactory.java
index 53785bc..db30eb0 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyProviderFactory.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyProviderFactory.java
@@ -189,8 +189,10 @@ public class TestKeyProviderFactory {
     assertTrue("Returned Keys should have included key4.", keys.contains("key4"));
 
     List<KeyVersion> kvl = provider.getKeyVersions("key3");
-    assertTrue("KeyVersions should have been returned for key3.", kvl.size() == 1);
-    assertTrue("KeyVersions should have included key3@0.", kvl.get(0).getVersionName().equals("key3@0"));
+    assertEquals("KeyVersions should have been returned for key3.",
+        1, kvl.size());
+    assertEquals("KeyVersions should have included key3@0.",
+        "key3@0", kvl.get(0).getVersionName());
     assertArrayEquals(key3, kvl.get(0).getMaterial());
   }
 
@@ -267,7 +269,7 @@ public class TestKeyProviderFactory {
     Path path = ProviderUtils.unnestUri(new URI(ourUrl));
     FileSystem fs = path.getFileSystem(conf);
     FileStatus s = fs.getFileStatus(path);
-    assertTrue(s.getPermission().toString().equals("rw-------"));
+    assertEquals("rw-------", s.getPermission().toString());
     assertTrue(file + " should exist", file.isFile());
 
     // Corrupt file and Check if JKS can reload from _OLD file
@@ -371,7 +373,8 @@ public class TestKeyProviderFactory {
 
     FileSystem fs = path.getFileSystem(conf);
     FileStatus s = fs.getFileStatus(path);
-    assertTrue("Permissions should have been retained from the preexisting keystore.", s.getPermission().toString().equals("rwxrwxrwx"));
+    assertEquals("Permissions should have been retained from the preexisting "
+        + "keystore.", "rwxrwxrwx", s.getPermission().toString());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c21c2603/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java
index b32b95e..b08e15c 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java
@@ -320,7 +320,7 @@ public class TestHardLink {
     assertEquals(2, ("%f").length()); 
     //make sure "\\%f" was munged correctly
     assertEquals(3, ("\\%f").length()); 
-    assertTrue(win.getLinkCountCommand[1].equals("hardlink"));
+    assertEquals("hardlink", win.getLinkCountCommand[1]);
     //make sure "-c%h" was not munged
     assertEquals(4, ("-c%h").length()); 
   }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c21c2603/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredentialProviderFactory.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredentialProviderFactory.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredentialProviderFactory.java
index 6fa5992..ee7e42c 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredentialProviderFactory.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/alias/TestCredentialProviderFactory.java
@@ -214,7 +214,7 @@ public class TestCredentialProviderFactory {
     Path path = ProviderUtils.unnestUri(new URI(ourUrl));
     FileSystem fs = path.getFileSystem(conf);
     FileStatus s = fs.getFileStatus(path);
-    assertTrue(s.getPermission().toString().equals("rw-------"));
+    assertEquals("rw-------", s.getPermission().toString());
     assertTrue(file + " should exist", file.isFile());
 
     // check permission retention after explicit change
@@ -236,8 +236,8 @@ public class TestCredentialProviderFactory {
     Path path = ProviderUtils.unnestUri(new URI(ourUrl));
     FileSystem fs = path.getFileSystem(conf);
     FileStatus s = fs.getFileStatus(path);
-    assertTrue("Unexpected permissions: " + s.getPermission().toString(),
-        s.getPermission().toString().equals("rw-------"));
+    assertEquals("Unexpected permissions: " + s.getPermission().toString(),
+        "rw-------", s.getPermission().toString());
     assertTrue(file + " should exist", file.isFile());
 
     // check permission retention after explicit change
@@ -267,8 +267,8 @@ public class TestCredentialProviderFactory {
 
     FileSystem fs = path.getFileSystem(conf);
     FileStatus s = fs.getFileStatus(path);
-    assertTrue("Permissions should have been retained from the preexisting " +
-    		"keystore.", s.getPermission().toString().equals("rwxrwxrwx"));
+    assertEquals("Permissions should have been retained from the preexisting " +
+        "keystore.", "rwxrwxrwx", s.getPermission().toString());
   }
 }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c21c2603/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/authorize/TestAccessControlList.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/authorize/TestAccessControlList.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/authorize/TestAccessControlList.java
index 0868381..7039001 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/authorize/TestAccessControlList.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/authorize/TestAccessControlList.java
@@ -187,18 +187,18 @@ public class TestAccessControlList {
     AccessControlList acl;
 
     acl = new AccessControlList("*");
-    assertTrue(acl.toString().equals("All users are allowed"));
+    assertEquals("All users are allowed", acl.toString());
     validateGetAclString(acl);
 
     acl = new AccessControlList(" ");
-    assertTrue(acl.toString().equals("No users are allowed"));
+    assertEquals("No users are allowed", acl.toString());
 
     acl = new AccessControlList("user1,user2");
-    assertTrue(acl.toString().equals("Users [user1, user2] are allowed"));
+    assertEquals("Users [user1, user2] are allowed", acl.toString());
     validateGetAclString(acl);
 
     acl = new AccessControlList("user1,user2 ");// with space
-    assertTrue(acl.toString().equals("Users [user1, user2] are allowed"));
+    assertEquals("Users [user1, user2] are allowed", acl.toString());
     validateGetAclString(acl);
 
     acl = new AccessControlList(" group1,group2");

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c21c2603/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestReadWriteDiskValidator.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestReadWriteDiskValidator.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestReadWriteDiskValidator.java
index 46f4033..b50a73f 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestReadWriteDiskValidator.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestReadWriteDiskValidator.java
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.util;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -125,7 +126,7 @@ public class TestReadWriteDiskValidator {
       readWriteDiskValidator.checkStatus(testDir);
       fail("Disk check should fail.");
     } catch (DiskErrorException e) {
-      assertTrue(e.getMessage().equals("Disk Check failed!"));
+      assertEquals("Disk Check failed!", e.getMessage());
     }
 
     MetricsSource source = ms.getSource(
@@ -137,7 +138,7 @@ public class TestReadWriteDiskValidator {
       readWriteDiskValidator.checkStatus(testDir);
       fail("Disk check should fail.");
     } catch (DiskErrorException e) {
-      assertTrue(e.getMessage().equals("Disk Check failed!"));
+      assertEquals("Disk Check failed!", e.getMessage());
     }
 
     source.getMetrics(collector, true);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message