1844 |
|
* applyToEither result completes normally after normal completion |
1845 |
|
* of either source |
1846 |
|
*/ |
1847 |
< |
public void testApplyToEither() { |
1848 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
1849 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
1850 |
< |
CompletableFuture<Integer> g = f.applyToEither(f2, inc); |
1851 |
< |
f.complete(one); |
1852 |
< |
checkCompletedNormally(g, two); |
1853 |
< |
f2.complete(one); |
1854 |
< |
checkCompletedNormally(g, two); |
1855 |
< |
|
1856 |
< |
f = new CompletableFuture<>(); |
1857 |
< |
f.complete(one); |
1858 |
< |
f2 = new CompletableFuture<>(); |
1859 |
< |
g = f.applyToEither(f2, inc); |
1860 |
< |
checkCompletedNormally(g, two); |
1847 |
> |
public void testApplyToEither_normalCompletion1() { |
1848 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
1849 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1850 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
1851 |
> |
|
1852 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1853 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1854 |
> |
final IncFunction r = new IncFunction(); |
1855 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1856 |
> |
|
1857 |
> |
f.complete(v1); |
1858 |
> |
checkCompletedNormally(h, inc(v1)); |
1859 |
> |
g.complete(v2); |
1860 |
> |
|
1861 |
> |
checkCompletedNormally(f, v1); |
1862 |
> |
checkCompletedNormally(g, v2); |
1863 |
> |
checkCompletedNormally(h, inc(v1)); |
1864 |
> |
} |
1865 |
> |
} |
1866 |
> |
|
1867 |
> |
public void testApplyToEither_normalCompletion2() { |
1868 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
1869 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1870 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
1871 |
> |
|
1872 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1873 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1874 |
> |
final IncFunction r = new IncFunction(); |
1875 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1876 |
> |
|
1877 |
> |
g.complete(v2); |
1878 |
> |
checkCompletedNormally(h, inc(v2)); |
1879 |
> |
f.complete(v1); |
1880 |
> |
|
1881 |
> |
checkCompletedNormally(f, v1); |
1882 |
> |
checkCompletedNormally(g, v2); |
1883 |
> |
checkCompletedNormally(h, inc(v2)); |
1884 |
> |
} |
1885 |
> |
} |
1886 |
> |
public void testApplyToEither_normalCompletion3() { |
1887 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
1888 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1889 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
1890 |
> |
|
1891 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1892 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1893 |
> |
final IncFunction r = new IncFunction(); |
1894 |
> |
|
1895 |
> |
f.complete(v1); |
1896 |
> |
g.complete(v2); |
1897 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1898 |
> |
|
1899 |
> |
checkCompletedNormally(f, v1); |
1900 |
> |
checkCompletedNormally(g, v2); |
1901 |
> |
|
1902 |
> |
// unspecified behavior |
1903 |
> |
assertTrue(Objects.equals(h.join(), inc(v1)) || |
1904 |
> |
Objects.equals(h.join(), inc(v2))); |
1905 |
> |
} |
1906 |
|
} |
1907 |
|
|
1908 |
|
/** |
1909 |
|
* applyToEither result completes exceptionally after exceptional |
1910 |
|
* completion of either source |
1911 |
|
*/ |
1912 |
< |
public void testApplyToEither2() { |
1913 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
1914 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
1915 |
< |
CompletableFuture<Integer> g = f.applyToEither(f2, inc); |
1916 |
< |
f.completeExceptionally(new CFException()); |
1917 |
< |
f2.complete(one); |
1918 |
< |
checkCompletedWithWrappedCFException(g); |
1912 |
> |
public void testApplyToEither_exceptionalCompletion1() { |
1913 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
1914 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1915 |
> |
|
1916 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1917 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1918 |
> |
final IncFunction r = new IncFunction(); |
1919 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1920 |
> |
final CFException ex = new CFException(); |
1921 |
> |
|
1922 |
> |
f.completeExceptionally(ex); |
1923 |
> |
checkCompletedWithWrappedCFException(h, ex); |
1924 |
> |
g.complete(v1); |
1925 |
> |
|
1926 |
> |
assertFalse(r.ran()); |
1927 |
> |
checkCompletedNormally(g, v1); |
1928 |
> |
checkCompletedWithWrappedCFException(f, ex); |
1929 |
> |
checkCompletedWithWrappedCFException(h, ex); |
1930 |
> |
} |
1931 |
> |
} |
1932 |
> |
|
1933 |
> |
public void testApplyToEither_exceptionalCompletion2() { |
1934 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
1935 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1936 |
> |
|
1937 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1938 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1939 |
> |
final IncFunction r = new IncFunction(); |
1940 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1941 |
> |
final CFException ex = new CFException(); |
1942 |
> |
|
1943 |
> |
g.completeExceptionally(ex); |
1944 |
> |
checkCompletedWithWrappedCFException(h, ex); |
1945 |
> |
f.complete(v1); |
1946 |
> |
|
1947 |
> |
assertFalse(r.ran()); |
1948 |
> |
checkCompletedNormally(f, v1); |
1949 |
> |
checkCompletedWithWrappedCFException(g, ex); |
1950 |
> |
checkCompletedWithWrappedCFException(h, ex); |
1951 |
> |
} |
1952 |
> |
} |
1953 |
> |
|
1954 |
> |
public void testApplyToEither_exceptionalCompletion3() { |
1955 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
1956 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1957 |
> |
|
1958 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1959 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1960 |
> |
final IncFunction r = new IncFunction(); |
1961 |
> |
final CFException ex = new CFException(); |
1962 |
> |
|
1963 |
> |
g.completeExceptionally(ex); |
1964 |
> |
f.complete(v1); |
1965 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1966 |
|
|
1967 |
< |
f = new CompletableFuture<>(); |
1968 |
< |
f2 = new CompletableFuture<>(); |
1969 |
< |
f2.completeExceptionally(new CFException()); |
1970 |
< |
g = f.applyToEither(f2, inc); |
1971 |
< |
checkCompletedWithWrappedCFException(g); |
1967 |
> |
// unspecified behavior |
1968 |
> |
Integer v; |
1969 |
> |
try { |
1970 |
> |
assertEquals(h.join(), inc(v1)); |
1971 |
> |
assertTrue(r.ran()); |
1972 |
> |
} catch (CompletionException ok) { |
1973 |
> |
checkCompletedWithWrappedCFException(h, ex); |
1974 |
> |
assertFalse(r.ran()); |
1975 |
> |
} |
1976 |
> |
|
1977 |
> |
checkCompletedWithWrappedCFException(g, ex); |
1978 |
> |
checkCompletedNormally(f, v1); |
1979 |
> |
} |
1980 |
> |
} |
1981 |
> |
|
1982 |
> |
public void testApplyToEither_exceptionalCompletion4() { |
1983 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
1984 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1985 |
> |
|
1986 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1987 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1988 |
> |
final IncFunction r = new IncFunction(); |
1989 |
> |
final CFException ex = new CFException(); |
1990 |
> |
|
1991 |
> |
f.completeExceptionally(ex); |
1992 |
> |
g.complete(v1); |
1993 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1994 |
> |
|
1995 |
> |
// unspecified behavior |
1996 |
> |
Integer v; |
1997 |
> |
try { |
1998 |
> |
assertEquals(h.join(), inc(v1)); |
1999 |
> |
assertTrue(r.ran()); |
2000 |
> |
} catch (CompletionException ok) { |
2001 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2002 |
> |
assertFalse(r.ran()); |
2003 |
> |
} |
2004 |
> |
|
2005 |
> |
checkCompletedWithWrappedCFException(f, ex); |
2006 |
> |
assertFalse(r.ran()); |
2007 |
> |
checkCompletedNormally(g, v1); |
2008 |
> |
} |
2009 |
|
} |
2010 |
|
|
2011 |
|
/** |
2012 |
|
* applyToEither result completes exceptionally if action does |
2013 |
|
*/ |
2014 |
< |
public void testApplyToEither3() { |
2015 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2016 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2017 |
< |
FailingFunction r = new FailingFunction(); |
2018 |
< |
CompletableFuture<Integer> g = f.applyToEither(f2, r); |
2019 |
< |
f2.complete(two); |
2020 |
< |
checkCompletedWithWrappedCFException(g); |
2014 |
> |
public void testApplyToEither_actionFailed1() { |
2015 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2016 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2017 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2018 |
> |
|
2019 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2020 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2021 |
> |
final FailingFunction r = new FailingFunction(); |
2022 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
2023 |
> |
|
2024 |
> |
f.complete(v1); |
2025 |
> |
checkCompletedWithWrappedCFException(h); |
2026 |
> |
g.complete(v2); |
2027 |
> |
checkCompletedNormally(f, v1); |
2028 |
> |
checkCompletedNormally(g, v2); |
2029 |
> |
} |
2030 |
> |
} |
2031 |
> |
|
2032 |
> |
public void testApplyToEither_actionFailed2() { |
2033 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2034 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2035 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2036 |
> |
|
2037 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2038 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2039 |
> |
final FailingFunction r = new FailingFunction(); |
2040 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
2041 |
> |
|
2042 |
> |
g.complete(v2); |
2043 |
> |
checkCompletedWithWrappedCFException(h); |
2044 |
> |
f.complete(v1); |
2045 |
> |
checkCompletedNormally(f, v1); |
2046 |
> |
checkCompletedNormally(g, v2); |
2047 |
> |
} |
2048 |
|
} |
2049 |
|
|
2050 |
|
/** |
2051 |
|
* applyToEither result completes exceptionally if either source cancelled |
2052 |
|
*/ |
2053 |
< |
public void testApplyToEither4() { |
2054 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2055 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2056 |
< |
CompletableFuture<Integer> g = f.applyToEither(f2, inc); |
2057 |
< |
assertTrue(f.cancel(true)); |
2058 |
< |
checkCompletedWithWrappedCancellationException(g); |
2059 |
< |
f = new CompletableFuture<>(); |
2060 |
< |
f2 = new CompletableFuture<>(); |
2061 |
< |
assertTrue(f2.cancel(true)); |
2062 |
< |
checkCompletedWithWrappedCancellationException(g); |
2053 |
> |
public void testApplyToEither_sourceCancelled1() { |
2054 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2055 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2056 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2057 |
> |
|
2058 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2059 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2060 |
> |
final IncFunction r = new IncFunction(); |
2061 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
2062 |
> |
|
2063 |
> |
assertTrue(f.cancel(mayInterruptIfRunning)); |
2064 |
> |
checkCompletedWithWrappedCancellationException(h); |
2065 |
> |
g.complete(v1); |
2066 |
> |
|
2067 |
> |
checkCancelled(f); |
2068 |
> |
assertFalse(r.ran()); |
2069 |
> |
checkCompletedNormally(g, v1); |
2070 |
> |
checkCompletedWithWrappedCancellationException(h); |
2071 |
> |
} |
2072 |
> |
} |
2073 |
> |
|
2074 |
> |
public void testApplyToEither_sourceCancelled2() { |
2075 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2076 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2077 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2078 |
> |
|
2079 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2080 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2081 |
> |
final IncFunction r = new IncFunction(); |
2082 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
2083 |
> |
|
2084 |
> |
assertTrue(g.cancel(mayInterruptIfRunning)); |
2085 |
> |
checkCompletedWithWrappedCancellationException(h); |
2086 |
> |
f.complete(v1); |
2087 |
> |
|
2088 |
> |
checkCancelled(g); |
2089 |
> |
assertFalse(r.ran()); |
2090 |
> |
checkCompletedNormally(f, v1); |
2091 |
> |
checkCompletedWithWrappedCancellationException(h); |
2092 |
> |
} |
2093 |
> |
} |
2094 |
> |
|
2095 |
> |
public void testApplyToEither_sourceCancelled3() { |
2096 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2097 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2098 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2099 |
> |
|
2100 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2101 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2102 |
> |
final IncFunction r = new IncFunction(); |
2103 |
> |
|
2104 |
> |
assertTrue(g.cancel(mayInterruptIfRunning)); |
2105 |
> |
f.complete(v1); |
2106 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
2107 |
> |
|
2108 |
> |
// unspecified behavior |
2109 |
> |
Integer v; |
2110 |
> |
try { |
2111 |
> |
assertEquals(h.join(), inc(v1)); |
2112 |
> |
assertTrue(r.ran()); |
2113 |
> |
} catch (CompletionException ok) { |
2114 |
> |
checkCompletedWithWrappedCancellationException(h); |
2115 |
> |
assertFalse(r.ran()); |
2116 |
> |
} |
2117 |
> |
|
2118 |
> |
checkCancelled(g); |
2119 |
> |
checkCompletedNormally(f, v1); |
2120 |
> |
} |
2121 |
> |
} |
2122 |
> |
|
2123 |
> |
public void testApplyToEither_sourceCancelled4() { |
2124 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2125 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2126 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2127 |
> |
|
2128 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2129 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2130 |
> |
final IncFunction r = new IncFunction(); |
2131 |
> |
|
2132 |
> |
assertTrue(f.cancel(mayInterruptIfRunning)); |
2133 |
> |
g.complete(v1); |
2134 |
> |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
2135 |
> |
|
2136 |
> |
// unspecified behavior |
2137 |
> |
Integer v; |
2138 |
> |
try { |
2139 |
> |
assertEquals(h.join(), inc(v1)); |
2140 |
> |
assertTrue(r.ran()); |
2141 |
> |
} catch (CompletionException ok) { |
2142 |
> |
checkCompletedWithWrappedCancellationException(h); |
2143 |
> |
assertFalse(r.ran()); |
2144 |
> |
} |
2145 |
> |
|
2146 |
> |
checkCancelled(f); |
2147 |
> |
checkCompletedNormally(g, v1); |
2148 |
> |
} |
2149 |
|
} |
2150 |
|
|
2151 |
|
/** |
2517 |
|
} |
2518 |
|
|
2519 |
|
/** |
2278 |
– |
* applyToEitherAsync result completes normally after normal |
2279 |
– |
* completion of sources |
2280 |
– |
*/ |
2281 |
– |
public void testApplyToEitherAsync() { |
2282 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2283 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2284 |
– |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, inc); |
2285 |
– |
f.complete(one); |
2286 |
– |
checkCompletedNormally(g, two); |
2287 |
– |
|
2288 |
– |
f = new CompletableFuture<>(); |
2289 |
– |
f.complete(one); |
2290 |
– |
f2 = new CompletableFuture<>(); |
2291 |
– |
g = f.applyToEitherAsync(f2, inc); |
2292 |
– |
checkCompletedNormally(g, two); |
2293 |
– |
} |
2294 |
– |
|
2295 |
– |
/** |
2296 |
– |
* applyToEitherAsync result completes exceptionally after exceptional |
2297 |
– |
* completion of source |
2298 |
– |
*/ |
2299 |
– |
public void testApplyToEitherAsync2() { |
2300 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2301 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2302 |
– |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, inc); |
2303 |
– |
f.completeExceptionally(new CFException()); |
2304 |
– |
checkCompletedWithWrappedCFException(g); |
2305 |
– |
|
2306 |
– |
f = new CompletableFuture<>(); |
2307 |
– |
f2 = new CompletableFuture<>(); |
2308 |
– |
f2.completeExceptionally(new CFException()); |
2309 |
– |
g = f.applyToEitherAsync(f2, inc); |
2310 |
– |
f.complete(one); |
2311 |
– |
checkCompletedWithWrappedCFException(g); |
2312 |
– |
} |
2313 |
– |
|
2314 |
– |
/** |
2315 |
– |
* applyToEitherAsync result completes exceptionally if action does |
2316 |
– |
*/ |
2317 |
– |
public void testApplyToEitherAsync3() { |
2318 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2319 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2320 |
– |
FailingFunction r = new FailingFunction(); |
2321 |
– |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, r); |
2322 |
– |
f.complete(one); |
2323 |
– |
checkCompletedWithWrappedCFException(g); |
2324 |
– |
} |
2325 |
– |
|
2326 |
– |
/** |
2327 |
– |
* applyToEitherAsync result completes exceptionally if either source cancelled |
2328 |
– |
*/ |
2329 |
– |
public void testApplyToEitherAsync4() { |
2330 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2331 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2332 |
– |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, inc); |
2333 |
– |
assertTrue(f.cancel(true)); |
2334 |
– |
checkCompletedWithWrappedCancellationException(g); |
2335 |
– |
|
2336 |
– |
f = new CompletableFuture<>(); |
2337 |
– |
f2 = new CompletableFuture<>(); |
2338 |
– |
assertTrue(f2.cancel(true)); |
2339 |
– |
g = f.applyToEitherAsync(f2, inc); |
2340 |
– |
checkCompletedWithWrappedCancellationException(g); |
2341 |
– |
} |
2342 |
– |
|
2343 |
– |
/** |
2520 |
|
* acceptEitherAsync result completes normally after normal |
2521 |
|
* completion of sources |
2522 |
|
*/ |
2889 |
|
checkCompletedWithWrappedCancellationException(g); |
2890 |
|
} |
2891 |
|
|
2716 |
– |
/** |
2717 |
– |
* applyToEitherAsync result completes normally after normal |
2718 |
– |
* completion of sources |
2719 |
– |
*/ |
2720 |
– |
public void testApplyToEitherAsyncE() { |
2721 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2722 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2723 |
– |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, inc, new ThreadExecutor()); |
2724 |
– |
f.complete(one); |
2725 |
– |
checkCompletedNormally(g, two); |
2726 |
– |
|
2727 |
– |
f = new CompletableFuture<>(); |
2728 |
– |
f.complete(one); |
2729 |
– |
f2 = new CompletableFuture<>(); |
2730 |
– |
g = f.applyToEitherAsync(f2, inc, new ThreadExecutor()); |
2731 |
– |
checkCompletedNormally(g, two); |
2732 |
– |
} |
2733 |
– |
|
2734 |
– |
/** |
2735 |
– |
* applyToEitherAsync result completes exceptionally after exceptional |
2736 |
– |
* completion of source |
2737 |
– |
*/ |
2738 |
– |
public void testApplyToEitherAsync2E() { |
2739 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2740 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2741 |
– |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, inc, new ThreadExecutor()); |
2742 |
– |
f.completeExceptionally(new CFException()); |
2743 |
– |
checkCompletedWithWrappedCFException(g); |
2744 |
– |
|
2745 |
– |
f = new CompletableFuture<>(); |
2746 |
– |
f2 = new CompletableFuture<>(); |
2747 |
– |
f2.completeExceptionally(new CFException()); |
2748 |
– |
g = f.applyToEitherAsync(f2, inc, new ThreadExecutor()); |
2749 |
– |
f.complete(one); |
2750 |
– |
checkCompletedWithWrappedCFException(g); |
2751 |
– |
} |
2752 |
– |
|
2753 |
– |
/** |
2754 |
– |
* applyToEitherAsync result completes exceptionally if action does |
2755 |
– |
*/ |
2756 |
– |
public void testApplyToEitherAsync3E() { |
2757 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2758 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2759 |
– |
FailingFunction r = new FailingFunction(); |
2760 |
– |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, r, new ThreadExecutor()); |
2761 |
– |
f.complete(one); |
2762 |
– |
checkCompletedWithWrappedCFException(g); |
2763 |
– |
} |
2764 |
– |
|
2765 |
– |
/** |
2766 |
– |
* applyToEitherAsync result completes exceptionally if either source cancelled |
2767 |
– |
*/ |
2768 |
– |
public void testApplyToEitherAsync4E() { |
2769 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2770 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2771 |
– |
CompletableFuture<Integer> g = f.applyToEitherAsync(f2, inc, new ThreadExecutor()); |
2772 |
– |
assertTrue(f.cancel(true)); |
2773 |
– |
checkCompletedWithWrappedCancellationException(g); |
2774 |
– |
|
2775 |
– |
f = new CompletableFuture<>(); |
2776 |
– |
f2 = new CompletableFuture<>(); |
2777 |
– |
assertTrue(f2.cancel(true)); |
2778 |
– |
g = f.applyToEitherAsync(f2, inc, new ThreadExecutor()); |
2779 |
– |
checkCompletedWithWrappedCancellationException(g); |
2780 |
– |
} |
2781 |
– |
|
2892 |
|
/** |
2893 |
|
* acceptEitherAsync result completes normally after normal |
2894 |
|
* completion of sources |