manager.ban(PROXY1);
}
@Test
public void testConcurrentTakeAndBack() throws Exception {
final DefaultProxyManager manager = new DefaultProxyManager(new MockIncrementalGoodHttpProxyNoDelayLoader(), 10, 100, 10, 0);
ExecutorService service = Executors.newFixedThreadPool(20);
Collection<Callable<Object>> tasks = new ArrayList<>();
final AtomicInteger done = new AtomicInteger(0);
final Random random = new Random();
for (int i = 0; i < 100; i++) {
tasks.add(Executors.callable(new Runnable() {
@Override
public void run() {
HttpProxyConfig take = manager.take();
try {
sleep(100);
} catch (InterruptedException ignored) {
}
manager.compliment(take);
take = manager.take();
try {
sleep(100);
} catch (InterruptedException ignored) {
}
if (random.nextBoolean()) {
manager.blame(take);
} else {
manager.ban(take);
}
done.incrementAndGet();
}
}));
}