فهرست منبع

MAPREDUCE-6914. Tests use assertTrue(....equals(...)) instead of assertEquals()). (Daniel Templeton via Yufei Gu)

Yufei Gu 7 سال پیش
والد
کامیت
b8e8241854

+ 8 - 8
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());
     
   }
 

+ 1 - 2
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;
       }
     }

+ 4 - 4
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<Queue> 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<Queue> 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");

+ 4 - 4
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

+ 5 - 5
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