ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/CompletableFutureTest.java
(Generate patch)

Comparing jsr166/src/test/tck/CompletableFutureTest.java (file contents):
Revision 1.49 by jsr166, Mon Jun 2 19:20:51 2014 UTC vs.
Revision 1.52 by jsr166, Mon Jun 2 20:10:04 2014 UTC

# Line 416 | Line 416 | public class CompletableFutureTest exten
416              throw new CFException();
417          }
418      }
419 <    static final class FailingNoop implements Runnable {
419 >    static final class FailingRunnable implements Runnable {
420          int invocationCount = 0;
421          public void run() {
422              invocationCount++;
# Line 933 | Line 933 | public class CompletableFutureTest exten
933       * failing runAsync completes exceptionally after running Runnable
934       */
935      public void testRunAsync3() {
936 <        FailingNoop r = new FailingNoop();
936 >        FailingRunnable r = new FailingRunnable();
937          CompletableFuture<Void> f = CompletableFuture.runAsync(r);
938          checkCompletedWithWrappedCFException(f);
939          assertEquals(1, r.invocationCount);
# Line 983 | Line 983 | public class CompletableFutureTest exten
983          final Noop r = new Noop();
984          if (!createIncomplete) f.complete(v1);
985          final CompletableFuture<Void> g = m.thenRun(f, r);
986 <        if (createIncomplete) f.complete(v1);
986 >        if (createIncomplete) {
987 >            checkIncomplete(g);
988 >            f.complete(v1);
989 >        }
990  
991          checkCompletedNormally(g, null);
992          checkCompletedNormally(f, v1);
# Line 1003 | Line 1006 | public class CompletableFutureTest exten
1006          final Noop r = new Noop();
1007          if (!createIncomplete) f.completeExceptionally(ex);
1008          final CompletableFuture<Void> g = m.thenRun(f, r);
1009 <        if (createIncomplete) f.completeExceptionally(ex);
1009 >        if (createIncomplete) {
1010 >            checkIncomplete(g);
1011 >            f.completeExceptionally(ex);
1012 >        }
1013  
1014          checkCompletedWithWrappedCFException(g, ex);
1015          checkCompletedWithWrappedCFException(f, ex);
# Line 1022 | Line 1028 | public class CompletableFutureTest exten
1028          final Noop r = new Noop();
1029          if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1030          final CompletableFuture<Void> g = f.thenRun(r);
1031 <        if (createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1031 >        if (createIncomplete) {
1032 >            checkIncomplete(g);
1033 >            assertTrue(f.cancel(mayInterruptIfRunning));
1034 >        }
1035  
1036          checkCompletedWithWrappedCancellationException(g);
1037          checkCancelled(f);
# Line 1038 | Line 1047 | public class CompletableFutureTest exten
1047          for (Integer v1 : new Integer[] { 1, null })
1048      {
1049          final CompletableFuture<Integer> f = new CompletableFuture<>();
1050 <        final FailingNoop r = new FailingNoop();
1050 >        final FailingRunnable r = new FailingRunnable();
1051          if (!createIncomplete) f.complete(v1);
1052          final CompletableFuture<Void> g = f.thenRun(r);
1053 <        if (createIncomplete) f.complete(v1);
1053 >        if (createIncomplete) {
1054 >            checkIncomplete(g);
1055 >            f.complete(v1);
1056 >        }
1057  
1058          checkCompletedWithWrappedCFException(g);
1059          checkCompletedNormally(f, v1);
# Line 1082 | Line 1094 | public class CompletableFutureTest exten
1094          final IncFunction r = new IncFunction();
1095          if (!createIncomplete) f.completeExceptionally(ex);
1096          final CompletableFuture<Integer> g = m.thenApply(f, r);
1097 <        if (createIncomplete) f.completeExceptionally(ex);
1097 >        if (createIncomplete) {
1098 >            checkIncomplete(g);
1099 >            f.completeExceptionally(ex);
1100 >        }
1101  
1102          checkCompletedWithWrappedCFException(g, ex);
1103          checkCompletedWithWrappedCFException(f, ex);
# Line 1101 | Line 1116 | public class CompletableFutureTest exten
1116          final IncFunction r = new IncFunction();
1117          if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1118          final CompletableFuture<Integer> g = f.thenApply(r);
1119 <        if (createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1119 >        if (createIncomplete) {
1120 >            checkIncomplete(g);
1121 >            assertTrue(f.cancel(mayInterruptIfRunning));
1122 >        }
1123  
1124          checkCompletedWithWrappedCancellationException(g);
1125          checkCancelled(f);
# Line 1120 | Line 1138 | public class CompletableFutureTest exten
1138          final FailingFunction r = new FailingFunction();
1139          if (!createIncomplete) f.complete(v1);
1140          final CompletableFuture<Integer> g = f.thenApply(r);
1141 <        if (createIncomplete) f.complete(v1);
1141 >        if (createIncomplete) {
1142 >            checkIncomplete(g);
1143 >            f.complete(v1);
1144 >        }
1145  
1146          checkCompletedWithWrappedCFException(g);
1147          checkCompletedNormally(f, v1);
# Line 1129 | Line 1150 | public class CompletableFutureTest exten
1150      /**
1151       * thenAccept result completes normally after normal completion of source
1152       */
1153 <    public void testThenAccept() {
1154 <        CompletableFuture<Integer> f = new CompletableFuture<>();
1155 <        IncAction r = new IncAction();
1156 <        CompletableFuture<Void> g = f.thenAccept(r);
1157 <        f.complete(one);
1153 >    public void testThenAccept_normalCompletion() {
1154 >        for (ExecutionMode m : ExecutionMode.values())
1155 >        for (boolean createIncomplete : new boolean[] { true, false })
1156 >        for (Integer v1 : new Integer[] { 1, null })
1157 >    {
1158 >        final CompletableFuture<Integer> f = new CompletableFuture<>();
1159 >        final IncAction r = new IncAction();
1160 >        if (!createIncomplete) f.complete(v1);
1161 >        final CompletableFuture<Void> g = m.thenAccept(f, r);
1162 >        if (createIncomplete) {
1163 >            checkIncomplete(g);
1164 >            f.complete(v1);
1165 >        }
1166 >
1167          checkCompletedNormally(g, null);
1168 <        assertEquals(r.value, (Integer) 2);
1169 <    }
1168 >        checkCompletedNormally(f, v1);
1169 >        assertEquals(1, r.invocationCount);
1170 >        assertEquals(inc(v1), r.value);
1171 >    }}
1172  
1173      /**
1174       * thenAccept result completes exceptionally after exceptional
1175       * completion of source
1176       */
1177 <    public void testThenAccept2() {
1178 <        CompletableFuture<Integer> f = new CompletableFuture<>();
1179 <        IncAction r = new IncAction();
1180 <        CompletableFuture<Void> g = f.thenAccept(r);
1181 <        f.completeExceptionally(new CFException());
1182 <        checkCompletedWithWrappedCFException(g);
1183 <    }
1177 >    public void testThenAccept_exceptionalCompletion() {
1178 >        for (ExecutionMode m : ExecutionMode.values())
1179 >        for (boolean createIncomplete : new boolean[] { true, false })
1180 >    {
1181 >        final CFException ex = new CFException();
1182 >        final CompletableFuture<Integer> f = new CompletableFuture<>();
1183 >        final IncAction r = new IncAction();
1184 >        if (!createIncomplete) f.completeExceptionally(ex);
1185 >        final CompletableFuture<Void> g = m.thenAccept(f, r);
1186 >        if (createIncomplete) {
1187 >            checkIncomplete(g);
1188 >            f.completeExceptionally(ex);
1189 >        }
1190 >
1191 >        checkCompletedWithWrappedCFException(g, ex);
1192 >        checkCompletedWithWrappedCFException(f, ex);
1193 >        assertEquals(0, r.invocationCount);
1194 >    }}
1195  
1196      /**
1197       * thenAccept result completes exceptionally if action does
1198       */
1199 <    public void testThenAccept3() {
1200 <        CompletableFuture<Integer> f = new CompletableFuture<>();
1201 <        FailingConsumer r = new FailingConsumer();
1202 <        CompletableFuture<Void> g = f.thenAccept(r);
1203 <        f.complete(one);
1199 >    public void testThenAccept_actionFailed() {
1200 >        for (ExecutionMode m : ExecutionMode.values())
1201 >        for (boolean createIncomplete : new boolean[] { true, false })
1202 >        for (Integer v1 : new Integer[] { 1, null })
1203 >    {
1204 >        final CompletableFuture<Integer> f = new CompletableFuture<>();
1205 >        final FailingConsumer r = new FailingConsumer();
1206 >        if (!createIncomplete) f.complete(v1);
1207 >        final CompletableFuture<Void> g = f.thenAccept(r);
1208 >        if (createIncomplete) {
1209 >            checkIncomplete(g);
1210 >            f.complete(v1);
1211 >        }
1212 >
1213          checkCompletedWithWrappedCFException(g);
1214 <        assertEquals(1, r.invocationCount);
1215 <    }
1214 >        checkCompletedNormally(f, v1);
1215 >    }}
1216  
1217      /**
1218       * thenAccept result completes exceptionally if source cancelled
1219       */
1220 <    public void testThenAccept4() {
1221 <        CompletableFuture<Integer> f = new CompletableFuture<>();
1222 <        IncAction r = new IncAction();
1223 <        CompletableFuture<Void> g = f.thenAccept(r);
1224 <        assertTrue(f.cancel(true));
1220 >    public void testThenAccept_sourceCancelled() {
1221 >        for (ExecutionMode m : ExecutionMode.values())
1222 >        for (boolean createIncomplete : new boolean[] { true, false })
1223 >        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1224 >    {
1225 >        final CompletableFuture<Integer> f = new CompletableFuture<>();
1226 >        final IncAction r = new IncAction();
1227 >        if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1228 >        final CompletableFuture<Void> g = f.thenAccept(r);
1229 >        if (createIncomplete) {
1230 >            checkIncomplete(g);
1231 >            assertTrue(f.cancel(mayInterruptIfRunning));
1232 >        }
1233 >
1234          checkCompletedWithWrappedCancellationException(g);
1235 <    }
1235 >        checkCancelled(f);
1236 >        assertEquals(0, r.invocationCount);
1237 >    }}
1238  
1239      /**
1240       * thenCombine result completes normally after normal completion
1241       * of sources
1242       */
1243 <    public void testThenCombine_normalCompletion1() {
1243 >    public void testThenCombine_normalCompletion() {
1244 >        for (ExecutionMode m : ExecutionMode.values())
1245          for (boolean createIncomplete : new boolean[] { true, false })
1246          for (boolean fFirst : new boolean[] { true, false })
1183        for (ExecutionMode m : ExecutionMode.values())
1247          for (Integer v1 : new Integer[] { 1, null })
1248          for (Integer v2 : new Integer[] { 2, null })
1249      {
1250          final CompletableFuture<Integer> f = new CompletableFuture<>();
1251          final CompletableFuture<Integer> g = new CompletableFuture<>();
1252          final SubtractFunction r = new SubtractFunction();
1190        CompletableFuture<Integer> h = null;
1191        if (createIncomplete) h = m.thenCombine(f, g, r);
1253  
1254 <        if (fFirst)
1255 <            f.complete(v1);
1256 <        else
1257 <            g.complete(v2);
1258 <        if (createIncomplete) checkIncomplete(h);
1259 <        assertEquals(0, r.invocationCount);
1260 <        if (!fFirst)
1261 <            f.complete(v1);
1262 <        else
1202 <            g.complete(v2);
1203 <        if (!createIncomplete) h = m.thenCombine(f, g, r);
1254 >        if (fFirst) f.complete(v1); else g.complete(v2);
1255 >        if (!createIncomplete)
1256 >            if (!fFirst) f.complete(v1); else g.complete(v2);
1257 >        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1258 >        if (createIncomplete) {
1259 >            checkIncomplete(h);
1260 >            assertEquals(0, r.invocationCount);
1261 >            if (!fFirst) f.complete(v1); else g.complete(v2);
1262 >        }
1263  
1264          checkCompletedNormally(h, subtract(v1, v2));
1265          checkCompletedNormally(f, v1);
# Line 1212 | Line 1271 | public class CompletableFutureTest exten
1271       * thenCombine result completes exceptionally after exceptional
1272       * completion of either source
1273       */
1274 <    public void testThenCombine_exceptionalCompletion1() {
1216 <        for (ExecutionMode m : ExecutionMode.values())
1217 <        for (Integer v1 : new Integer[] { 1, null })
1218 <    {
1219 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1220 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1221 <        final SubtractFunction r = new SubtractFunction();
1222 <        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1223 <        final CFException ex = new CFException();
1224 <
1225 <        f.completeExceptionally(ex);
1226 <        checkIncomplete(h);
1227 <        g.complete(v1);
1228 <
1229 <        checkCompletedWithWrappedCFException(h, ex);
1230 <        checkCompletedWithWrappedCFException(f, ex);
1231 <        assertEquals(0, r.invocationCount);
1232 <        checkCompletedNormally(g, v1);
1233 <    }}
1234 <
1235 <    public void testThenCombine_exceptionalCompletion2() {
1236 <        for (ExecutionMode m : ExecutionMode.values())
1237 <        for (Integer v1 : new Integer[] { 1, null })
1238 <    {
1239 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1240 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1241 <        final SubtractFunction r = new SubtractFunction();
1242 <        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1243 <        final CFException ex = new CFException();
1244 <
1245 <        g.completeExceptionally(ex);
1246 <        checkIncomplete(h);
1247 <        f.complete(v1);
1248 <
1249 <        checkCompletedWithWrappedCFException(h, ex);
1250 <        checkCompletedWithWrappedCFException(g, ex);
1251 <        assertEquals(0, r.invocationCount);
1252 <        checkCompletedNormally(f, v1);
1253 <    }}
1254 <
1255 <    public void testThenCombine_exceptionalCompletion3() {
1274 >    public void testThenCombine_exceptionalCompletion() {
1275          for (ExecutionMode m : ExecutionMode.values())
1276 +        for (boolean createIncomplete : new boolean[] { true, false })
1277 +        for (boolean fFirst : new boolean[] { true, false })
1278          for (Integer v1 : new Integer[] { 1, null })
1279      {
1280          final CompletableFuture<Integer> f = new CompletableFuture<>();
1281          final CompletableFuture<Integer> g = new CompletableFuture<>();
1261        final SubtractFunction r = new SubtractFunction();
1282          final CFException ex = new CFException();
1263
1264        g.completeExceptionally(ex);
1265        f.complete(v1);
1266        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1267
1268        checkCompletedWithWrappedCFException(h, ex);
1269        checkCompletedWithWrappedCFException(g, ex);
1270        assertEquals(0, r.invocationCount);
1271        checkCompletedNormally(f, v1);
1272    }}
1273
1274    public void testThenCombine_exceptionalCompletion4() {
1275        for (ExecutionMode m : ExecutionMode.values())
1276        for (Integer v1 : new Integer[] { 1, null })
1277    {
1278        final CompletableFuture<Integer> f = new CompletableFuture<>();
1279        final CompletableFuture<Integer> g = new CompletableFuture<>();
1283          final SubtractFunction r = new SubtractFunction();
1281        final CFException ex = new CFException();
1284  
1285 <        f.completeExceptionally(ex);
1286 <        g.complete(v1);
1285 >        (fFirst ? f : g).complete(v1);
1286 >        if (!createIncomplete)
1287 >            (!fFirst ? f : g).completeExceptionally(ex);
1288          final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1289 +        if (createIncomplete) {
1290 +            checkIncomplete(h);
1291 +            (!fFirst ? f : g).completeExceptionally(ex);
1292 +        }
1293  
1294          checkCompletedWithWrappedCFException(h, ex);
1288        checkCompletedWithWrappedCFException(f, ex);
1295          assertEquals(0, r.invocationCount);
1296 <        checkCompletedNormally(g, v1);
1296 >        checkCompletedNormally(fFirst ? f : g, v1);
1297 >        checkCompletedWithWrappedCFException(!fFirst ? f : g, ex);
1298      }}
1299  
1300      /**
1301       * thenCombine result completes exceptionally if action does
1302       */
1303 <    public void testThenCombine_actionFailed1() {
1297 <        for (ExecutionMode m : ExecutionMode.values())
1298 <        for (Integer v1 : new Integer[] { 1, null })
1299 <        for (Integer v2 : new Integer[] { 2, null })
1300 <    {
1301 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1302 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1303 <        final FailingBiFunction r = new FailingBiFunction();
1304 <        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1305 <
1306 <        f.complete(v1);
1307 <        checkIncomplete(h);
1308 <        g.complete(v2);
1309 <
1310 <        checkCompletedWithWrappedCFException(h);
1311 <        checkCompletedNormally(f, v1);
1312 <        checkCompletedNormally(g, v2);
1313 <    }}
1314 <
1315 <    public void testThenCombine_actionFailed2() {
1303 >    public void testThenCombine_actionFailed() {
1304          for (ExecutionMode m : ExecutionMode.values())
1305 +        for (boolean fFirst : new boolean[] { true, false })
1306          for (Integer v1 : new Integer[] { 1, null })
1307          for (Integer v2 : new Integer[] { 2, null })
1308      {
# Line 1322 | Line 1311 | public class CompletableFutureTest exten
1311          final FailingBiFunction r = new FailingBiFunction();
1312          final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1313  
1314 <        g.complete(v2);
1315 <        checkIncomplete(h);
1316 <        f.complete(v1);
1314 >        if (fFirst) {
1315 >            f.complete(v1);
1316 >            g.complete(v2);
1317 >        } else {
1318 >            g.complete(v2);
1319 >            f.complete(v1);
1320 >        }
1321  
1322          checkCompletedWithWrappedCFException(h);
1323          checkCompletedNormally(f, v1);
# Line 1334 | Line 1327 | public class CompletableFutureTest exten
1327      /**
1328       * thenCombine result completes exceptionally if either source cancelled
1329       */
1330 <    public void testThenCombine_sourceCancelled1() {
1338 <        for (ExecutionMode m : ExecutionMode.values())
1339 <        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1340 <        for (Integer v1 : new Integer[] { 1, null })
1341 <    {
1342 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1343 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1344 <        final SubtractFunction r = new SubtractFunction();
1345 <        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1346 <
1347 <        assertTrue(f.cancel(mayInterruptIfRunning));
1348 <        checkIncomplete(h);
1349 <        g.complete(v1);
1350 <
1351 <        checkCompletedWithWrappedCancellationException(h);
1352 <        checkCancelled(f);
1353 <        assertEquals(0, r.invocationCount);
1354 <        checkCompletedNormally(g, v1);
1355 <    }}
1356 <
1357 <    public void testThenCombine_sourceCancelled2() {
1358 <        for (ExecutionMode m : ExecutionMode.values())
1359 <        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1360 <        for (Integer v1 : new Integer[] { 1, null })
1361 <    {
1362 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1363 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1364 <        final SubtractFunction r = new SubtractFunction();
1365 <        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1366 <
1367 <        assertTrue(g.cancel(mayInterruptIfRunning));
1368 <        checkIncomplete(h);
1369 <        f.complete(v1);
1370 <
1371 <        checkCompletedWithWrappedCancellationException(h);
1372 <        checkCancelled(g);
1373 <        assertEquals(0, r.invocationCount);
1374 <        checkCompletedNormally(f, v1);
1375 <    }}
1376 <
1377 <    public void testThenCombine_sourceCancelled3() {
1378 <        for (ExecutionMode m : ExecutionMode.values())
1379 <        for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1380 <        for (Integer v1 : new Integer[] { 1, null })
1381 <    {
1382 <        final CompletableFuture<Integer> f = new CompletableFuture<>();
1383 <        final CompletableFuture<Integer> g = new CompletableFuture<>();
1384 <        final SubtractFunction r = new SubtractFunction();
1385 <
1386 <        assertTrue(g.cancel(mayInterruptIfRunning));
1387 <        f.complete(v1);
1388 <        final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1389 <
1390 <        checkCompletedWithWrappedCancellationException(h);
1391 <        checkCancelled(g);
1392 <        assertEquals(0, r.invocationCount);
1393 <        checkCompletedNormally(f, v1);
1394 <    }}
1395 <
1396 <    public void testThenCombine_sourceCancelled4() {
1330 >    public void testThenCombine_sourceCancelled() {
1331          for (ExecutionMode m : ExecutionMode.values())
1332          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1333 +        for (boolean createIncomplete : new boolean[] { true, false })
1334 +        for (boolean fFirst : new boolean[] { true, false })
1335          for (Integer v1 : new Integer[] { 1, null })
1336      {
1337          final CompletableFuture<Integer> f = new CompletableFuture<>();
1338          final CompletableFuture<Integer> g = new CompletableFuture<>();
1339          final SubtractFunction r = new SubtractFunction();
1340  
1341 <        assertTrue(f.cancel(mayInterruptIfRunning));
1342 <        g.complete(v1);
1341 >        (fFirst ? f : g).complete(v1);
1342 >        if (!createIncomplete)
1343 >            assertTrue((!fFirst ? f : g).cancel(mayInterruptIfRunning));
1344          final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1345 +        if (createIncomplete) {
1346 +            checkIncomplete(h);
1347 +            assertTrue((!fFirst ? f : g).cancel(mayInterruptIfRunning));
1348 +        }
1349  
1350          checkCompletedWithWrappedCancellationException(h);
1351 <        checkCancelled(f);
1351 >        checkCancelled(!fFirst ? f : g);
1352          assertEquals(0, r.invocationCount);
1353 <        checkCompletedNormally(g, v1);
1353 >        checkCompletedNormally(fFirst ? f : g, v1);
1354      }}
1355  
1356      /**
# Line 1876 | Line 1817 | public class CompletableFutureTest exten
1817      {
1818          final CompletableFuture<Integer> f = new CompletableFuture<>();
1819          final CompletableFuture<Integer> g = new CompletableFuture<>();
1820 <        final FailingNoop r = new FailingNoop();
1820 >        final FailingRunnable r = new FailingRunnable();
1821          final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1822  
1823          f.complete(v1);
# Line 1895 | Line 1836 | public class CompletableFutureTest exten
1836      {
1837          final CompletableFuture<Integer> f = new CompletableFuture<>();
1838          final CompletableFuture<Integer> g = new CompletableFuture<>();
1839 <        final FailingNoop r = new FailingNoop();
1839 >        final FailingRunnable r = new FailingRunnable();
1840          final CompletableFuture<Void> h = m.runAfterBoth(f, g, r);
1841  
1842          g.complete(v2);
# Line 2759 | Line 2700 | public class CompletableFutureTest exten
2700      {
2701          final CompletableFuture<Integer> f = new CompletableFuture<>();
2702          final CompletableFuture<Integer> g = new CompletableFuture<>();
2703 <        final FailingNoop r = new FailingNoop();
2703 >        final FailingRunnable r = new FailingRunnable();
2704          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2705  
2706          f.complete(v1);
# Line 2776 | Line 2717 | public class CompletableFutureTest exten
2717      {
2718          final CompletableFuture<Integer> f = new CompletableFuture<>();
2719          final CompletableFuture<Integer> g = new CompletableFuture<>();
2720 <        final FailingNoop r = new FailingNoop();
2720 >        final FailingRunnable r = new FailingRunnable();
2721          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2722  
2723          g.complete(v2);
# Line 2953 | Line 2894 | public class CompletableFutureTest exten
2894          final CompletableFutureInc r = new CompletableFutureInc();
2895          if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
2896          final CompletableFuture<Integer> g = f.thenCompose(r);
2897 <        if (createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
2897 >        if (createIncomplete) {
2898 >            checkIncomplete(g);
2899 >            assertTrue(f.cancel(mayInterruptIfRunning));
2900 >        }
2901  
2902          checkCompletedWithWrappedCancellationException(g);
2903          checkCancelled(f);
2904      }}
2905  
2962    // asyncs
2963
2964    /**
2965     * thenAcceptAsync result completes normally after normal
2966     * completion of source
2967     */
2968    public void testThenAcceptAsync() {
2969        CompletableFuture<Integer> f = new CompletableFuture<>();
2970        IncAction r = new IncAction();
2971        CompletableFuture<Void> g = f.thenAcceptAsync(r);
2972        f.complete(one);
2973        checkCompletedNormally(g, null);
2974        assertEquals(r.value, (Integer) 2);
2975    }
2976
2977    /**
2978     * thenAcceptAsync result completes exceptionally after exceptional
2979     * completion of source
2980     */
2981    public void testThenAcceptAsync2() {
2982        CompletableFuture<Integer> f = new CompletableFuture<>();
2983        IncAction r = new IncAction();
2984        CompletableFuture<Void> g = f.thenAcceptAsync(r);
2985        f.completeExceptionally(new CFException());
2986        checkCompletedWithWrappedCFException(g);
2987    }
2988
2989    /**
2990     * thenAcceptAsync result completes exceptionally if action does
2991     */
2992    public void testThenAcceptAsync3() {
2993        CompletableFuture<Integer> f = new CompletableFuture<>();
2994        FailingConsumer r = new FailingConsumer();
2995        CompletableFuture<Void> g = f.thenAcceptAsync(r);
2996        f.complete(null);
2997        checkCompletedWithWrappedCFException(g);
2998    }
2999
3000    /**
3001     * thenAcceptAsync result completes exceptionally if source cancelled
3002     */
3003    public void testThenAcceptAsync4() {
3004        CompletableFuture<Integer> f = new CompletableFuture<>();
3005        IncAction r = new IncAction();
3006        CompletableFuture<Void> g = f.thenAcceptAsync(r);
3007        assertTrue(f.cancel(true));
3008        checkCompletedWithWrappedCancellationException(g);
3009    }
3010
3011    // async with explicit executors
3012
3013    /**
3014     * thenAcceptAsync result completes normally after normal
3015     * completion of source
3016     */
3017    public void testThenAcceptAsyncE() {
3018        CompletableFuture<Integer> f = new CompletableFuture<>();
3019        IncAction r = new IncAction();
3020        CompletableFuture<Void> g = f.thenAcceptAsync(r, new ThreadExecutor());
3021        f.complete(one);
3022        checkCompletedNormally(g, null);
3023        assertEquals(r.value, (Integer) 2);
3024    }
3025
3026    /**
3027     * thenAcceptAsync result completes exceptionally after exceptional
3028     * completion of source
3029     */
3030    public void testThenAcceptAsync2E() {
3031        CompletableFuture<Integer> f = new CompletableFuture<>();
3032        IncAction r = new IncAction();
3033        CompletableFuture<Void> g = f.thenAcceptAsync(r, new ThreadExecutor());
3034        f.completeExceptionally(new CFException());
3035        checkCompletedWithWrappedCFException(g);
3036    }
3037
3038    /**
3039     * thenAcceptAsync result completes exceptionally if action does
3040     */
3041    public void testThenAcceptAsync3E() {
3042        CompletableFuture<Integer> f = new CompletableFuture<>();
3043        FailingConsumer r = new FailingConsumer();
3044        CompletableFuture<Void> g = f.thenAcceptAsync(r, new ThreadExecutor());
3045        f.complete(null);
3046        checkCompletedWithWrappedCFException(g);
3047    }
3048
3049    /**
3050     * thenAcceptAsync result completes exceptionally if source cancelled
3051     */
3052    public void testThenAcceptAsync4E() {
3053        CompletableFuture<Integer> f = new CompletableFuture<>();
3054        IncAction r = new IncAction();
3055        CompletableFuture<Void> g = f.thenAcceptAsync(r, new ThreadExecutor());
3056        assertTrue(f.cancel(true));
3057        checkCompletedWithWrappedCancellationException(g);
3058    }
3059
2906      // other static methods
2907  
2908      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines