HADOOP-14666. Tests use assertTrue(....equals(...)) instead of assertEquals()
This commit is contained in:
parent
077fcf6a96
commit
c21c260392
@ -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 void testValidPEM() throws Exception {
|
||||
+ "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");
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public void testDeprecatedKeys() throws Exception {
|
||||
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
|
||||
|
@ -189,8 +189,10 @@ static void checkSpecificProvider(Configuration conf,
|
||||
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 void testJksProvider() throws Exception {
|
||||
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 void checkPermissionRetention(Configuration conf, String ourUrl, Path pat
|
||||
|
||||
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
|
||||
|
@ -320,7 +320,7 @@ class win extends HardLinkCGWin {}
|
||||
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());
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ public void testJksProvider() throws Exception {
|
||||
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 void testLocalJksProvider() throws Exception {
|
||||
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 void checkPermissionRetention(Configuration conf, String ourUrl,
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,18 +187,18 @@ public void testAclString() {
|
||||
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");
|
||||
|
@ -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 void testCheckFailures() throws Throwable {
|
||||
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 void testCheckFailures() throws Throwable {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user