Methods Summary |
---|
public static void | main(java.lang.String[] args)
junit.textui.TestRunner.run (suite());
|
public static junit.framework.Test | suite()
return new TestSuite(ExecutorCompletionServiceTest.class);
|
public void | testConstructorNPE()Creating a new ECS with null Executor throw NPE
try {
ExecutorCompletionService ecs = new ExecutorCompletionService(null);
shouldThrow();
} catch (NullPointerException success) {
}
|
public void | testConstructorNPE2()Creating a new ECS with null queue throw NPE
try {
ExecutorService e = Executors.newCachedThreadPool();
ExecutorCompletionService ecs = new ExecutorCompletionService(e, null);
shouldThrow();
} catch (NullPointerException success) {
}
|
public void | testPoll1()If poll returns non-null, the returned task is completed
ExecutorService e = Executors.newCachedThreadPool();
ExecutorCompletionService ecs = new ExecutorCompletionService(e);
try {
assertNull(ecs.poll());
Callable c = new StringTask();
ecs.submit(c);
Thread.sleep(SHORT_DELAY_MS);
for (;;) {
Future f = ecs.poll();
if (f != null) {
assert(f.isDone());
break;
}
}
} catch (Exception ex) {
unexpectedException();
} finally {
joinPool(e);
}
|
public void | testPoll2()If timed poll returns non-null, the returned task is completed
ExecutorService e = Executors.newCachedThreadPool();
ExecutorCompletionService ecs = new ExecutorCompletionService(e);
try {
assertNull(ecs.poll());
Callable c = new StringTask();
ecs.submit(c);
Future f = ecs.poll(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
if (f != null)
assert(f.isDone());
} catch (Exception ex) {
unexpectedException();
} finally {
joinPool(e);
}
|
public void | testSubmitNPE()Submitting a null callable throws NPE
ExecutorService e = Executors.newCachedThreadPool();
ExecutorCompletionService ecs = new ExecutorCompletionService(e);
try {
Callable c = null;
ecs.submit(c);
shouldThrow();
} catch (NullPointerException success) {
} finally {
joinPool(e);
}
|
public void | testSubmitNPE2()Submitting a null runnable throws NPE
ExecutorService e = Executors.newCachedThreadPool();
ExecutorCompletionService ecs = new ExecutorCompletionService(e);
try {
Runnable r = null;
ecs.submit(r, Boolean.TRUE);
shouldThrow();
} catch (NullPointerException success) {
} finally {
joinPool(e);
}
|
public void | testTake()A taken submitted task is completed
ExecutorService e = Executors.newCachedThreadPool();
ExecutorCompletionService ecs = new ExecutorCompletionService(e);
try {
Callable c = new StringTask();
ecs.submit(c);
Future f = ecs.take();
assert(f.isDone());
} catch (Exception ex) {
unexpectedException();
} finally {
joinPool(e);
}
|
public void | testTake2()Take returns the same future object returned by submit
ExecutorService e = Executors.newCachedThreadPool();
ExecutorCompletionService ecs = new ExecutorCompletionService(e);
try {
Callable c = new StringTask();
Future f1 = ecs.submit(c);
Future f2 = ecs.take();
assertSame(f1, f2);
} catch (Exception ex) {
unexpectedException();
} finally {
joinPool(e);
}
|