use of java8.util.concurrent.ForkJoinPool in project streamsupport by stefan-zobel.
the class ForkJoinPoolTest method testInvokeAny3.
/**
* invokeAny(c) throws NullPointerException if c has a single null element
*/
public void testInvokeAny3() throws Throwable {
ExecutorService e = new ForkJoinPool(1);
PoolCleaner cleaner = null;
try {
cleaner = cleaner(e);
List<Callable<String>> l = new ArrayList<>();
l.add(null);
try {
e.invokeAny(l);
shouldThrow();
} catch (NullPointerException success) {
}
} finally {
if (cleaner != null) {
cleaner.close();
}
}
}
use of java8.util.concurrent.ForkJoinPool in project streamsupport by stefan-zobel.
the class ForkJoinPoolTest method testSubmitRunnable.
/**
* Completed submit(runnable) returns successfully
*/
public void testSubmitRunnable() throws Throwable {
ExecutorService e = new ForkJoinPool(1);
PoolCleaner cleaner = null;
try {
cleaner = cleaner(e);
Future<?> future = e.submit(new NoOpRunnable());
assertNull(future.get());
assertTrue(future.isDone());
assertFalse(future.isCancelled());
} finally {
if (cleaner != null) {
cleaner.close();
}
}
}
use of java8.util.concurrent.ForkJoinPool in project streamsupport by stefan-zobel.
the class ForkJoinPoolTest method testSubmitAfterShutdown.
/**
* A task submitted after shutdown is rejected
*/
public void testSubmitAfterShutdown() {
ForkJoinPool p = new ForkJoinPool(1);
PoolCleaner cleaner = null;
try {
cleaner = cleaner(p);
p.shutdown();
assertTrue(p.isShutdown());
try {
@SuppressWarnings("unused") ForkJoinTask<Integer> f = p.submit(new FibTask(8));
shouldThrow();
} catch (RejectedExecutionException success) {
}
} finally {
if (cleaner != null) {
cleaner.close();
}
}
}
use of java8.util.concurrent.ForkJoinPool in project streamsupport by stefan-zobel.
the class ForkJoinPoolTest method testTimedInvokeAll4.
/**
* get of returned element of invokeAll(c) throws exception on failed task
*/
public void testTimedInvokeAll4() throws Throwable {
ExecutorService e = new ForkJoinPool(1);
PoolCleaner cleaner = null;
try {
cleaner = cleaner(e);
List<Callable<String>> l = new ArrayList<>();
l.add(new NPETask());
List<Future<String>> futures = e.invokeAll(l, LONG_DELAY_MS, MILLISECONDS);
assertEquals(1, futures.size());
try {
futures.get(0).get();
shouldThrow();
} catch (ExecutionException success) {
assertTrue(success.getCause() instanceof NullPointerException);
}
} finally {
if (cleaner != null) {
cleaner.close();
}
}
}
use of java8.util.concurrent.ForkJoinPool in project streamsupport by stefan-zobel.
the class ForkJoinPoolTest method testTimedInvokeAny2.
/**
* timed invokeAny(empty collection) throws IllegalArgumentException
*/
public void testTimedInvokeAny2() throws Throwable {
ExecutorService e = new ForkJoinPool(1);
PoolCleaner cleaner = null;
try {
cleaner = cleaner(e);
try {
e.invokeAny(new ArrayList<Callable<String>>(), randomTimeout(), randomTimeUnit());
shouldThrow();
} catch (IllegalArgumentException success) {
}
} finally {
if (cleaner != null) {
cleaner.close();
}
}
}
Aggregations