From b8e8241854904e3a92b636ffaa6f4c651e47cea2 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Thu, 3 Aug 2017 11:44:34 -0700 Subject: [PATCH] MAPREDUCE-6914. Tests use assertTrue(....equals(...)) instead of assertEquals()). (Daniel Templeton via Yufei Gu) --- .../mapreduce/v2/app/TestJobEndNotifier.java | 16 ++++++++-------- .../v2/app/rm/TestRMContainerAllocator.java | 3 +-- .../java/org/apache/hadoop/mapred/TestQueue.java | 8 ++++---- .../org/apache/hadoop/mapred/TestYARNRunner.java | 8 ++++---- .../mapreduce/lib/input/TestMultipleInputs.java | 10 +++++----- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java index d122a9b2469..5af79d6f73b 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestJobEndNotifier.java @@ -124,20 +124,20 @@ public class TestJobEndNotifier extends JobEndNotifier { proxyToUse.type() == Proxy.Type.DIRECT); conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "somehost:1000"); setConf(conf); - Assert.assertTrue("Proxy should have been set but wasn't ", - proxyToUse.toString().equals("HTTP @ somehost:1000")); + Assert.assertEquals("Proxy should have been set but wasn't ", + "HTTP @ somehost:1000", proxyToUse.toString()); conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "socks@somehost:1000"); setConf(conf); - Assert.assertTrue("Proxy should have been socks but wasn't ", - proxyToUse.toString().equals("SOCKS @ somehost:1000")); + Assert.assertEquals("Proxy should have been socks but wasn't ", + "SOCKS @ somehost:1000", proxyToUse.toString()); conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "SOCKS@somehost:1000"); setConf(conf); - Assert.assertTrue("Proxy should have been socks but wasn't ", - proxyToUse.toString().equals("SOCKS @ somehost:1000")); + Assert.assertEquals("Proxy should have been socks but wasn't ", + "SOCKS @ somehost:1000", proxyToUse.toString()); conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "sfafn@somehost:1000"); setConf(conf); - Assert.assertTrue("Proxy should have been http but wasn't ", - proxyToUse.toString().equals("HTTP @ somehost:1000")); + Assert.assertEquals("Proxy should have been http but wasn't ", + "HTTP @ somehost:1000", proxyToUse.toString()); } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java index bc05c623e2f..6c51626af9d 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java @@ -329,8 +329,7 @@ public class TestRMContainerAllocator { for(TaskAttemptContainerAssignedEvent event : assigned) { if(event.getTaskAttemptID().equals(event3.getAttemptID())) { assigned.remove(event); - Assert.assertTrue( - event.getContainer().getNodeId().getHost().equals("h3")); + Assert.assertEquals("h3", event.getContainer().getNodeId().getHost()); break; } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestQueue.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestQueue.java index fb2d5e0cd1d..796bbee2920 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestQueue.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestQueue.java @@ -74,13 +74,13 @@ public class TestQueue { assertTrue(root.getChildren().size() == 2); Iterator iterator = root.getChildren().iterator(); Queue firstSubQueue = iterator.next(); - assertTrue(firstSubQueue.getName().equals("first")); + assertEquals("first", firstSubQueue.getName()); assertEquals( firstSubQueue.getAcls().get("mapred.queue.first.acl-submit-job") .toString(), "Users [user1, user2] and members of the groups [group1, group2] are allowed"); Queue secondSubQueue = iterator.next(); - assertTrue(secondSubQueue.getName().equals("second")); + assertEquals("second", secondSubQueue.getName()); assertEquals(secondSubQueue.getProperties().getProperty("key"), "value"); assertEquals(secondSubQueue.getProperties().getProperty("key1"), "value1"); // test status @@ -207,13 +207,13 @@ public class TestQueue { assertTrue(root.getChildren().size() == 2); Iterator iterator = root.getChildren().iterator(); Queue firstSubQueue = iterator.next(); - assertTrue(firstSubQueue.getName().equals("first")); + assertEquals("first", firstSubQueue.getName()); assertEquals( firstSubQueue.getAcls().get("mapred.queue.first.acl-submit-job") .toString(), "Users [user1, user2] and members of the groups [group1, group2] are allowed"); Queue secondSubQueue = iterator.next(); - assertTrue(secondSubQueue.getName().equals("second")); + assertEquals("second", secondSubQueue.getName()); assertEquals(firstSubQueue.getState().getStateName(), "running"); assertEquals(secondSubQueue.getState().getStateName(), "stopped"); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestYARNRunner.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestYARNRunner.java index bd3e524d44b..55ddea6da38 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestYARNRunner.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapred/TestYARNRunner.java @@ -871,10 +871,10 @@ public class TestYARNRunner { Configuration confSent = BuilderUtils.parseTokensConf(submissionContext); // configs that match regex should be included - Assert.assertTrue(confSent.get("dfs.namenode.rpc-address.mycluster2.nn1") - .equals("123.0.0.1")); - Assert.assertTrue(confSent.get("dfs.namenode.rpc-address.mycluster2.nn2") - .equals("123.0.0.2")); + Assert.assertEquals("123.0.0.1", + confSent.get("dfs.namenode.rpc-address.mycluster2.nn1")); + Assert.assertEquals("123.0.0.2", + confSent.get("dfs.namenode.rpc-address.mycluster2.nn2")); // configs that aren't matching regex should not be included Assert.assertTrue(confSent.get("hadoop.tmp.dir") == null || !confSent diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/lib/input/TestMultipleInputs.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/lib/input/TestMultipleInputs.java index 632c40e3407..a6f8a725f69 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/lib/input/TestMultipleInputs.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/lib/input/TestMultipleInputs.java @@ -134,11 +134,11 @@ public class TestMultipleInputs extends HadoopTestCase { BufferedReader output = new BufferedReader(new InputStreamReader(fs .open(new Path(outDir, "part-r-00000")))); // reducer should have counted one key from each file - assertTrue(output.readLine().equals("a 2")); - assertTrue(output.readLine().equals("b 2")); - assertTrue(output.readLine().equals("c 2")); - assertTrue(output.readLine().equals("d 2")); - assertTrue(output.readLine().equals("e 2")); + assertEquals("a 2", output.readLine()); + assertEquals("b 2", output.readLine()); + assertEquals("c 2", output.readLine()); + assertEquals("d 2", output.readLine()); + assertEquals("e 2", output.readLine()); } @Test