Suppress stacks during sweeper test

This commit is contained in:
Greg Wilkins 2016-07-07 08:32:36 +10:00
parent 8a12915dac
commit 322fe73869
1 changed files with 27 additions and 23 deletions

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.util.thread;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -91,34 +92,37 @@ public class SweeperTest
@Test
public void testSweepThrows() throws Exception
{
long period = 500;
final CountDownLatch taskLatch = new CountDownLatch(2);
Sweeper sweeper = new Sweeper(scheduler, period)
try(StacklessLogging scope = new StacklessLogging(Sweeper.class))
{
@Override
public void run()
long period = 500;
final CountDownLatch taskLatch = new CountDownLatch(2);
Sweeper sweeper = new Sweeper(scheduler, period)
{
super.run();
taskLatch.countDown();
}
};
sweeper.start();
@Override
public void run()
{
super.run();
taskLatch.countDown();
}
};
sweeper.start();
final CountDownLatch sweepLatch = new CountDownLatch(2);
sweeper.offer(new Sweeper.Sweepable()
{
@Override
public boolean sweep()
final CountDownLatch sweepLatch = new CountDownLatch(2);
sweeper.offer(new Sweeper.Sweepable()
{
sweepLatch.countDown();
throw new NullPointerException();
}
});
@Override
public boolean sweep()
{
sweepLatch.countDown();
throw new NullPointerException("Test exception!");
}
});
Assert.assertTrue(sweepLatch.await(4 * period, TimeUnit.MILLISECONDS));
Assert.assertTrue(taskLatch.await(4 * period, TimeUnit.MILLISECONDS));
Assert.assertEquals(1, sweeper.getSize());
Assert.assertTrue(sweepLatch.await(4 * period, TimeUnit.MILLISECONDS));
Assert.assertTrue(taskLatch.await(4 * period, TimeUnit.MILLISECONDS));
Assert.assertEquals(1, sweeper.getSize());
sweeper.stop();
sweeper.stop();
}
}
}