more robust test by avoiding sleep

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2018-03-06 14:35:31 +11:00
parent e99f28bc17
commit f6d9393bb5
1 changed files with 9 additions and 3 deletions

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.io;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.eclipse.jetty.util.thread.TimerScheduler;
@ -120,13 +121,18 @@ public class IdleTimeoutTest
@Test
public void testShorten() throws Exception
{
for (int i=0;i<5;i++)
for (int i=0;i<20;i++)
{
Thread.sleep(100);
Thread.sleep(200);
_timeout.notIdle();
}
Assert.assertNull(_expired);
_timeout.setIdleTimeout(100);
Thread.sleep(400);
long start = System.nanoTime();
while (_expired==null && TimeUnit.NANOSECONDS.toSeconds(System.nanoTime()-start)<4)
Thread.sleep(200);
Assert.assertNotNull(_expired);
}