@Override
  public int run(String[] args) throws Exception {
    try {
      webServiceClient = WebServiceClient.getWebServiceClient().createClient();
      return runCommand(args);
    } finally {
      if (yarnClient != null) {
        yarnClient.close();
      }
      if (webServiceClient != null) {
        webServiceClient.destroy();
      }
    }
  }
@Test (timeout = 5000)
  public void testWithNonMatchingEntityIds() throws Exception {
    ApplicationId appId1 = ApplicationId.newInstance(0, 1);
    ApplicationId appId2 = ApplicationId.newInstance(0, 2);
    ApplicationAttemptId appAttemptId1 =
            ApplicationAttemptId.newInstance(appId1, 1);
    ApplicationAttemptId appAttemptId2 =
            ApplicationAttemptId.newInstance(appId2, 1);
    ContainerId containerId0 = ContainerId.newContainerId(appAttemptId1, 0);
    LogsCLI cli = createCli();

    // Non-matching applicationId and applicationAttemptId
    int exitCode = cli.run(new String[] {"-applicationId", appId2.toString(),
        "-applicationAttemptId", appAttemptId1.toString()});
    assertTrue(exitCode == -1);
    assertTrue(sysErrStream.toString().contains(
        "The Application:" + appId2.toString()
            + " does not have the AppAttempt:" + appAttemptId1.toString()));
    sysErrStream.reset();

    // Non-matching applicationId and containerId
    exitCode = cli.run(new String[] {"-applicationId", appId2.toString(),
        "-containerId", containerId0.toString()});
    assertTrue(exitCode == -1);
    assertTrue(sysErrStream.toString().contains(
        "The Application:" + appId2.toString()
            + " does not have the container:" + containerId0.toString()));
    sysErrStream.reset();

    // Non-matching applicationAttemptId and containerId
    exitCode = cli.run(new String[] {"-applicationAttemptId",
            appAttemptId2.toString(), "-containerId", containerId0.toString()});
    assertTrue(exitCode == -1);
    assertTrue(sysErrStream.toString().contains(
        "The AppAttempt:" + appAttemptId2.toString()
            + " does not have the container:" + containerId0.toString()));
    sysErrStream.reset();
  }