@Override
 protected void runApplication(OptionSet options) throws Exception {
   String appVersion = options.valueOf(applicationVersionOption);
   String appName = options.valueOf(applicationNameOption);
   Assert.hasText(appVersion, "Application version must be defined");
   YarnSubmitApplication app = new YarnSubmitApplication();
   if (StringUtils.hasText(appName)) {
     app.applicationName(appName);
   }
   app.applicationVersion(appVersion);
   handleApplicationRun(app);
 }
  @Test
  public void testAppInstallSubmit() throws Exception {

    String ID = "foo-1";
    String BASE = "/apps/";
    setYarnClient(buildYarnClient());

    String[] installAppArgs =
        new String[] {
          "--spring.hadoop.fsUri=" + getConfiguration().get("fs.defaultFS"),
          "--spring.hadoop.resourceManagerAddress="
              + getConfiguration().get("yarn.resourcemanager.address"),
          "--spring.yarn.client.files[0]=file:build/libs/test-install-submit-appmaster-2.0.0.BUILD-SNAPSHOT.jar",
          "--spring.yarn.client.files[1]=file:build/libs/test-install-submit-container-2.0.0.BUILD-SNAPSHOT.jar"
        };
    Properties appProperties = new Properties();
    appProperties.setProperty("spring.yarn.applicationDir", BASE + ID + "/");
    YarnPushApplication installApp = new YarnPushApplication();
    installApp.applicationVersion(ID);
    installApp.applicationBaseDir(BASE);
    installApp.configFile("application.properties", appProperties);
    installApp.run(installAppArgs);
    listFiles();
    catFile(BASE + ID + "/application.properties");

    String rm = getConfiguration().get("yarn.resourcemanager.address");
    String[] split = StringUtils.split(rm, ":");
    String[] submitAppArgs =
        new String[] {
          "--spring.yarn.applicationDir=" + BASE + ID + "/",
          "--spring.hadoop.fsUri=" + getConfiguration().get("fs.defaultFS"),
          "--spring.hadoop.resourceManagerHost=" + split[0],
          "--spring.hadoop.resourceManagerAddress="
              + getConfiguration().get("yarn.resourcemanager.address"),
          "--spring.hadoop.resourceManagerSchedulerAddress="
              + getConfiguration().get("yarn.resourcemanager.scheduler.address")
        };
    YarnSubmitApplication submitApp = new YarnSubmitApplication();
    submitApp.applicationVersion(ID);
    submitApp.applicationBaseDir(BASE);
    ApplicationId applicationId = submitApp.run(submitAppArgs);

    YarnApplicationState state =
        waitState(applicationId, 2, TimeUnit.MINUTES, YarnApplicationState.FINISHED);
    assertThat(state, is(YarnApplicationState.FINISHED));

    List<Resource> resources =
        ContainerLogUtils.queryContainerLogs(getYarnCluster(), applicationId);
    assertThat(resources, notNullValue());
    assertThat(resources.size(), is(6));

    for (Resource res : resources) {
      File file = res.getFile();
      String content = ContainerLogUtils.getFileContent(file);
      if (file.getName().endsWith("stdout")) {
        assertThat(file.length(), greaterThan(0l));
        if (file.getName().equals("Container.stdout")) {
          assertThat(content, containsString("Hello from ActivatorPojo"));
        }
      } else if (file.getName().endsWith("stderr")) {
        assertThat("stderr file is not empty: " + content, file.length(), is(0l));
      }
    }
  }