MAPREDUCE-7363. Rename JobClientUnitTest to TestJobClients (#3487)

This commit is contained in:
Dongjoon Hyun 2021-09-28 09:50:01 -07:00 committed by GitHub
parent 1f8f53f7d7
commit f5148ca542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,8 +44,8 @@
import org.junit.Test; import org.junit.Test;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class JobClientUnitTest { public class TestJobClients {
public class TestJobClient extends JobClient { public class TestJobClient extends JobClient {
TestJobClient(JobConf jobConf) throws IOException { TestJobClient(JobConf jobConf) throws IOException {
@ -99,57 +99,57 @@ public void testMapTaskReportsWithNullJob() throws Exception {
Cluster mockCluster = mock(Cluster.class); Cluster mockCluster = mock(Cluster.class);
client.setCluster(mockCluster); client.setCluster(mockCluster);
JobID id = new JobID("test",0); JobID id = new JobID("test",0);
when(mockCluster.getJob(id)).thenReturn(null); when(mockCluster.getJob(id)).thenReturn(null);
TaskReport[] result = client.getMapTaskReports(id); TaskReport[] result = client.getMapTaskReports(id);
assertEquals(0, result.length); assertEquals(0, result.length);
verify(mockCluster).getJob(id); verify(mockCluster).getJob(id);
} }
@Test @Test
public void testReduceTaskReportsWithNullJob() throws Exception { public void testReduceTaskReportsWithNullJob() throws Exception {
TestJobClient client = new TestJobClient(new JobConf()); TestJobClient client = new TestJobClient(new JobConf());
Cluster mockCluster = mock(Cluster.class); Cluster mockCluster = mock(Cluster.class);
client.setCluster(mockCluster); client.setCluster(mockCluster);
JobID id = new JobID("test",0); JobID id = new JobID("test",0);
when(mockCluster.getJob(id)).thenReturn(null); when(mockCluster.getJob(id)).thenReturn(null);
TaskReport[] result = client.getReduceTaskReports(id); TaskReport[] result = client.getReduceTaskReports(id);
assertEquals(0, result.length); assertEquals(0, result.length);
verify(mockCluster).getJob(id); verify(mockCluster).getJob(id);
} }
@Test @Test
public void testSetupTaskReportsWithNullJob() throws Exception { public void testSetupTaskReportsWithNullJob() throws Exception {
TestJobClient client = new TestJobClient(new JobConf()); TestJobClient client = new TestJobClient(new JobConf());
Cluster mockCluster = mock(Cluster.class); Cluster mockCluster = mock(Cluster.class);
client.setCluster(mockCluster); client.setCluster(mockCluster);
JobID id = new JobID("test",0); JobID id = new JobID("test",0);
when(mockCluster.getJob(id)).thenReturn(null); when(mockCluster.getJob(id)).thenReturn(null);
TaskReport[] result = client.getSetupTaskReports(id); TaskReport[] result = client.getSetupTaskReports(id);
assertEquals(0, result.length); assertEquals(0, result.length);
verify(mockCluster).getJob(id); verify(mockCluster).getJob(id);
} }
@Test @Test
public void testCleanupTaskReportsWithNullJob() throws Exception { public void testCleanupTaskReportsWithNullJob() throws Exception {
TestJobClient client = new TestJobClient(new JobConf()); TestJobClient client = new TestJobClient(new JobConf());
Cluster mockCluster = mock(Cluster.class); Cluster mockCluster = mock(Cluster.class);
client.setCluster(mockCluster); client.setCluster(mockCluster);
JobID id = new JobID("test",0); JobID id = new JobID("test",0);
when(mockCluster.getJob(id)).thenReturn(null); when(mockCluster.getJob(id)).thenReturn(null);
TaskReport[] result = client.getCleanupTaskReports(id); TaskReport[] result = client.getCleanupTaskReports(id);
assertEquals(0, result.length); assertEquals(0, result.length);
verify(mockCluster).getJob(id); verify(mockCluster).getJob(id);
} }
@ -184,7 +184,7 @@ public void testShowJob() throws Exception {
when(mockCluster.getJob(jobID)).thenReturn(mockJob); when(mockCluster.getJob(jobID)).thenReturn(mockJob);
client.setCluster(mockCluster); client.setCluster(mockCluster);
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
client.displayJobList(new JobStatus[] {mockJobStatus}, new PrintWriter(out)); client.displayJobList(new JobStatus[] {mockJobStatus}, new PrintWriter(out));
String commandLineOutput = out.toString(); String commandLineOutput = out.toString();