@Test
public void testSingleContainer() throws Exception {

  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
  WebResource r = resource();
  ClientResponse response =
      r.path("ws").path("v1").path("applicationhistory").path("apps")
        .path(appId.toString()).path("appattempts")
        .path(appAttemptId.toString()).path("containers")
        .path(containerId.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());
  JSONObject container = json.getJSONObject("container");
  assertEquals(containerId.toString(), container.getString("containerId"));
  assertEquals(containerId.toString(), container.getString("diagnosticsInfo"));
  assertEquals("0", container.getString("allocatedMB"));
  assertEquals("0", container.getString("allocatedVCores"));
  assertEquals(NodeId.newInstance("localhost", 0).toString(),
    container.getString("assignedNodeId"));
  assertEquals(Priority.newInstance(containerId.getId()).toString(),
    container.getString("priority"));
  Configuration conf = new YarnConfiguration();
  assertEquals(WebAppUtils.getHttpSchemePrefix(conf) +
      WebAppUtils.getAHSWebAppURLWithoutScheme(conf) +
      "/applicationhistory/logs/localhost:0/container_0_0001_01_000001/" +
      "container_0_0001_01_000001/test user",
      container.getString("logUrl"));
  assertEquals(ContainerState.COMPLETE.toString(),
    container.getString("containerState"));
}