36 |
|
import java.util.function.BiFunction; |
37 |
|
import java.util.function.Consumer; |
38 |
|
import java.util.function.Function; |
39 |
+ |
import java.util.function.Predicate; |
40 |
|
import java.util.function.Supplier; |
41 |
|
|
42 |
|
import junit.framework.Test; |
837 |
|
if (!createIncomplete) assertTrue(f.complete(v1)); |
838 |
|
final CompletableFuture<Integer> g = f.exceptionally |
839 |
|
((Throwable t) -> { |
839 |
– |
// Should not be called |
840 |
|
a.getAndIncrement(); |
841 |
< |
throw new AssertionError(); |
841 |
> |
threadFail("should not be called"); |
842 |
> |
return null; // unreached |
843 |
|
}); |
844 |
|
if (createIncomplete) assertTrue(f.complete(v1)); |
845 |
|
|
898 |
|
* whenComplete action executes on normal completion, propagating |
899 |
|
* source result. |
900 |
|
*/ |
901 |
< |
public void testWhenComplete_normalCompletion1() { |
901 |
> |
public void testWhenComplete_normalCompletion() { |
902 |
|
for (ExecutionMode m : ExecutionMode.values()) |
903 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
904 |
|
for (Integer v1 : new Integer[] { 1, null }) |
3704 |
|
if (!testImplementationDetails) return; |
3705 |
|
Function<Method, String> toSignature = |
3706 |
|
(method) -> method.getName() + Arrays.toString(method.getParameterTypes()); |
3707 |
+ |
Predicate<Method> isNotStatic = |
3708 |
+ |
(method) -> (method.getModifiers() & Modifier.STATIC) == 0; |
3709 |
|
List<Method> minimalMethods = |
3710 |
|
Stream.of(Object.class, CompletionStage.class) |
3711 |
< |
.map((klazz) -> Stream.of(klazz.getMethods())) |
3712 |
< |
.reduce(Stream::concat) |
3710 |
< |
.orElseGet(Stream::empty) |
3711 |
< |
.filter((method) -> (method.getModifiers() & Modifier.STATIC) == 0) |
3711 |
> |
.flatMap((klazz) -> Stream.of(klazz.getMethods())) |
3712 |
> |
.filter(isNotStatic) |
3713 |
|
.collect(Collectors.toList()); |
3714 |
|
// Methods from CompletableFuture permitted NOT to throw UOE |
3715 |
|
String[] signatureWhitelist = { |
3723 |
|
Stream.of(signatureWhitelist)) |
3724 |
|
.collect(Collectors.toSet()); |
3725 |
|
List<Method> allMethods = Stream.of(CompletableFuture.class.getMethods()) |
3726 |
< |
.filter((method) -> (method.getModifiers() & Modifier.STATIC) == 0) |
3726 |
> |
.filter(isNotStatic) |
3727 |
|
.filter((method) -> !permittedMethodSignatures.contains(toSignature.apply(method))) |
3728 |
|
.collect(Collectors.toList()); |
3729 |
|
|