3345 |
|
() -> CompletableFuture.anyOf(null, f), |
3346 |
|
|
3347 |
|
() -> f.obtrudeException(null), |
3348 |
+ |
|
3349 |
+ |
() -> CompletableFuture.delayedExecutor(1L, SECONDS, null), |
3350 |
+ |
() -> CompletableFuture.delayedExecutor(1L, null, new ThreadExecutor()), |
3351 |
+ |
() -> CompletableFuture.delayedExecutor(1L, null), |
3352 |
+ |
|
3353 |
+ |
() -> f.orTimeout(1L, null), |
3354 |
+ |
() -> f.completeOnTimeout(42, 1L, null), |
3355 |
|
}; |
3356 |
|
|
3357 |
|
assertThrows(NullPointerException.class, throwingActions); |
3372 |
|
* newIncompleteFuture returns an incomplete CompletableFuture |
3373 |
|
*/ |
3374 |
|
public void testNewIncompleteFuture() { |
3375 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
3376 |
+ |
{ |
3377 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3378 |
|
CompletableFuture<Integer> g = f.newIncompleteFuture(); |
3379 |
|
checkIncomplete(f); |
3380 |
|
checkIncomplete(g); |
3381 |
< |
} |
3381 |
> |
f.complete(v1); |
3382 |
> |
checkCompletedNormally(f, v1); |
3383 |
> |
checkIncomplete(g); |
3384 |
> |
g.complete(v1); |
3385 |
> |
checkCompletedNormally(g, v1); |
3386 |
> |
assertSame(g.getClass(), CompletableFuture.class); |
3387 |
> |
}} |
3388 |
|
|
3389 |
|
/** |
3390 |
|
* completedStage returns a completed CompletionStage |
3419 |
|
public void testFailedFuture() { |
3420 |
|
CFException ex = new CFException(); |
3421 |
|
CompletableFuture<Integer> f = CompletableFuture.failedFuture(ex); |
3422 |
< |
checkCompletedExceptionallyWithRootCause(f, ex); |
3422 |
> |
checkCompletedExceptionally(f, ex); |
3423 |
|
} |
3424 |
|
|
3425 |
|
/** |
3426 |
|
* failedFuture(null) throws NPE |
3427 |
|
*/ |
3428 |
< |
public void testFailedFuture2() { |
3428 |
> |
public void testFailedFuture_null() { |
3429 |
|
try { |
3430 |
|
CompletableFuture<Integer> f = CompletableFuture.failedFuture(null); |
3431 |
|
shouldThrow(); |
3507 |
|
AtomicReference<Throwable> r = new AtomicReference<Throwable>(); |
3508 |
|
f.whenComplete((v, e) -> {if (e != null) r.set(e); else x.set(v);}); |
3509 |
|
assertEquals(x.get(), 0); |
3510 |
< |
assertEquals(r.get().getCause(), ex); |
3510 |
> |
assertEquals(r.get(), ex); |
3511 |
|
} |
3512 |
|
|
3513 |
|
/** |