From 7db7e4a131be01e000c2668dc53cbd9c85756c70 Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Sat, 30 Nov 2024 19:12:47 +0800 Subject: [PATCH] =?UTF-8?q?test:=20Check=20the=20executor=20parameter=20us?= =?UTF-8?q?age=20of=20all=20Cffu/CffuFactory=20methods=20that=20has=20Exec?= =?UTF-8?q?utor=20parameter=20=F0=9F=A7=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aspect_test/CheckExecutorOfTests.kt | 618 +++++++++++++++++- .../test_utils/TestingExecutorUtils.kt | 2 +- 2 files changed, 617 insertions(+), 3 deletions(-) diff --git a/cffu-core/src/test/java/io/foldright/aspect_test/CheckExecutorOfTests.kt b/cffu-core/src/test/java/io/foldright/aspect_test/CheckExecutorOfTests.kt index 77429778..c6930e01 100644 --- a/cffu-core/src/test/java/io/foldright/aspect_test/CheckExecutorOfTests.kt +++ b/cffu-core/src/test/java/io/foldright/aspect_test/CheckExecutorOfTests.kt @@ -15,9 +15,9 @@ import java.util.function.* import java.util.function.Function /** - * Check the executor parameter usage of all method that has Executor parameter. + * Check the executor parameter usage of all CompletableFutureUtils methods that has Executor parameter. */ -class CheckExecutorTests : FunSpec({ +class CheckExecutorOfCompletableFutureUtilsMethodsTests : FunSpec({ (1..3).forEach { count -> test("Multi-Actions(M*) Methods with $count actions") { val am = ExTracingActionMaker() @@ -653,6 +653,620 @@ class CheckExecutorTests : FunSpec({ } }) +/** + * Check the executor parameter usage of all Cffu/CffuFactory methods that has Executor parameter. + */ +class CheckExecutorOfCffuMethodsTests : FunSpec({ + val anotherExecutor = createThreadPool("CheckExecutorOfCffuMethodsTests") + + (1..3).forEach { count -> + test("Multi-Actions(M*) Methods with $count actions") { + val am = ExTracingActionMaker() + + testCffuFac.mSupplyFailFastAsync(*am.createSuppliers(count, testExecutor)) + testCffuFac.mSupplyFailFastAsync(anotherExecutor, *am.createSuppliers(count, anotherExecutor)) + + testCffuFac.mSupplyAllSuccessAsync(null, *am.createSuppliers(count, testExecutor)) + testCffuFac.mSupplyAllSuccessAsync( + anotherExecutor, + null, + *am.createSuppliers(count, anotherExecutor) + ) + + testCffuFac.mSupplyMostSuccessAsync( + null, + LONG_WAIT_MS, + MILLISECONDS, + *am.createSuppliers(count, testExecutor) + ) + testCffuFac.mSupplyMostSuccessAsync( + anotherExecutor, + null, + LONG_WAIT_MS, + MILLISECONDS, + *am.createSuppliers(count, anotherExecutor) + ) + + testCffuFac.mSupplyAsync(*am.createSuppliers(count, testExecutor)) + testCffuFac.mSupplyAsync(anotherExecutor, *am.createSuppliers(count, anotherExecutor)) + + testCffuFac.mSupplyAnySuccessAsync(*am.createSuppliers(count, testExecutor)) + testCffuFac.mSupplyAnySuccessAsync( + anotherExecutor, + *am.createSuppliers(count, anotherExecutor) + ) + + testCffuFac.mSupplyAnyAsync(*am.createSuppliers(count, testExecutor)) + testCffuFac.mSupplyAnyAsync(anotherExecutor, *am.createSuppliers(count, anotherExecutor)) + + testCffuFac.mRunFailFastAsync(*am.createRunnables(count, testExecutor)) + testCffuFac.mRunFailFastAsync(anotherExecutor, *am.createRunnables(count, anotherExecutor)) + + testCffuFac.mRunAsync(*am.createRunnables(count, testExecutor)) + testCffuFac.mRunAsync(anotherExecutor, *am.createRunnables(count, anotherExecutor)) + + testCffuFac.mRunAnySuccessAsync(*am.createRunnables(count, testExecutor)) + testCffuFac.mRunAnySuccessAsync(anotherExecutor, *am.createRunnables(count, anotherExecutor)) + + testCffuFac.mRunAnyAsync(*am.createRunnables(count, testExecutor)) + testCffuFac.mRunAnyAsync(anotherExecutor, *am.createRunnables(count, anotherExecutor)) + + am.checkRunningExecutor() + } + } + + test("Multi-Actions-Tuple(MTuple*) Methods(create by actions)") { + val am = ExTracingActionMaker() + + run { + val (sInCP1, sInCP2) = am.createSuppliers(2, testExecutor) + testCffuFac.mSupplyTupleFailFastAsync(sInCP1, sInCP2) + } + run { + val (sInCP1, sInCP2, sInCP3) = am.createSuppliers(3, testExecutor) + testCffuFac.mSupplyTupleFailFastAsync(sInCP1, sInCP2, sInCP3) + } + run { + val (sInCP1, sInCP2, sInCP3, sInCP4) = am.createSuppliers(4, testExecutor) + testCffuFac.mSupplyTupleFailFastAsync(sInCP1, sInCP2, sInCP3, sInCP4) + } + run { + val (sInCP1, sInCP2, sInCP3, sInCP4, sInCP5) = am.createSuppliers(5, testExecutor) + testCffuFac.mSupplyTupleFailFastAsync(sInCP1, sInCP2, sInCP3, sInCP4, sInCP5) + } + run { + val (sInTE1, sInTE2) = am.createSuppliers(2, anotherExecutor) + testCffuFac.mSupplyTupleFailFastAsync(anotherExecutor, sInTE1, sInTE2) + } + run { + val (sInTE1, sInTE2, sInTE3) = am.createSuppliers(3, anotherExecutor) + testCffuFac.mSupplyTupleFailFastAsync(anotherExecutor, sInTE1, sInTE2, sInTE3) + } + run { + val (sInTE1, sInTE2, sInTE3, sInTE4) = am.createSuppliers(4, anotherExecutor) + testCffuFac.mSupplyTupleFailFastAsync(anotherExecutor, sInTE1, sInTE2, sInTE3, sInTE4) + } + run { + val (sInTE1, sInTE2, sInTE3, sInTE4, sInTE5) = am.createSuppliers(5, anotherExecutor) + testCffuFac.mSupplyTupleFailFastAsync(anotherExecutor, sInTE1, sInTE2, sInTE3, sInTE4, sInTE5) + } + + run { + val (sInCP1, sInCP2) = am.createSuppliers(2, testExecutor) + testCffuFac.mSupplyAllSuccessTupleAsync(sInCP1, sInCP2) + } + run { + val (sInCP1, sInCP2, sInCP3) = am.createSuppliers(3, testExecutor) + testCffuFac.mSupplyAllSuccessTupleAsync(sInCP1, sInCP2, sInCP3) + } + run { + val (sInCP1, sInCP2, sInCP3, sInCP4) = am.createSuppliers(4, testExecutor) + testCffuFac.mSupplyAllSuccessTupleAsync(sInCP1, sInCP2, sInCP3, sInCP4) + } + run { + val (sInCP1, sInCP2, sInCP3, sInCP4, sInCP5) = am.createSuppliers(5, testExecutor) + testCffuFac.mSupplyAllSuccessTupleAsync(sInCP1, sInCP2, sInCP3, sInCP4, sInCP5) + } + run { + val (sInTE1, sInTE2) = am.createSuppliers(2, anotherExecutor) + testCffuFac.mSupplyAllSuccessTupleAsync(anotherExecutor, sInTE1, sInTE2) + } + run { + val (sInTE1, sInTE2, sInTE3) = am.createSuppliers(3, anotherExecutor) + testCffuFac.mSupplyAllSuccessTupleAsync(anotherExecutor, sInTE1, sInTE2, sInTE3) + } + run { + val (sInTE1, sInTE2, sInTE3, sInTE4) = am.createSuppliers(4, anotherExecutor) + testCffuFac.mSupplyAllSuccessTupleAsync(anotherExecutor, sInTE1, sInTE2, sInTE3, sInTE4) + } + run { + val (sInTE1, sInTE2, sInTE3, sInTE4, sInTE5) = am.createSuppliers(5, anotherExecutor) + testCffuFac.mSupplyAllSuccessTupleAsync(anotherExecutor, sInTE1, sInTE2, sInTE3, sInTE4, sInTE5) + } + + run { + val (sInCP1, sInCP2) = am.createSuppliers(2, testExecutor) + testCffuFac.mSupplyMostSuccessTupleAsync(LONG_WAIT_MS, MILLISECONDS, sInCP1, sInCP2) + } + run { + val (sInCP1, sInCP2, sInCP3) = am.createSuppliers(3, testExecutor) + testCffuFac.mSupplyMostSuccessTupleAsync(LONG_WAIT_MS, MILLISECONDS, sInCP1, sInCP2, sInCP3) + } + run { + val (sInCP1, sInCP2, sInCP3, sInCP4) = am.createSuppliers(4, testExecutor) + testCffuFac.mSupplyMostSuccessTupleAsync( + LONG_WAIT_MS, + MILLISECONDS, + sInCP1, + sInCP2, + sInCP3, + sInCP4 + ) + } + run { + val (sInCP1, sInCP2, sInCP3, sInCP4, sInCP5) = am.createSuppliers(5, testExecutor) + testCffuFac.mSupplyMostSuccessTupleAsync( + LONG_WAIT_MS, + MILLISECONDS, + sInCP1, + sInCP2, + sInCP3, + sInCP4, + sInCP5 + ) + } + + run { + val (sInTE1, sInTE2) = am.createSuppliers(2, anotherExecutor) + testCffuFac.mSupplyMostSuccessTupleAsync( + anotherExecutor, + LONG_WAIT_MS, + MILLISECONDS, + sInTE1, + sInTE2 + ) + } + run { + val (sInTE1, sInTE2, sInTE3) = am.createSuppliers(3, anotherExecutor) + testCffuFac.mSupplyMostSuccessTupleAsync( + anotherExecutor, + LONG_WAIT_MS, + MILLISECONDS, + sInTE1, + sInTE2, + sInTE3 + ) + } + run { + val (sInTE1, sInTE2, sInTE3, sInTE4) = am.createSuppliers(4, anotherExecutor) + testCffuFac.mSupplyMostSuccessTupleAsync( + anotherExecutor, + LONG_WAIT_MS, + MILLISECONDS, + sInTE1, + sInTE2, + sInTE3, + sInTE4 + ) + } + run { + val (sInTE1, sInTE2, sInTE3, sInTE4, sInTE5) = am.createSuppliers(5, anotherExecutor) + testCffuFac.mSupplyMostSuccessTupleAsync( + anotherExecutor, + LONG_WAIT_MS, + MILLISECONDS, + sInTE1, + sInTE2, + sInTE3, + sInTE4, + sInTE5 + ) + } + + run { + val (sInCP1, sInCP2) = am.createSuppliers(2, testExecutor) + testCffuFac.mSupplyTupleAsync(sInCP1, sInCP2) + } + run { + val (sInCP1, sInCP2, sInCP3) = am.createSuppliers(3, testExecutor) + testCffuFac.mSupplyTupleAsync(sInCP1, sInCP2, sInCP3) + } + run { + val (sInCP1, sInCP2, sInCP3, sInCP4) = am.createSuppliers(4, testExecutor) + testCffuFac.mSupplyTupleAsync(sInCP1, sInCP2, sInCP3, sInCP4) + } + run { + val (sInCP1, sInCP2, sInCP3, sInCP4, sInCP5) = am.createSuppliers(5, testExecutor) + testCffuFac.mSupplyTupleAsync(sInCP1, sInCP2, sInCP3, sInCP4, sInCP5) + } + run { + val (sInTE1, sInTE2) = am.createSuppliers(2, anotherExecutor) + testCffuFac.mSupplyTupleAsync(anotherExecutor, sInTE1, sInTE2) + } + run { + val (sInTE1, sInTE2, sInTE3) = am.createSuppliers(3, anotherExecutor) + testCffuFac.mSupplyTupleAsync(anotherExecutor, sInTE1, sInTE2, sInTE3) + } + run { + val (sInTE1, sInTE2, sInTE3, sInTE4) = am.createSuppliers(4, anotherExecutor) + testCffuFac.mSupplyTupleAsync(anotherExecutor, sInTE1, sInTE2, sInTE3, sInTE4) + } + run { + val (sInTE1, sInTE2, sInTE3, sInTE4, sInTE5) = am.createSuppliers(5, anotherExecutor) + testCffuFac.mSupplyTupleAsync(anotherExecutor, sInTE1, sInTE2, sInTE3, sInTE4, sInTE5) + } + + am.checkRunningExecutor() + } + + test("Delay Execution") { + val am = ExTracingActionMaker() + + testCffuFac.delayedExecutor(1, MILLISECONDS).execute(am.createFutureTask(testExecutor)) + testCffuFac.delayedExecutor(1, MILLISECONDS, anotherExecutor).execute(am.createFutureTask(anotherExecutor)) + + am.checkRunningExecutor() + } + + val cfThis = testCffuFac.completedFuture(n) + + (1..3).forEach { count -> + test("Then-Multi-Actions(thenM*) Methods with $count actions") { + val am = ExTracingActionMaker() + + cfThis.thenMApplyFailFastAsync(*am.createFunctions(count, testExecutor)) + cfThis.thenMApplyFailFastAsync( + anotherExecutor, + *am.createFunctions(count, anotherExecutor) + ) + + cfThis.thenMApplyAllSuccessAsync(null, *am.createFunctions(count, testExecutor)) + cfThis.thenMApplyAllSuccessAsync( + anotherExecutor, null, *am.createFunctions(count, anotherExecutor) + ) + + cfThis.thenMApplyMostSuccessAsync( + null, + LONG_WAIT_MS, + MILLISECONDS, + *am.createFunctions(count, testExecutor) + ) + cfThis.thenMApplyMostSuccessAsync( + anotherExecutor, + null, + LONG_WAIT_MS, + MILLISECONDS, + *am.createFunctions(count, anotherExecutor) + ) + + cfThis.thenMApplyAsync(*am.createFunctions(count, testExecutor)) + cfThis.thenMApplyAsync(anotherExecutor, *am.createFunctions(count, anotherExecutor)) + + cfThis.thenMApplyAnySuccessAsync(*am.createFunctions(count, testExecutor)) + cfThis.thenMApplyAnySuccessAsync( + anotherExecutor, + *am.createFunctions(count, anotherExecutor) + ) + + cfThis.thenMApplyAnyAsync(*am.createFunctions(count, testExecutor)) + cfThis.thenMApplyAnyAsync( + anotherExecutor, + *am.createFunctions(count, anotherExecutor) + ) + + cfThis.thenMAcceptFailFastAsync(*am.createConsumers(count, testExecutor)) + cfThis.thenMAcceptFailFastAsync( + anotherExecutor, + *am.createConsumers(count, anotherExecutor) + ) + + cfThis.thenMAcceptAsync(*am.createConsumers(count, testExecutor)) + cfThis.thenMAcceptAsync(anotherExecutor, *am.createConsumers(count, anotherExecutor)) + + cfThis.thenMAcceptAnySuccessAsync(*am.createConsumers(count, testExecutor)) + cfThis.thenMAcceptAnySuccessAsync( + anotherExecutor, + *am.createConsumers(count, anotherExecutor) + ) + + cfThis.thenMAcceptAnyAsync(*am.createConsumers(count, testExecutor)) + cfThis.thenMAcceptAnyAsync( + anotherExecutor, + *am.createConsumers(count, anotherExecutor) + ) + + cfThis.thenMRunFailFastAsync(*am.createRunnables(count, testExecutor)) + cfThis.thenMRunFailFastAsync( + anotherExecutor, + *am.createRunnables(count, anotherExecutor) + ) + + cfThis.thenMRunAsync(*am.createRunnables(count, testExecutor)) + cfThis.thenMRunAsync(anotherExecutor, *am.createRunnables(count, anotherExecutor)) + + cfThis.thenMRunAnySuccessAsync(*am.createRunnables(count, testExecutor)) + cfThis.thenMRunAnySuccessAsync( + anotherExecutor, + *am.createRunnables(count, anotherExecutor) + ) + + cfThis.thenMRunAnyAsync(*am.createRunnables(count, testExecutor)) + cfThis.thenMRunAnyAsync(anotherExecutor, *am.createRunnables(count, anotherExecutor)) + + am.checkRunningExecutor() + } + } + + test("Then-Multi-Actions-Tuple(thenMTuple*) Methods") { + val am = ExTracingActionMaker() + + run { + val (fInCP1, fInCP2) = am.createFunctions(2, testExecutor) + cfThis.thenMApplyTupleFailFastAsync(fInCP1, fInCP2) + } + run { + val (fInCP1, fInCP2, fInCP3) = am.createFunctions(3, testExecutor) + cfThis.thenMApplyTupleFailFastAsync(fInCP1, fInCP2, fInCP3) + } + run { + val (fInCP1, fInCP2, fInCP3, fInCP4) = am.createFunctions(4, testExecutor) + cfThis.thenMApplyTupleFailFastAsync(fInCP1, fInCP2, fInCP3, fInCP4) + } + run { + val (fInCP1, fInCP2, fInCP3, fInCP4, fInCP5) = am.createFunctions(5, testExecutor) + cfThis.thenMApplyTupleFailFastAsync(fInCP1, fInCP2, fInCP3, fInCP4, fInCP5) + } + run { + val (fInTE1, fInTE2) = am.createFunctions(2, anotherExecutor) + cfThis.thenMApplyTupleFailFastAsync(anotherExecutor, fInTE1, fInTE2) + } + run { + val (fInTE1, fInTE2, fInTE3) = am.createFunctions(3, anotherExecutor) + cfThis.thenMApplyTupleFailFastAsync(anotherExecutor, fInTE1, fInTE2, fInTE3) + } + run { + val (fInTE1, fInTE2, fInTE3, fInTE4) = am.createFunctions(4, anotherExecutor) + cfThis.thenMApplyTupleFailFastAsync(anotherExecutor, fInTE1, fInTE2, fInTE3, fInTE4) + } + run { + val (fInTE1, fInTE2, fInTE3, fInTE4, fInTE5) = am.createFunctions(5, anotherExecutor) + cfThis.thenMApplyTupleFailFastAsync( + anotherExecutor, + fInTE1, + fInTE2, + fInTE3, + fInTE4, + fInTE5 + ) + } + + run { + val (fInCP1, fInCP2) = am.createFunctions(2, testExecutor) + cfThis.thenMApplyAllSuccessTupleAsync(fInCP1, fInCP2) + } + run { + val (fInCP1, fInCP2, fInCP3) = am.createFunctions(3, testExecutor) + cfThis.thenMApplyAllSuccessTupleAsync(fInCP1, fInCP2, fInCP3) + } + run { + val (fInCP1, fInCP2, fInCP3, fInCP4) = am.createFunctions(4, testExecutor) + cfThis.thenMApplyAllSuccessTupleAsync(fInCP1, fInCP2, fInCP3, fInCP4) + } + run { + val (fInCP1, fInCP2, fInCP3, fInCP4, fInCP5) = am.createFunctions(5, testExecutor) + cfThis.thenMApplyAllSuccessTupleAsync(fInCP1, fInCP2, fInCP3, fInCP4, fInCP5) + } + run { + val (fInTE1, fInTE2) = am.createFunctions(2, anotherExecutor) + cfThis.thenMApplyAllSuccessTupleAsync(anotherExecutor, fInTE1, fInTE2) + } + run { + val (fInTE1, fInTE2, fInTE3) = am.createFunctions(3, anotherExecutor) + cfThis.thenMApplyAllSuccessTupleAsync(anotherExecutor, fInTE1, fInTE2, fInTE3) + } + run { + val (fInTE1, fInTE2, fInTE3, fInTE4) = am.createFunctions(4, anotherExecutor) + cfThis.thenMApplyAllSuccessTupleAsync(anotherExecutor, fInTE1, fInTE2, fInTE3, fInTE4) + } + run { + val (fInTE1, fInTE2, fInTE3, fInTE4, fInTE5) = am.createFunctions(5, anotherExecutor) + cfThis.thenMApplyAllSuccessTupleAsync( + anotherExecutor, + fInTE1, + fInTE2, + fInTE3, + fInTE4, + fInTE5 + ) + } + + run { + val (fInCP1, fInCP2) = am.createFunctions(2, testExecutor) + cfThis.thenMApplyMostSuccessTupleAsync(LONG_WAIT_MS, MILLISECONDS, fInCP1, fInCP2) + } + run { + val (fInCP1, fInCP2, fInCP3) = am.createFunctions(3, testExecutor) + cfThis.thenMApplyMostSuccessTupleAsync( + LONG_WAIT_MS, + MILLISECONDS, + fInCP1, + fInCP2, + fInCP3 + ) + } + run { + val (fInCP1, fInCP2, fInCP3, fInCP4) = am.createFunctions(4, testExecutor) + cfThis.thenMApplyMostSuccessTupleAsync( + LONG_WAIT_MS, + MILLISECONDS, + fInCP1, + fInCP2, + fInCP3, + fInCP4 + ) + } + run { + val (fInCP1, fInCP2, fInCP3, fInCP4, fInCP5) = am.createFunctions(5, testExecutor) + cfThis.thenMApplyMostSuccessTupleAsync( + LONG_WAIT_MS, + MILLISECONDS, + fInCP1, + fInCP2, + fInCP3, + fInCP4, + fInCP5 + ) + } + run { + val (fInTE1, fInTE2) = am.createFunctions(2, anotherExecutor) + cfThis.thenMApplyMostSuccessTupleAsync( + anotherExecutor, + LONG_WAIT_MS, + MILLISECONDS, + fInTE1, + fInTE2 + ) + } + run { + val (fInTE1, fInTE2, fInTE3) = am.createFunctions(3, anotherExecutor) + cfThis.thenMApplyMostSuccessTupleAsync( + anotherExecutor, + LONG_WAIT_MS, + MILLISECONDS, + fInTE1, + fInTE2, + fInTE3 + ) + } + run { + val (fInTE1, fInTE2, fInTE3, fInTE4) = am.createFunctions(4, anotherExecutor) + cfThis.thenMApplyMostSuccessTupleAsync( + anotherExecutor, + LONG_WAIT_MS, + MILLISECONDS, + fInTE1, + fInTE2, + fInTE3, + fInTE4 + ) + } + run { + val (fInTE1, fInTE2, fInTE3, fInTE4, fInTE5) = am.createFunctions(5, anotherExecutor) + cfThis.thenMApplyMostSuccessTupleAsync( + anotherExecutor, + LONG_WAIT_MS, + MILLISECONDS, + fInTE1, + fInTE2, + fInTE3, + fInTE4, + fInTE5 + ) + } + + run { + val (fInCP1, fInCP2) = am.createFunctions(2, testExecutor) + cfThis.thenMApplyTupleAsync(fInCP1, fInCP2) + } + run { + val (fInCP1, fInCP2, fInCP3) = am.createFunctions(3, testExecutor) + cfThis.thenMApplyTupleAsync(fInCP1, fInCP2, fInCP3) + } + run { + val (fInCP1, fInCP2, fInCP3, fInCP4) = am.createFunctions(4, testExecutor) + cfThis.thenMApplyTupleAsync(fInCP1, fInCP2, fInCP3, fInCP4) + } + run { + val (fInCP1, fInCP2, fInCP3, fInCP4, fInCP5) = am.createFunctions(5, testExecutor) + cfThis.thenMApplyTupleAsync(fInCP1, fInCP2, fInCP3, fInCP4, fInCP5) + } + run { + val (fInTE1, fInTE2) = am.createFunctions(2, anotherExecutor) + cfThis.thenMApplyTupleAsync(anotherExecutor, fInTE1, fInTE2) + } + run { + val (fInTE1, fInTE2, fInTE3) = am.createFunctions(3, anotherExecutor) + cfThis.thenMApplyTupleAsync(anotherExecutor, fInTE1, fInTE2, fInTE3) + } + run { + val (fInTE1, fInTE2, fInTE3, fInTE4) = am.createFunctions(4, anotherExecutor) + cfThis.thenMApplyTupleAsync(anotherExecutor, fInTE1, fInTE2, fInTE3, fInTE4) + } + run { + val (fInTE1, fInTE2, fInTE3, fInTE4, fInTE5) = am.createFunctions(5, anotherExecutor) + cfThis.thenMApplyTupleAsync(anotherExecutor, fInTE1, fInTE2, fInTE3, fInTE4, fInTE5) + } + + am.checkRunningExecutor() + } + + val other = CompletableFuture.completedFuture(anotherN) + + test("thenBoth* Methods(binary input) with fail-fast support") { + val am = ExTracingActionMaker() + + cfThis.thenCombineFailFastAsync(other, am.createBiFunction(testExecutor)) + cfThis.thenCombineFailFastAsync(other, am.createBiFunction(anotherExecutor), anotherExecutor) + + cfThis.thenAcceptBothFailFastAsync(other, am.createBiConsumer(testExecutor)) + cfThis.thenAcceptBothFailFastAsync( + other, + am.createBiConsumer(anotherExecutor), + anotherExecutor + ) + + cfThis.runAfterBothFailFastAsync(other, am.createFutureTask(testExecutor)) + cfThis.runAfterBothFailFastAsync(other, am.createFutureTask(anotherExecutor), anotherExecutor) + + am.checkRunningExecutor() + } + + test("thenEither* Methods(binary input) with either(any)-success support") { + val am = ExTracingActionMaker() + + cfThis.applyToEitherSuccessAsync(other, am.createFunctions(1, testExecutor)[0]) + cfThis.applyToEitherSuccessAsync( + other, + am.createFunctions(1, anotherExecutor)[0], + anotherExecutor + ) + + cfThis.acceptEitherSuccessAsync(other, am.createConsumers(1, testExecutor)[0]) + cfThis.acceptEitherSuccessAsync( + other, + am.createConsumers(1, anotherExecutor)[0], + anotherExecutor + ) + + cfThis.runAfterEitherSuccessAsync(other, am.createFutureTask(testExecutor)) + cfThis.runAfterEitherSuccessAsync( + other, + am.createFutureTask(anotherExecutor), + anotherExecutor + ) + + am.checkRunningExecutor() + } + + test("Error Handling Methods of CompletionStage") { + val am = ExTracingActionMaker() + + val failedCf = testCffuFac.failedFuture(RuntimeException("Failed")) + + failedCf.catchingAsync(RuntimeException::class.java, am.createExFunction(testExecutor)) + failedCf.catchingAsync( + RuntimeException::class.java, + am.createExFunction(anotherExecutor), + anotherExecutor + ) + + failedCf.exceptionallyAsync(am.createExFunction(testExecutor)) + failedCf.exceptionallyAsync(am.createExFunction(anotherExecutor), anotherExecutor) + + am.checkRunningExecutor() + } +}) + private val commonPool = ForkJoinPool.commonPool() class ExTracingActionMaker(private val testingThread: Thread = currentThread()) { diff --git a/cffu-core/src/test/java/io/foldright/test_utils/TestingExecutorUtils.kt b/cffu-core/src/test/java/io/foldright/test_utils/TestingExecutorUtils.kt index 1cb260e6..c755b8dd 100644 --- a/cffu-core/src/test/java/io/foldright/test_utils/TestingExecutorUtils.kt +++ b/cffu-core/src/test/java/io/foldright/test_utils/TestingExecutorUtils.kt @@ -98,7 +98,7 @@ fun assertRunningByFjCommonPool(callingThread: Thread) { val actualMsg = "actual" + (if (!runInCallingThread) " not" else "") + - "running in calling thread" + + " running in calling thread" + (if (!runInCpThread) " not" else "") + " running in common pool thread"