62 |
|
assertTrue(f.toString().matches(".*\\[.*Not completed.*\\]")); |
63 |
|
try { |
64 |
|
assertNull(f.getNow(null)); |
65 |
< |
} catch (Exception fail) { threadUnexpectedException(fail); } |
65 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
66 |
|
try { |
67 |
|
f.get(randomExpiredTimeout(), randomTimeUnit()); |
68 |
|
shouldThrow(); |
78 |
|
assertEquals(value, f.join()); |
79 |
|
assertEquals(value, f.getNow(null)); |
80 |
|
assertEquals(value, f.get()); |
81 |
< |
} catch (Exception fail) { threadUnexpectedException(fail); } |
81 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
82 |
|
assertTrue(f.isDone()); |
83 |
|
assertFalse(f.isCancelled()); |
84 |
|
assertFalse(f.isCompletedExceptionally()); |
330 |
|
* toString indicates current completion state |
331 |
|
*/ |
332 |
|
public void testToString_incomplete() { |
333 |
< |
CompletableFuture<String> f = new CompletableFuture<String>(); |
333 |
> |
CompletableFuture<String> f = new CompletableFuture<>(); |
334 |
|
assertTrue(f.toString().matches(".*\\[.*Not completed.*\\]")); |
335 |
|
if (testImplementationDetails) |
336 |
|
assertEquals(identityString(f) + "[Not completed]", |
338 |
|
} |
339 |
|
|
340 |
|
public void testToString_normal() { |
341 |
< |
CompletableFuture<String> f = new CompletableFuture<String>(); |
341 |
> |
CompletableFuture<String> f = new CompletableFuture<>(); |
342 |
|
assertTrue(f.complete("foo")); |
343 |
|
assertTrue(f.toString().matches(".*\\[.*Completed normally.*\\]")); |
344 |
|
if (testImplementationDetails) |
347 |
|
} |
348 |
|
|
349 |
|
public void testToString_exception() { |
350 |
< |
CompletableFuture<String> f = new CompletableFuture<String>(); |
350 |
> |
CompletableFuture<String> f = new CompletableFuture<>(); |
351 |
|
assertTrue(f.completeExceptionally(new IndexOutOfBoundsException())); |
352 |
|
assertTrue(f.toString().matches(".*\\[.*Completed exceptionally.*\\]")); |
353 |
|
if (testImplementationDetails) |
357 |
|
|
358 |
|
public void testToString_cancelled() { |
359 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) { |
360 |
< |
CompletableFuture<String> f = new CompletableFuture<String>(); |
360 |
> |
CompletableFuture<String> f = new CompletableFuture<>(); |
361 |
|
assertTrue(f.cancel(mayInterruptIfRunning)); |
362 |
|
assertTrue(f.toString().matches(".*\\[.*Completed exceptionally.*\\]")); |
363 |
|
if (testImplementationDetails) |