Make multi-threaded progress meter daemon unit test more robust

This commit is contained in:
Mark DePristo 2013-01-05 12:59:18 -05:00
parent 2ab55e4ee7
commit b403c269e9
1 changed files with 6 additions and 2 deletions

View File

@ -96,7 +96,11 @@ public class ProgressMeterDaemonUnitTest extends BaseTest {
daemon.done();
Assert.assertTrue(daemon.isDone());
Assert.assertEquals(meter.progressCalls.size(), ticks,
"Expected " + ticks + " progress calls from daemon thread, but only got " + meter.progressCalls.size() + " with exact calls " + meter.progressCalls);
Assert.assertTrue(meter.progressCalls.size() >= 1,
"Expected at least one progress update call from daemon thread, but only got " + meter.progressCalls.size() + " with exact calls " + meter.progressCalls);
final int tolerance = (int)Math.ceil(0.8 * meter.progressCalls.size());
Assert.assertTrue(Math.abs(meter.progressCalls.size() - ticks) <= tolerance,
"Expected " + ticks + " progress calls from daemon thread, but got " + meter.progressCalls.size() + " and a tolerance of only " + tolerance);
}
}