private Set<Thread> done;
private int count;
public void testScheduleWork() throws Exception {
DefaultWorkManager workManager = new DefaultWorkManager();
workManager.setScheduledMaximumPoolSize(3);
workManager.init();
int max=workManager.getScheduledMaximumPoolSize()*5;
done=Collections.synchronizedSet(new HashSet<Thread>());
count=0;
CountDownLatch startSignal = new CountDownLatch(1);
CountDownLatch doneSignal = new CountDownLatch(max);
for (int i = 0; i < max; ++i) {
workManager.scheduleWork(new Worker(startSignal, doneSignal));
}
startSignal.countDown();
doneSignal.await();
assertFalse(done.contains(Thread.currentThread()));
assert(done.size()==workManager.getScheduledMaximumPoolSize());
assert(count==max);
done=null;
count=0;
workManager.destroy();
}