org.apache.commons
commons-lang3
diff --git a/cffu-core/src/main/java/io/foldright/cffu/package-info.java b/cffu-core/src/main/java/io/foldright/cffu/package-info.java
index a7e99558..17fa29f1 100644
--- a/cffu-core/src/main/java/io/foldright/cffu/package-info.java
+++ b/cffu-core/src/main/java/io/foldright/cffu/package-info.java
@@ -1,8 +1,7 @@
/**
- * A tiny 0-dependency sidekick library for CompletableFuture
- * to improve user experience and reduce misuse.
+ * A tiny sidekick library for CompletableFuture to improve user experience and reduce misuse.
*
- * the core class is {@link io.foldright.cffu.Cffu}.
+ * The core class is {@link io.foldright.cffu.Cffu}.
*
* @see io.foldright.cffu.Cffu
* @see io.foldright.cffu.CffuFactory
diff --git a/cffu-core/src/main/javadoc/overview.html b/cffu-core/src/main/javadoc/overview.html
index 49902493..9b115b98 100644
--- a/cffu-core/src/main/javadoc/overview.html
+++ b/cffu-core/src/main/javadoc/overview.html
@@ -1,12 +1,12 @@
This is the API documentation for the
-
- 🦝 Java CompletableFuture Fu(aka. CF-Fu, pronounced "Shifu"),
- a tiny 0-dependency sidekick library for
- CompletableFuture
- to improve user experience and reduce misuse.
+
+ 🦝 Java CompletableFuture Fu(aka. CF-Fu, pronounced "Shifu"),
+ a tiny sidekick library for
+ CompletableFuture
+ to improve user experience and reduce misuse.
The CF-Fu GitHub repo
- also include the best practice/traps guide 📚 for CompletableFuture
💗.
+ also include the best practice/traps guide 📚 for CompletableFuture
💗.
diff --git a/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java b/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java
index 496134d1..260bb19a 100644
--- a/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java
+++ b/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java
@@ -17,7 +17,9 @@
import java.util.function.Function;
import static io.foldright.cffu.CffuFactoryBuilder.newCffuFactoryBuilder;
+import static io.foldright.cffu.CompletableFutureUtils.failedFuture;
import static io.foldright.test_utils.TestUtils.*;
+import static io.foldright.test_utils.CoreTestUtils.*;
import static java.util.concurrent.ForkJoinPool.commonPool;
import static org.junit.jupiter.api.Assertions.*;
@@ -26,22 +28,6 @@
* see io.foldright.compatibility_test.CffuApiCompatibilityTest
*/
class CffuFactoryTest {
- ////////////////////////////////////////////////////////////////////////////////
- // test constants
- ////////////////////////////////////////////////////////////////////////////////
-
- static final int n = 42;
- static final int another_n = 424242;
-
- static final String s = "S42";
-
- static final double d = 42.1;
-
- static final RuntimeException rte = new RuntimeException("Bang");
- static final RuntimeException another_rte = new RuntimeException("BangAnother");
-
- private static CffuFactory cffuFactory;
-
///////////////////////////////////////////////////////////////////////////////
//# Factory Methods, equivalent to same name static methods of CompletableFuture
//
@@ -90,7 +76,7 @@ void test_failedStage() throws Exception {
CompletionStage se = stage.exceptionally(throwable -> n);
try {
- createFailedFuture(rte).toCompletableFuture().join();
+ failedFuture(rte).toCompletableFuture().join();
fail();
} catch (CompletionException expected) {
assertSame(rte, expected.getCause());
@@ -183,10 +169,10 @@ void test_asCffuArray() throws Exception {
void test_allOf_CompletableFuture() throws Exception {
cffuFactory.allOf(
CompletableFuture.completedFuture(n),
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
).get();
cffuFactory.allOf(
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
).get();
assertNull(cffuFactory.allOf().get());
@@ -195,20 +181,20 @@ void test_allOf_CompletableFuture() throws Exception {
cffuFactory.allOfFastFail(
CompletableFuture.completedFuture(n),
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
).get();
cffuFactory.allOfFastFail(
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
).get();
assertNull(cffuFactory.allOfFastFail().get());
cffuFactory.allOfFastFail(
cffuFactory.completedFuture(n),
- cffuFactory.completedFuture(another_n)
+ cffuFactory.completedFuture(anotherN)
).get();
cffuFactory.allOfFastFail(
- cffuFactory.completedFuture(another_n)
+ cffuFactory.completedFuture(anotherN)
).get();
}
@@ -216,10 +202,10 @@ void test_allOf_CompletableFuture() throws Exception {
void test_anyOf_CompletableFuture() throws Exception {
cffuFactory.anyOf(
CompletableFuture.completedFuture(n),
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
).get();
- assertEquals(another_n, cffuFactory.anyOf(
- CompletableFuture.completedFuture(another_n)
+ assertEquals(anotherN, cffuFactory.anyOf(
+ CompletableFuture.completedFuture(anotherN)
).get());
assertFalse(cffuFactory.anyOf().isDone());
@@ -228,10 +214,10 @@ void test_anyOf_CompletableFuture() throws Exception {
cffuFactory.anyOfSuccess(
CompletableFuture.completedFuture(n),
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
).get();
- assertEquals(another_n, cffuFactory.anyOfSuccess(
- CompletableFuture.completedFuture(another_n)
+ assertEquals(anotherN, cffuFactory.anyOfSuccess(
+ CompletableFuture.completedFuture(anotherN)
).get());
try {
@@ -243,10 +229,10 @@ void test_anyOf_CompletableFuture() throws Exception {
cffuFactory.anyOfSuccess(
cffuFactory.completedFuture(n),
- cffuFactory.completedFuture(another_n)
+ cffuFactory.completedFuture(anotherN)
).get();
- assertEquals(another_n, cffuFactory.anyOfSuccess(
- cffuFactory.completedFuture(another_n)
+ assertEquals(anotherN, cffuFactory.anyOfSuccess(
+ cffuFactory.completedFuture(anotherN)
).get());
}
@@ -403,7 +389,7 @@ void test_cffuAnyOf_exceptionally() throws Exception {
try {
cffuFactory.cffuAnyOf(
createIncompleteFuture(),
- createFailedFuture(rte),
+ failedFuture(rte),
createIncompleteFuture()
).get();
@@ -430,7 +416,7 @@ void test_cffuAnyOfSuccess__trivial_case() throws Exception {
cffuFactory.newIncompleteCffu(),
cffuFactory.supplyAsync(() -> {
sleep(300);
- return another_n;
+ return anotherN;
}),
cffuFactory.completedFuture(n)
).get());
@@ -449,11 +435,11 @@ void test_cffuAnyOfSuccess__trivial_case() throws Exception {
assertEquals(n, cffuFactory.cffuAnyOfSuccess(
cffuFactory.supplyAsync(() -> {
sleep(300);
- return another_n;
+ return anotherN;
}),
cffuFactory.supplyAsync(() -> {
sleep(300);
- return another_n;
+ return anotherN;
}),
cffuFactory.completedFuture(n)
).get());
@@ -466,7 +452,7 @@ void test_cffuAnyOfSuccess__trivial_case() throws Exception {
createIncompleteFuture(),
CompletableFuture.supplyAsync(() -> {
sleep(300);
- return another_n;
+ return anotherN;
}),
CompletableFuture.completedFuture(n)
).get());
@@ -485,11 +471,11 @@ void test_cffuAnyOfSuccess__trivial_case() throws Exception {
assertEquals(n, cffuFactory.cffuAnyOfSuccess(
CompletableFuture.supplyAsync(() -> {
sleep(300);
- return another_n;
+ return anotherN;
}),
CompletableFuture.supplyAsync(() -> {
sleep(300);
- return another_n;
+ return anotherN;
}),
CompletableFuture.completedFuture(n)
).get());
@@ -517,18 +503,18 @@ void test_cffuCombine() throws Exception {
CompletableFuture.completedFuture(d)
).get());
- assertEquals(Tuple4.of(n, s, d, another_n), cffuFactory.cffuCombine(
+ assertEquals(Tuple4.of(n, s, d, anotherN), cffuFactory.cffuCombine(
CompletableFuture.completedFuture(n),
CompletableFuture.completedFuture(s),
CompletableFuture.completedFuture(d),
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
).get());
- assertEquals(Tuple5.of(n, s, d, another_n, n + n), cffuFactory.cffuCombine(
+ assertEquals(Tuple5.of(n, s, d, anotherN, n + n), cffuFactory.cffuCombine(
CompletableFuture.completedFuture(n),
CompletableFuture.completedFuture(s),
CompletableFuture.completedFuture(d),
- CompletableFuture.completedFuture(another_n),
+ CompletableFuture.completedFuture(anotherN),
CompletableFuture.completedFuture(n + n)
).get());
@@ -545,18 +531,18 @@ void test_cffuCombine() throws Exception {
cffuFactory.completedFuture(d)
).get());
- assertEquals(Tuple4.of(n, s, d, another_n), cffuFactory.cffuCombine(
+ assertEquals(Tuple4.of(n, s, d, anotherN), cffuFactory.cffuCombine(
cffuFactory.completedFuture(n),
cffuFactory.completedFuture(s),
cffuFactory.completedFuture(d),
- cffuFactory.completedFuture(another_n)
+ cffuFactory.completedFuture(anotherN)
).get());
- assertEquals(Tuple5.of(n, s, d, another_n, n + n), cffuFactory.cffuCombine(
+ assertEquals(Tuple5.of(n, s, d, anotherN, n + n), cffuFactory.cffuCombine(
cffuFactory.completedFuture(n),
cffuFactory.completedFuture(s),
cffuFactory.completedFuture(d),
- cffuFactory.completedFuture(another_n),
+ cffuFactory.completedFuture(anotherN),
cffuFactory.completedFuture(n + n)
).get());
@@ -571,16 +557,16 @@ void test_cffuCombine() throws Exception {
CompletableFuture.completedFuture(d)
).get());
- assertEquals(Tuple4.of(n, s, d, another_n), cffuFactory.completedFuture(n).cffuCombine(
+ assertEquals(Tuple4.of(n, s, d, anotherN), cffuFactory.completedFuture(n).cffuCombine(
CompletableFuture.completedFuture(s),
CompletableFuture.completedFuture(d),
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
).get());
- assertEquals(Tuple5.of(n, s, d, another_n, n + n), cffuFactory.completedFuture(n).cffuCombine(
+ assertEquals(Tuple5.of(n, s, d, anotherN, n + n), cffuFactory.completedFuture(n).cffuCombine(
CompletableFuture.completedFuture(s),
CompletableFuture.completedFuture(d),
- CompletableFuture.completedFuture(another_n),
+ CompletableFuture.completedFuture(anotherN),
CompletableFuture.completedFuture(n + n)
).get());
@@ -595,16 +581,16 @@ void test_cffuCombine() throws Exception {
cffuFactory.completedFuture(d)
).get());
- assertEquals(Tuple4.of(n, s, d, another_n), cffuFactory.completedFuture(n).cffuCombine(
+ assertEquals(Tuple4.of(n, s, d, anotherN), cffuFactory.completedFuture(n).cffuCombine(
cffuFactory.completedFuture(s),
cffuFactory.completedFuture(d),
- cffuFactory.completedFuture(another_n)
+ cffuFactory.completedFuture(anotherN)
).get());
- assertEquals(Tuple5.of(n, s, d, another_n, n + n), cffuFactory.completedFuture(n).cffuCombine(
+ assertEquals(Tuple5.of(n, s, d, anotherN, n + n), cffuFactory.completedFuture(n).cffuCombine(
cffuFactory.completedFuture(s),
cffuFactory.completedFuture(d),
- cffuFactory.completedFuture(another_n),
+ cffuFactory.completedFuture(anotherN),
cffuFactory.completedFuture(n + n)
).get());
}
@@ -614,7 +600,7 @@ void test_cffuCombine_exceptionally() throws Exception {
try {
cffuFactory.cffuCombine(
CompletableFuture.completedFuture(n),
- createFailedFuture(rte)
+ failedFuture(rte)
).get();
fail();
@@ -625,7 +611,7 @@ void test_cffuCombine_exceptionally() throws Exception {
try {
cffuFactory.cffuCombine(
CompletableFuture.completedFuture(n),
- createFailedFuture(rte),
+ failedFuture(rte),
CompletableFuture.completedFuture(s)
).get();
@@ -638,9 +624,9 @@ void test_cffuCombine_exceptionally() throws Exception {
cffuFactory.cffuCombine(
CompletableFuture.completedFuture(n),
CompletableFuture.completedFuture(d),
- createFailedFuture(rte),
+ failedFuture(rte),
CompletableFuture.completedFuture(s),
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
).get();
fail();
@@ -664,7 +650,7 @@ void test_toCompletableFutureArray() {
@SuppressWarnings("unchecked")
CompletableFuture[] cfArray = new CompletableFuture[]{
CompletableFuture.completedFuture(n),
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
};
@SuppressWarnings("unchecked")
CompletionStage[] csArray = new CompletableFuture[]{
@@ -687,7 +673,7 @@ void test_cffuArrayUnwrap() {
@SuppressWarnings("unchecked")
CompletableFuture[] cfArray = new CompletableFuture[]{
CompletableFuture.completedFuture(n),
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
};
@SuppressWarnings("unchecked")
Cffu[] input = new Cffu[]{
@@ -702,7 +688,7 @@ void test_cffuListToArray() {
@SuppressWarnings("unchecked")
Cffu[] input = new Cffu[]{
cffuFactory.completedFuture(n),
- cffuFactory.completedFuture(another_n),
+ cffuFactory.completedFuture(anotherN),
cffuFactory.newIncompleteCffu()
};
@@ -714,7 +700,7 @@ void test_completableFutureListToArray() {
@SuppressWarnings("unchecked")
CompletableFuture[] input = new CompletableFuture[]{
CompletableFuture.completedFuture(n),
- CompletableFuture.completedFuture(another_n)
+ CompletableFuture.completedFuture(anotherN)
};
assertArrayEquals(input, CffuFactory.completableFutureListToArray(Arrays.asList(input)));
@@ -772,6 +758,8 @@ void test_executorSetting_MayBe_ThreadPerTaskExecutor() throws Exception {
//# Test helper methods
////////////////////////////////////////////////////////////////////////////////
+ private static CffuFactory cffuFactory;
+
private static ExecutorService executorService;
private static ExecutorService anotherExecutorService;
diff --git a/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java b/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java
index 20b8e842..0201cfbf 100644
--- a/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java
+++ b/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java
@@ -1,7 +1,6 @@
package io.foldright.cffu;
import io.foldright.test_utils.TestThreadPoolManager;
-import io.foldright.test_utils.TestUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -11,8 +10,7 @@
import java.util.concurrent.*;
import static io.foldright.cffu.CffuFactoryBuilder.newCffuFactoryBuilder;
-import static io.foldright.cffu.CffuFactoryTest.n;
-import static io.foldright.cffu.CffuFactoryTest.rte;
+import static io.foldright.test_utils.TestUtils.*;
import static org.junit.jupiter.api.Assertions.*;
@@ -76,7 +74,7 @@ void test_cffuJoin() {
// Incomplete Future -> join before timeout
Cffu cffu = cffuFactory.supplyAsync(() -> {
- TestUtils.sleep(300);
+ sleep(300);
return 42;
});
assertEquals(42, cffu.cffuJoin(3, TimeUnit.SECONDS));
diff --git a/cffu-core/src/test/java/io/foldright/compatibility_test/CffuApiCompatibilityTest.java b/cffu-core/src/test/java/io/foldright/compatibility_test/CffuApiCompatibilityTest.java
index 2b7802aa..9def890b 100644
--- a/cffu-core/src/test/java/io/foldright/compatibility_test/CffuApiCompatibilityTest.java
+++ b/cffu-core/src/test/java/io/foldright/compatibility_test/CffuApiCompatibilityTest.java
@@ -13,7 +13,7 @@
import io.foldright.cffu.CffuFactory;
import io.foldright.cffu.CffuFactoryBuilder;
import io.foldright.test_utils.TestThreadPoolManager;
-import io.foldright.test_utils.TestUtils;
+import io.foldright.test_utils.CoreTestUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -44,7 +44,7 @@ void factoryMethods_byImmediateValue() throws Exception {
// completedFuture
Cffu f0 = cffuFactory.completedFuture(hello);
assertEquals(hello, f0.get());
- TestUtils.shouldNotBeMinimalStage(f0);
+ CoreTestUtils.shouldNotBeMinimalStage(f0);
// below methods is tested in below test method
// - completedStage
// - failedFuture
@@ -56,7 +56,7 @@ void factoryMethods_byImmediateValue__Java9() throws Exception {
// completedStage
Cffu cf = (Cffu) cffuFactory.completedStage(hello);
assertEquals(hello, cf.toCompletableFuture().get());
- TestUtils.shouldBeMinimalStage(cf);
+ CoreTestUtils.shouldBeMinimalStage(cf);
// failedFuture
cf = cffuFactory.failedFuture(rte);
@@ -66,7 +66,7 @@ void factoryMethods_byImmediateValue__Java9() throws Exception {
} catch (ExecutionException expected) {
assertSame(rte, expected.getCause());
}
- TestUtils.shouldNotBeMinimalStage(cf);
+ CoreTestUtils.shouldNotBeMinimalStage(cf);
// failedStage
cf = (Cffu) cffuFactory.failedStage(rte);
@@ -76,7 +76,7 @@ void factoryMethods_byImmediateValue__Java9() throws Exception {
} catch (ExecutionException expected) {
assertSame(rte, expected.getCause());
}
- TestUtils.shouldBeMinimalStage(cf);
+ CoreTestUtils.shouldBeMinimalStage(cf);
}
@Test
@@ -85,35 +85,35 @@ void factoryMethods_byLambda() throws Exception {
// runAsync
Cffu cf = cffuFactory.runAsync(() -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
holder.set(hello);
});
assertNull(cf.get());
assertEquals(hello, holder.get());
- TestUtils.shouldNotBeMinimalStage(cf);
+ CoreTestUtils.shouldNotBeMinimalStage(cf);
holder.set(null);
cf = cffuFactory.runAsync(() -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
holder.set(hello);
}, anotherExecutorService);
assertNull(cf.get());
assertEquals(hello, holder.get());
- TestUtils.shouldNotBeMinimalStage(cf);
+ CoreTestUtils.shouldNotBeMinimalStage(cf);
// supplyAsync
Cffu s_cf = cffuFactory.supplyAsync(() -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
return hello;
});
assertEquals(hello, s_cf.get());
- TestUtils.shouldNotBeMinimalStage(s_cf);
+ CoreTestUtils.shouldNotBeMinimalStage(s_cf);
s_cf = cffuFactory.supplyAsync(() -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
return hello;
}, anotherExecutorService);
assertEquals(hello, s_cf.get());
- TestUtils.shouldNotBeMinimalStage(s_cf);
+ CoreTestUtils.shouldNotBeMinimalStage(s_cf);
}
@Test
@@ -154,7 +154,7 @@ void staticMethods_delayedExecutor() throws Exception {
Executor delayer = cffuFactory.delayedExecutor(1, TimeUnit.MILLISECONDS);
cffuFactory.runAsync(() -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
holder.set(hello);
}, delayer).get();
assertEquals(hello, holder.get());
@@ -162,7 +162,7 @@ void staticMethods_delayedExecutor() throws Exception {
holder.set(null);
delayer = cffuFactory.delayedExecutor(1, TimeUnit.MILLISECONDS, anotherExecutorService);
cffuFactory.runAsync(() -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
holder.set(hello);
}, delayer).get();
assertEquals(hello, holder.get());
@@ -182,13 +182,13 @@ void simpleThenMethods() throws Exception {
assertEquals(hello, holder.get());
holder.set(null);
cf.thenRunAsync(() -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
holder.set(hello);
}).get();
assertEquals(hello, holder.get());
holder.set(null);
cf.thenRunAsync(() -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
holder.set(hello);
}, anotherExecutorService).get();
assertEquals(hello, holder.get());
@@ -198,24 +198,24 @@ void simpleThenMethods() throws Exception {
assertEquals(hello, holder.get());
holder.set(null);
cf.thenAcceptAsync(x -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
holder.set(hello);
}).get();
assertEquals(hello, holder.get());
holder.set(null);
cf.thenAcceptAsync(x -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
holder.set(hello);
}, anotherExecutorService).get();
assertEquals(hello, holder.get());
assertEquals(43, cf.thenApply(x -> x + 1).get());
assertEquals(44, cf.thenApplyAsync(x -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
return x + 2;
}).get());
assertEquals(45, cf.thenApplyAsync(x -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
return x + 3;
}, anotherExecutorService).get());
}
@@ -230,13 +230,13 @@ void thenBoth_Methods() throws Exception {
assertEquals(hello, holder.get());
holder.set(null);
cf.runAfterBothAsync(cf, () -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
holder.set(hello);
}).get();
assertEquals(hello, holder.get());
holder.set(null);
cf.runAfterBothAsync(cf, () -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
holder.set(hello);
}, anotherExecutorService).get();
assertEquals(hello, holder.get());
@@ -246,24 +246,24 @@ void thenBoth_Methods() throws Exception {
assertEquals(hello, holder.get());
holder.set(null);
cf.thenAcceptBothAsync(cf, (x, y) -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
holder.set(hello);
}).get();
assertEquals(hello, holder.get());
holder.set(null);
cf.thenAcceptBothAsync(cf, (x, y) -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
holder.set(hello);
}, anotherExecutorService).get();
assertEquals(hello, holder.get());
assertEquals(84, cf.thenCombine(cf, Integer::sum).get());
assertEquals(84, cf.thenCombineAsync(cf, (a, b) -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
return Integer.sum(a, b);
}).get());
assertEquals(84, cf.thenCombineAsync(cf, (a, b) -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
return Integer.sum(a, b);
}, anotherExecutorService).get());
}
@@ -278,13 +278,13 @@ void thenEither_Methods() throws Exception {
assertEquals(hello, holder.get());
holder.set(null);
cf.runAfterEitherAsync(cf, () -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
holder.set(hello);
}).get();
assertEquals(hello, holder.get());
holder.set(null);
cf.runAfterEitherAsync(cf, () -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
holder.set(hello);
}, anotherExecutorService).get();
assertEquals(hello, holder.get());
@@ -294,24 +294,24 @@ void thenEither_Methods() throws Exception {
assertEquals(hello, holder.get());
holder.set(null);
cf.acceptEitherAsync(cf, x -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
holder.set(hello);
}).get();
assertEquals(hello, holder.get());
holder.set(null);
cf.acceptEitherAsync(cf, x -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
holder.set(hello);
}, anotherExecutorService).get();
assertEquals(hello, holder.get());
assertEquals(43, cf.applyToEither(cf, x -> x + 1).get());
assertEquals(44, cf.applyToEitherAsync(cf, x -> {
- TestUtils.assertCffuRunInDefaultThread(executorService);
+ CoreTestUtils.assertCffuRunInDefaultThread(executorService);
return x + 2;
}).get());
assertEquals(45, cf.applyToEitherAsync(cf, x -> {
- TestUtils.assertCffuRunInThreadOf(anotherExecutorService);
+ CoreTestUtils.assertCffuRunInThreadOf(anotherExecutorService);
return x + 3;
}, anotherExecutorService).get());
}
@@ -319,7 +319,7 @@ void thenEither_Methods() throws Exception {
@Test
void errorHandling_methods() throws Exception {
Cffu cf = cffuFactory.completedFuture(42);
- Cffu