/** * check that the assertions pass for the whole duration of the period specified * * @return number of times validation was retried if it failed the first time */ public int check(TimeUnit timeUnit, long count) { int pollPeriodMillis = getPollPeriodMillis(); long startTime = System.currentTimeMillis(); long expireTime = startTime + timeUnit.toMillis(count); int iteration = 0; while(true) { iteration++; try { validate(); } catch (Throwable t) { propagateAsError(t); } sleepUntil(startTime + (pollPeriodMillis * iteration)); if ( System.currentTimeMillis() >= expireTime) { break; } } return iteration; }