MAPREDUCE-4569. Fixed TestHsWebServicesJobsQuery to pass on JDK7 by not depending on test order. Contributed by Thomas Graves.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1379146 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2012-08-30 21:02:55 +00:00
parent 6f6e170325
commit 65e447cd8b
2 changed files with 19 additions and 1 deletions

View File

@ -553,6 +553,9 @@ Release 0.23.3 - UNRELEASED
MAPREDUCE-4375. Show Configuration Tracability in MR UI (bobby
via tgraves)
MAPREDUCE-4569. Fixed TestHsWebServicesJobsQuery to pass on JDK7 by not
depending on test order. (Thomas Graves via vinodkv)
OPTIMIZATIONS
MAPREDUCE-3850. Avoid redundant calls for tokens in TokenCache (Daryn

View File

@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
@ -217,9 +218,23 @@ public class TestHsWebServicesJobsQuery extends JerseyTest {
@Test
public void testJobsQueryStateNone() throws JSONException, Exception {
WebResource r = resource();
ArrayList<JobState> JOB_STATES =
new ArrayList<JobState>(Arrays.asList(JobState.values()));
// find a state that isn't in use
Map<JobId, Job> jobsMap = appContext.getAllJobs();
for (Map.Entry<JobId, Job> entry : jobsMap.entrySet()) {
JOB_STATES.remove(entry.getValue().getState());
}
assertTrue("No unused job states", JOB_STATES.size() > 0);
JobState notInUse = JOB_STATES.get(0);
ClientResponse response = r.path("ws").path("v1").path("history")
.path("mapreduce").path("jobs").queryParam("state", JobState.KILL_WAIT.toString())
.path("mapreduce").path("jobs").queryParam("state", notInUse.toString())
.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
JSONObject json = response.getEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());