352684 ensure test harness completes

This commit is contained in:
Greg Wilkins 2011-07-21 22:11:32 +10:00
parent 14bddae71e
commit 676b1a8ffc
1 changed files with 12 additions and 16 deletions

View File

@ -27,6 +27,7 @@ import org.junit.Test;
*/
public class ThreadMonitorTest
{
public final static int DURATION=5000;
private int count;
@Test
@ -49,12 +50,12 @@ public class ThreadMonitorTest
Thread runner = new Thread(spinner);
runner.start();
Thread.sleep(15000);
Thread.sleep(DURATION);
spinner.setDone();
monitor.stop();
assertTrue(count > 10);
assertTrue(count >= 2);
}
@ -73,22 +74,17 @@ public class ThreadMonitorTest
/* ------------------------------------------------------------ */
public void run()
{
while (!done)
long result=-1;
long end=System.currentTimeMillis()+DURATION+1000;
while (!done && System.currentTimeMillis()<end)
{
foo();
for (int i=0;i<1000000000;i++)
result^=i;
}
if (result==42)
System.err.println("Bingo!");
}
private void foo()
{
for (int i=0; i<Integer.MAX_VALUE; i++)
{
long f = 1;
for(int j=1; j<=i; j++)
{
f += j;
}
}
}
}
}