// Calculate future time when we stop timeout polling....
long futureTimeMillis = System.currentTimeMillis() + (timeOutSeconds * 1000);
do {
Map<String, String> stateDetails = (Map<String, String>) getJsonResponse(statusURL);
BuildState buildState = BuildState.valueOf(stateDetails.get("state"));
if (buildState.equals(BuildState.COMPLETED)) {
// If we have a status of completed, check result!
buildResultLocation = stateDetails.get("result");
assertNotNull(buildResultLocation);
break;
} else {
assertTrue(buildState.equals(BuildState.NOT_STARTED) || buildState.equals(BuildState.BUILDING));
}
} while (System.currentTimeMillis() < futureTimeMillis);
// If we didn't receive a build response by this time,
// we've given up! Simple build should not take more than