private Build buildJob(String jobPath)
      throws Exception, UnsupportedEncodingException, InterruptedException {
    Job job = null;
    AbstractNode result = client.execute(config.getUrl() + "/job/" + jobPath + "/build?delay=0sec");
    assertTrue(result instanceof ResetNode);
    for (int retryCount = 0;
        !(job = client.getJob(jobPath)).isBuilding() && retryCount < TEST_RETRY_COUNT;
        retryCount++) {
      Thread.sleep(TEST_RETRY_SLEEP);
    }

    return job.builds.get(0);
  }
  @Test
  public void testCanStopBuild() throws Exception {
    Job job = getJobNotBuilding();
    Build build = buildJob(job.path);
    AbstractNode result =
        client.execute(config.getUrl() + "/job/" + job.path + "/" + build.number + "/stop");
    assertTrue(result instanceof ResetNode);
    for (int retryCount = 0;
        (job = client.getJob(job.path)).isBuilding() && retryCount < TEST_RETRY_COUNT;
        retryCount++) {
      Thread.sleep(TEST_RETRY_SLEEP);
    }

    assertEquals("aborted", job.builds.get(0).result.toLowerCase());
  }