2856 |
|
* with the value null |
2857 |
|
*/ |
2858 |
|
public void testAllOf_empty() throws Exception { |
2859 |
< |
CompletableFuture<?> f = CompletableFuture.allOf(); |
2859 |
> |
CompletableFuture<Void> f = CompletableFuture.allOf(); |
2860 |
|
checkCompletedNormally(f, null); |
2861 |
|
} |
2862 |
|
|
2863 |
|
/** |
2864 |
< |
* allOf returns a future completed when all components complete |
2864 |
> |
* allOf returns a future completed normally with the value null |
2865 |
> |
* when all components complete normally |
2866 |
|
*/ |
2867 |
< |
public void testAllOf() throws Exception { |
2867 |
> |
public void testAllOf_normal() throws Exception { |
2868 |
|
for (int k = 1; k < 20; ++k) { |
2869 |
|
CompletableFuture<Integer>[] fs = (CompletableFuture<Integer>[]) new CompletableFuture[k]; |
2870 |
|
for (int i = 0; i < k; ++i) |
2872 |
|
CompletableFuture<Void> f = CompletableFuture.allOf(fs); |
2873 |
|
for (int i = 0; i < k; ++i) { |
2874 |
|
checkIncomplete(f); |
2875 |
+ |
checkIncomplete(CompletableFuture.allOf(fs)); |
2876 |
|
fs[i].complete(one); |
2877 |
|
} |
2878 |
|
checkCompletedNormally(f, null); |
2879 |
+ |
checkCompletedNormally(CompletableFuture.allOf(fs), null); |
2880 |
|
} |
2881 |
|
} |
2882 |
|
|
2884 |
|
* anyOf(no component futures) returns an incomplete future |
2885 |
|
*/ |
2886 |
|
public void testAnyOf_empty() throws Exception { |
2887 |
< |
CompletableFuture<?> f = CompletableFuture.anyOf(); |
2887 |
> |
CompletableFuture<Object> f = CompletableFuture.anyOf(); |
2888 |
|
checkIncomplete(f); |
2889 |
|
} |
2890 |
|
|
2891 |
|
/** |
2892 |
< |
* anyOf returns a future completed when any components complete |
2892 |
> |
* anyOf returns a future completed normally with a value when |
2893 |
> |
* a component future does |
2894 |
|
*/ |
2895 |
< |
public void testAnyOf() throws Exception { |
2896 |
< |
for (int k = 1; k < 20; ++k) { |
2895 |
> |
public void testAnyOf_normal() throws Exception { |
2896 |
> |
for (int k = 0; k < 10; ++k) { |
2897 |
|
CompletableFuture[] fs = new CompletableFuture[k]; |
2898 |
|
for (int i = 0; i < k; ++i) |
2899 |
|
fs[i] = new CompletableFuture<>(); |
2902 |
|
for (int i = 0; i < k; ++i) { |
2903 |
|
fs[i].complete(one); |
2904 |
|
checkCompletedNormally(f, one); |
2905 |
+ |
checkCompletedNormally(CompletableFuture.anyOf(fs), one); |
2906 |
+ |
} |
2907 |
+ |
} |
2908 |
+ |
} |
2909 |
+ |
|
2910 |
+ |
/** |
2911 |
+ |
* anyOf result completes exceptionally when any component does. |
2912 |
+ |
*/ |
2913 |
+ |
public void testAnyOf_exceptional() throws Exception { |
2914 |
+ |
for (int k = 0; k < 10; ++k) { |
2915 |
+ |
CompletableFuture[] fs = new CompletableFuture[k]; |
2916 |
+ |
for (int i = 0; i < k; ++i) |
2917 |
+ |
fs[i] = new CompletableFuture<>(); |
2918 |
+ |
CompletableFuture<Object> f = CompletableFuture.anyOf(fs); |
2919 |
+ |
checkIncomplete(f); |
2920 |
+ |
for (int i = 0; i < k; ++i) { |
2921 |
+ |
fs[i].completeExceptionally(new CFException()); |
2922 |
+ |
checkCompletedWithWrappedCFException(f); |
2923 |
+ |
checkCompletedWithWrappedCFException(CompletableFuture.anyOf(fs)); |
2924 |
|
} |
2925 |
|
} |
2926 |
|
} |